Cleanup some style
This commit is contained in:
parent
74e2c19865
commit
c1f224954e
@ -83,6 +83,8 @@ class FakeAutoScalingGroup(object):
|
|||||||
self.launch_config = autoscaling_backend.launch_configurations[launch_config_name]
|
self.launch_config = autoscaling_backend.launch_configurations[launch_config_name]
|
||||||
self.launch_config_name = launch_config_name
|
self.launch_config_name = launch_config_name
|
||||||
self.vpc_zone_identifier = vpc_zone_identifier
|
self.vpc_zone_identifier = vpc_zone_identifier
|
||||||
|
self.health_check_period = health_check_period
|
||||||
|
self.health_check_type = health_check_type
|
||||||
|
|
||||||
self.set_desired_capacity(desired_capacity)
|
self.set_desired_capacity(desired_capacity)
|
||||||
|
|
||||||
|
@ -75,7 +75,13 @@ def metadata_response(request, full_url, headers):
|
|||||||
Expiration=tomorrow.strftime("%Y-%m-%dT%H:%M:%SZ")
|
Expiration=tomorrow.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||||
)
|
)
|
||||||
|
|
||||||
path = parsed_url.path.lstrip("/latest/meta-data/")
|
path = parsed_url.path
|
||||||
|
|
||||||
|
meta_data_prefix = "/latest/meta-data/"
|
||||||
|
# Strip prefix if it is there
|
||||||
|
if path.startswith(meta_data_prefix):
|
||||||
|
path = path[len(meta_data_prefix):]
|
||||||
|
|
||||||
if path == '':
|
if path == '':
|
||||||
result = 'iam'
|
result = 'iam'
|
||||||
elif path == 'iam':
|
elif path == 'iam':
|
||||||
|
@ -3,10 +3,10 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# python 2.6 or earlier, use backport
|
# python 2.6 or earlier, use backport
|
||||||
from ordereddict import OrderedDict
|
from ordereddict import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
from moto.core import BaseBackend
|
from moto.core import BaseBackend
|
||||||
|
@ -36,23 +36,23 @@ class Instance(BotoInstance):
|
|||||||
self._state = InstanceState("running", 16)
|
self._state = InstanceState("running", 16)
|
||||||
self.user_data = user_data
|
self.user_data = user_data
|
||||||
|
|
||||||
def start(self):
|
def start(self, *args, **kwargs):
|
||||||
self._state.name = "running"
|
self._state.name = "running"
|
||||||
self._state.code = 16
|
self._state.code = 16
|
||||||
|
|
||||||
def stop(self):
|
def stop(self, *args, **kwargs):
|
||||||
self._state.name = "stopped"
|
self._state.name = "stopped"
|
||||||
self._state.code = 80
|
self._state.code = 80
|
||||||
|
|
||||||
def terminate(self):
|
def terminate(self, *args, **kwargs):
|
||||||
self._state.name = "terminated"
|
self._state.name = "terminated"
|
||||||
self._state.code = 48
|
self._state.code = 48
|
||||||
|
|
||||||
def reboot(self):
|
def reboot(self, *args, **kwargs):
|
||||||
self._state.name = "running"
|
self._state.name = "running"
|
||||||
self._state.code = 16
|
self._state.code = 16
|
||||||
|
|
||||||
def get_tags(self):
|
def get_tags(self, *args, **kwargs):
|
||||||
tags = ec2_backend.describe_tags(self.id)
|
tags = ec2_backend.describe_tags(self.id)
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
@ -562,7 +562,7 @@ class SpotRequestBackend(object):
|
|||||||
instance_type, placement, kernel_id, ramdisk_id,
|
instance_type, placement, kernel_id, ramdisk_id,
|
||||||
monitoring_enabled, subnet_id):
|
monitoring_enabled, subnet_id):
|
||||||
requests = []
|
requests = []
|
||||||
for index in range(count):
|
for _ in range(count):
|
||||||
spot_request_id = random_spot_request_id()
|
spot_request_id = random_spot_request_id()
|
||||||
request = SpotInstanceRequest(
|
request = SpotInstanceRequest(
|
||||||
spot_request_id, price, image_id, type, valid_from, valid_until,
|
spot_request_id, price, image_id, type, valid_from, valid_until,
|
||||||
@ -584,7 +584,7 @@ class SpotRequestBackend(object):
|
|||||||
return requests
|
return requests
|
||||||
|
|
||||||
|
|
||||||
class ElasticAddress():
|
class ElasticAddress(object):
|
||||||
def __init__(self, domain):
|
def __init__(self, domain):
|
||||||
self.public_ip = random_ip()
|
self.public_ip = random_ip()
|
||||||
self.allocation_id = random_eip_allocation_id() if domain == "vpc" else None
|
self.allocation_id = random_eip_allocation_id() if domain == "vpc" else None
|
||||||
|
@ -68,12 +68,16 @@ class InstanceResponse(BaseResponse):
|
|||||||
return template.render(instance=instance, attribute=attribute, value=value)
|
return template.render(instance=instance, attribute=attribute, value=value)
|
||||||
|
|
||||||
def modify_instance_attribute(self):
|
def modify_instance_attribute(self):
|
||||||
|
attribute_key = None
|
||||||
for key, value in self.querystring.iteritems():
|
for key, value in self.querystring.iteritems():
|
||||||
if '.Value' in key:
|
if '.Value' in key:
|
||||||
|
attribute_key = key
|
||||||
break
|
break
|
||||||
|
|
||||||
value = self.querystring.get(key)[0]
|
if not attribute_key:
|
||||||
normalized_attribute = camelcase_to_underscores(key.split(".")[0])
|
return
|
||||||
|
value = self.querystring.get(attribute_key)[0]
|
||||||
|
normalized_attribute = camelcase_to_underscores(attribute_key.split(".")[0])
|
||||||
instance_ids = instance_ids_from_querystring(self.querystring)
|
instance_ids = instance_ids_from_querystring(self.querystring)
|
||||||
instance_id = instance_ids[0]
|
instance_id = instance_ids[0]
|
||||||
ec2_backend.modify_instance_attribute(instance_id, normalized_attribute, value)
|
ec2_backend.modify_instance_attribute(instance_id, normalized_attribute, value)
|
||||||
|
@ -100,7 +100,7 @@ class FakeJobFlow(object):
|
|||||||
def master_instance_type(self):
|
def master_instance_type(self):
|
||||||
groups = self.instance_groups
|
groups = self.instance_groups
|
||||||
if groups:
|
if groups:
|
||||||
groups[0].type
|
return groups[0].type
|
||||||
else:
|
else:
|
||||||
return self.initial_master_instance_type
|
return self.initial_master_instance_type
|
||||||
|
|
||||||
@ -108,7 +108,7 @@ class FakeJobFlow(object):
|
|||||||
def slave_instance_type(self):
|
def slave_instance_type(self):
|
||||||
groups = self.instance_groups
|
groups = self.instance_groups
|
||||||
if groups:
|
if groups:
|
||||||
groups[0].type
|
return groups[0].type
|
||||||
else:
|
else:
|
||||||
return self.initial_slave_instance_type
|
return self.initial_slave_instance_type
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ from moto.core import BaseBackend
|
|||||||
from moto.core.utils import get_random_hex
|
from moto.core.utils import get_random_hex
|
||||||
|
|
||||||
|
|
||||||
class FakeZone:
|
class FakeZone(object):
|
||||||
|
|
||||||
def __init__(self, name, id):
|
def __init__(self, name, id):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
Loading…
x
Reference in New Issue
Block a user