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_name = launch_config_name
|
||||
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)
|
||||
|
||||
|
@ -75,7 +75,13 @@ def metadata_response(request, full_url, headers):
|
||||
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 == '':
|
||||
result = 'iam'
|
||||
elif path == 'iam':
|
||||
|
@ -3,10 +3,10 @@ import datetime
|
||||
import json
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
# python 2.6 or earlier, use backport
|
||||
from ordereddict import OrderedDict
|
||||
# python 2.6 or earlier, use backport
|
||||
from ordereddict import OrderedDict
|
||||
|
||||
|
||||
from moto.core import BaseBackend
|
||||
|
@ -36,23 +36,23 @@ class Instance(BotoInstance):
|
||||
self._state = InstanceState("running", 16)
|
||||
self.user_data = user_data
|
||||
|
||||
def start(self):
|
||||
def start(self, *args, **kwargs):
|
||||
self._state.name = "running"
|
||||
self._state.code = 16
|
||||
|
||||
def stop(self):
|
||||
def stop(self, *args, **kwargs):
|
||||
self._state.name = "stopped"
|
||||
self._state.code = 80
|
||||
|
||||
def terminate(self):
|
||||
def terminate(self, *args, **kwargs):
|
||||
self._state.name = "terminated"
|
||||
self._state.code = 48
|
||||
|
||||
def reboot(self):
|
||||
def reboot(self, *args, **kwargs):
|
||||
self._state.name = "running"
|
||||
self._state.code = 16
|
||||
|
||||
def get_tags(self):
|
||||
def get_tags(self, *args, **kwargs):
|
||||
tags = ec2_backend.describe_tags(self.id)
|
||||
return tags
|
||||
|
||||
@ -562,7 +562,7 @@ class SpotRequestBackend(object):
|
||||
instance_type, placement, kernel_id, ramdisk_id,
|
||||
monitoring_enabled, subnet_id):
|
||||
requests = []
|
||||
for index in range(count):
|
||||
for _ in range(count):
|
||||
spot_request_id = random_spot_request_id()
|
||||
request = SpotInstanceRequest(
|
||||
spot_request_id, price, image_id, type, valid_from, valid_until,
|
||||
@ -584,7 +584,7 @@ class SpotRequestBackend(object):
|
||||
return requests
|
||||
|
||||
|
||||
class ElasticAddress():
|
||||
class ElasticAddress(object):
|
||||
def __init__(self, domain):
|
||||
self.public_ip = random_ip()
|
||||
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)
|
||||
|
||||
def modify_instance_attribute(self):
|
||||
attribute_key = None
|
||||
for key, value in self.querystring.iteritems():
|
||||
if '.Value' in key:
|
||||
attribute_key = key
|
||||
break
|
||||
|
||||
value = self.querystring.get(key)[0]
|
||||
normalized_attribute = camelcase_to_underscores(key.split(".")[0])
|
||||
if not attribute_key:
|
||||
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_id = instance_ids[0]
|
||||
ec2_backend.modify_instance_attribute(instance_id, normalized_attribute, value)
|
||||
|
@ -100,7 +100,7 @@ class FakeJobFlow(object):
|
||||
def master_instance_type(self):
|
||||
groups = self.instance_groups
|
||||
if groups:
|
||||
groups[0].type
|
||||
return groups[0].type
|
||||
else:
|
||||
return self.initial_master_instance_type
|
||||
|
||||
@ -108,7 +108,7 @@ class FakeJobFlow(object):
|
||||
def slave_instance_type(self):
|
||||
groups = self.instance_groups
|
||||
if groups:
|
||||
groups[0].type
|
||||
return groups[0].type
|
||||
else:
|
||||
return self.initial_slave_instance_type
|
||||
|
||||
|
@ -2,7 +2,7 @@ from moto.core import BaseBackend
|
||||
from moto.core.utils import get_random_hex
|
||||
|
||||
|
||||
class FakeZone:
|
||||
class FakeZone(object):
|
||||
|
||||
def __init__(self, name, id):
|
||||
self.name = name
|
||||
|
Loading…
Reference in New Issue
Block a user