Lints.
This commit is contained in:
parent
1433f28846
commit
f37bad0e00
260 changed files with 6363 additions and 3766 deletions
|
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
from .models import opsworks_backends
|
||||
from ..core.models import MockAWS, base_decorator, HttprettyMockAWS, deprecated_base_decorator
|
||||
from ..core.models import base_decorator, deprecated_base_decorator
|
||||
|
||||
opsworks_backend = opsworks_backends['us-east-1']
|
||||
mock_opsworks = base_decorator(opsworks_backends)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ from werkzeug.exceptions import BadRequest
|
|||
|
||||
|
||||
class ResourceNotFoundException(BadRequest):
|
||||
|
||||
def __init__(self, message):
|
||||
super(ResourceNotFoundException, self).__init__()
|
||||
self.description = json.dumps({
|
||||
|
|
@ -14,6 +15,7 @@ class ResourceNotFoundException(BadRequest):
|
|||
|
||||
|
||||
class ValidationException(BadRequest):
|
||||
|
||||
def __init__(self, message):
|
||||
super(ValidationException, self).__init__()
|
||||
self.description = json.dumps({
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ class OpsworkInstance(object):
|
|||
This metadata exists before any instance reservations are made, and is
|
||||
used to populate a reservation request when "start" is called
|
||||
"""
|
||||
|
||||
def __init__(self, stack_id, layer_ids, instance_type, ec2_backend,
|
||||
auto_scale_type=None,
|
||||
hostname=None,
|
||||
|
|
@ -154,8 +155,10 @@ class OpsworkInstance(object):
|
|||
d.update({"ReportedAgentVersion": "2425-20160406102508 (fixed)"})
|
||||
d.update({"RootDeviceVolumeId": "vol-a20e450a (fixed)"})
|
||||
if self.ssh_keyname is not None:
|
||||
d.update({"SshHostDsaKeyFingerprint": "24:36:32:fe:d8:5f:9c:18:b1:ad:37:e9:eb:e8:69:58 (fixed)"})
|
||||
d.update({"SshHostRsaKeyFingerprint": "3c:bd:37:52:d7:ca:67:e1:6e:4b:ac:31:86:79:f5:6c (fixed)"})
|
||||
d.update(
|
||||
{"SshHostDsaKeyFingerprint": "24:36:32:fe:d8:5f:9c:18:b1:ad:37:e9:eb:e8:69:58 (fixed)"})
|
||||
d.update(
|
||||
{"SshHostRsaKeyFingerprint": "3c:bd:37:52:d7:ca:67:e1:6e:4b:ac:31:86:79:f5:6c (fixed)"})
|
||||
d.update({"PrivateDns": self.instance.private_dns})
|
||||
d.update({"PrivateIp": self.instance.private_ip})
|
||||
d.update({"PublicDns": getattr(self.instance, 'public_dns', None)})
|
||||
|
|
@ -164,6 +167,7 @@ class OpsworkInstance(object):
|
|||
|
||||
|
||||
class Layer(object):
|
||||
|
||||
def __init__(self, stack_id, type, name, shortname,
|
||||
attributes=None,
|
||||
custom_instance_profile_arn=None,
|
||||
|
|
@ -283,11 +287,13 @@ class Layer(object):
|
|||
if self.custom_json is not None:
|
||||
d.update({"CustomJson": self.custom_json})
|
||||
if self.custom_instance_profile_arn is not None:
|
||||
d.update({"CustomInstanceProfileArn": self.custom_instance_profile_arn})
|
||||
d.update(
|
||||
{"CustomInstanceProfileArn": self.custom_instance_profile_arn})
|
||||
return d
|
||||
|
||||
|
||||
class Stack(object):
|
||||
|
||||
def __init__(self, name, region, service_role_arn, default_instance_profile_arn,
|
||||
vpcid="vpc-1f99bf7a",
|
||||
attributes=None,
|
||||
|
|
@ -393,6 +399,7 @@ class Stack(object):
|
|||
|
||||
|
||||
class OpsWorksBackend(BaseBackend):
|
||||
|
||||
def __init__(self, ec2_backend):
|
||||
self.stacks = {}
|
||||
self.layers = {}
|
||||
|
|
@ -457,9 +464,12 @@ class OpsWorksBackend(BaseBackend):
|
|||
kwargs.setdefault("subnet_id", stack.default_subnet_id)
|
||||
kwargs.setdefault("root_device_type", stack.default_root_device_type)
|
||||
if layer.custom_instance_profile_arn:
|
||||
kwargs.setdefault("instance_profile_arn", layer.custom_instance_profile_arn)
|
||||
kwargs.setdefault("instance_profile_arn", stack.default_instance_profile_arn)
|
||||
kwargs.setdefault("security_group_ids", layer.custom_security_group_ids)
|
||||
kwargs.setdefault("instance_profile_arn",
|
||||
layer.custom_instance_profile_arn)
|
||||
kwargs.setdefault("instance_profile_arn",
|
||||
stack.default_instance_profile_arn)
|
||||
kwargs.setdefault("security_group_ids",
|
||||
layer.custom_security_group_ids)
|
||||
kwargs.setdefault("associate_public_ip", layer.auto_assign_public_ips)
|
||||
kwargs.setdefault("ebs_optimized", layer.use_ebs_optimized_instances)
|
||||
kwargs.update({"ec2_backend": self.ec2_backend})
|
||||
|
|
@ -507,14 +517,16 @@ class OpsWorksBackend(BaseBackend):
|
|||
if layer_id not in self.layers:
|
||||
raise ResourceNotFoundException(
|
||||
"Unable to find layer with ID {0}".format(layer_id))
|
||||
instances = [i.to_dict() for i in self.instances.values() if layer_id in i.layer_ids]
|
||||
instances = [i.to_dict() for i in self.instances.values()
|
||||
if layer_id in i.layer_ids]
|
||||
return instances
|
||||
|
||||
if stack_id:
|
||||
if stack_id not in self.stacks:
|
||||
raise ResourceNotFoundException(
|
||||
"Unable to find stack with ID {0}".format(stack_id))
|
||||
instances = [i.to_dict() for i in self.instances.values() if stack_id==i.stack_id]
|
||||
instances = [i.to_dict() for i in self.instances.values()
|
||||
if stack_id == i.stack_id]
|
||||
return instances
|
||||
|
||||
def start_instance(self, instance_id):
|
||||
|
|
|
|||
|
|
@ -22,19 +22,24 @@ class OpsWorksResponse(BaseResponse):
|
|||
region=self.parameters.get("Region"),
|
||||
vpcid=self.parameters.get("VpcId"),
|
||||
attributes=self.parameters.get("Attributes"),
|
||||
default_instance_profile_arn=self.parameters.get("DefaultInstanceProfileArn"),
|
||||
default_instance_profile_arn=self.parameters.get(
|
||||
"DefaultInstanceProfileArn"),
|
||||
default_os=self.parameters.get("DefaultOs"),
|
||||
hostname_theme=self.parameters.get("HostnameTheme"),
|
||||
default_availability_zone=self.parameters.get("DefaultAvailabilityZone"),
|
||||
default_availability_zone=self.parameters.get(
|
||||
"DefaultAvailabilityZone"),
|
||||
default_subnet_id=self.parameters.get("DefaultInstanceProfileArn"),
|
||||
custom_json=self.parameters.get("CustomJson"),
|
||||
configuration_manager=self.parameters.get("ConfigurationManager"),
|
||||
chef_configuration=self.parameters.get("ChefConfiguration"),
|
||||
use_custom_cookbooks=self.parameters.get("UseCustomCookbooks"),
|
||||
use_opsworks_security_groups=self.parameters.get("UseOpsworksSecurityGroups"),
|
||||
custom_cookbooks_source=self.parameters.get("CustomCookbooksSource"),
|
||||
use_opsworks_security_groups=self.parameters.get(
|
||||
"UseOpsworksSecurityGroups"),
|
||||
custom_cookbooks_source=self.parameters.get(
|
||||
"CustomCookbooksSource"),
|
||||
default_ssh_keyname=self.parameters.get("DefaultSshKeyName"),
|
||||
default_root_device_type=self.parameters.get("DefaultRootDeviceType"),
|
||||
default_root_device_type=self.parameters.get(
|
||||
"DefaultRootDeviceType"),
|
||||
service_role_arn=self.parameters.get("ServiceRoleArn"),
|
||||
agent_version=self.parameters.get("AgentVersion"),
|
||||
)
|
||||
|
|
@ -48,18 +53,24 @@ class OpsWorksResponse(BaseResponse):
|
|||
name=self.parameters.get('Name'),
|
||||
shortname=self.parameters.get('Shortname'),
|
||||
attributes=self.parameters.get('Attributes'),
|
||||
custom_instance_profile_arn=self.parameters.get("CustomInstanceProfileArn"),
|
||||
custom_instance_profile_arn=self.parameters.get(
|
||||
"CustomInstanceProfileArn"),
|
||||
custom_json=self.parameters.get("CustomJson"),
|
||||
custom_security_group_ids=self.parameters.get('CustomSecurityGroupIds'),
|
||||
custom_security_group_ids=self.parameters.get(
|
||||
'CustomSecurityGroupIds'),
|
||||
packages=self.parameters.get('Packages'),
|
||||
volume_configurations=self.parameters.get("VolumeConfigurations"),
|
||||
enable_autohealing=self.parameters.get("EnableAutoHealing"),
|
||||
auto_assign_elastic_ips=self.parameters.get("AutoAssignElasticIps"),
|
||||
auto_assign_elastic_ips=self.parameters.get(
|
||||
"AutoAssignElasticIps"),
|
||||
auto_assign_public_ips=self.parameters.get("AutoAssignPublicIps"),
|
||||
custom_recipes=self.parameters.get("CustomRecipes"),
|
||||
install_updates_on_boot=self.parameters.get("InstallUpdatesOnBoot"),
|
||||
use_ebs_optimized_instances=self.parameters.get("UseEbsOptimizedInstances"),
|
||||
lifecycle_event_configuration=self.parameters.get("LifecycleEventConfiguration")
|
||||
install_updates_on_boot=self.parameters.get(
|
||||
"InstallUpdatesOnBoot"),
|
||||
use_ebs_optimized_instances=self.parameters.get(
|
||||
"UseEbsOptimizedInstances"),
|
||||
lifecycle_event_configuration=self.parameters.get(
|
||||
"LifecycleEventConfiguration")
|
||||
)
|
||||
layer = self.opsworks_backend.create_layer(**kwargs)
|
||||
return json.dumps({"LayerId": layer.id}, indent=1)
|
||||
|
|
@ -80,7 +91,8 @@ class OpsWorksResponse(BaseResponse):
|
|||
architecture=self.parameters.get("Architecture"),
|
||||
root_device_type=self.parameters.get("RootDeviceType"),
|
||||
block_device_mappings=self.parameters.get("BlockDeviceMappings"),
|
||||
install_updates_on_boot=self.parameters.get("InstallUpdatesOnBoot"),
|
||||
install_updates_on_boot=self.parameters.get(
|
||||
"InstallUpdatesOnBoot"),
|
||||
ebs_optimized=self.parameters.get("EbsOptimized"),
|
||||
agent_version=self.parameters.get("AgentVersion"),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue