opsworks: py2.6 compat str.format
This commit is contained in:
parent
3a8268fd56
commit
768f1adb4f
@ -77,7 +77,7 @@ class OpsworkInstance(object):
|
|||||||
self.infrastructure_class = "ec2 (fixed)"
|
self.infrastructure_class = "ec2 (fixed)"
|
||||||
self.platform = "linux (fixed)"
|
self.platform = "linux (fixed)"
|
||||||
|
|
||||||
self.id = "{}".format(uuid.uuid4())
|
self.id = "{0}".format(uuid.uuid4())
|
||||||
self.created_at = datetime.datetime.utcnow()
|
self.created_at = datetime.datetime.utcnow()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
@ -249,7 +249,7 @@ class Layer(object):
|
|||||||
self.install_updates_on_boot = install_updates_on_boot
|
self.install_updates_on_boot = install_updates_on_boot
|
||||||
self.use_ebs_optimized_instances = use_ebs_optimized_instances
|
self.use_ebs_optimized_instances = use_ebs_optimized_instances
|
||||||
|
|
||||||
self.id = "{}".format(uuid.uuid4())
|
self.id = "{0}".format(uuid.uuid4())
|
||||||
self.created_at = datetime.datetime.utcnow()
|
self.created_at = datetime.datetime.utcnow()
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
@ -338,7 +338,7 @@ class Stack(object):
|
|||||||
self.default_root_device_type = default_root_device_type
|
self.default_root_device_type = default_root_device_type
|
||||||
self.agent_version = agent_version
|
self.agent_version = agent_version
|
||||||
|
|
||||||
self.id = "{}".format(uuid.uuid4())
|
self.id = "{0}".format(uuid.uuid4())
|
||||||
self.layers = []
|
self.layers = []
|
||||||
self.apps = []
|
self.apps = []
|
||||||
self.account_number = "123456789012"
|
self.account_number = "123456789012"
|
||||||
@ -417,11 +417,11 @@ class OpsWorksBackend(BaseBackend):
|
|||||||
raise ResourceNotFoundException(stackid)
|
raise ResourceNotFoundException(stackid)
|
||||||
if name in [l.name for l in self.layers.values()]:
|
if name in [l.name for l in self.layers.values()]:
|
||||||
raise ValidationException(
|
raise ValidationException(
|
||||||
'There is already a layer named "{}" '
|
'There is already a layer named "{0}" '
|
||||||
'for this stack'.format(name))
|
'for this stack'.format(name))
|
||||||
if shortname in [l.shortname for l in self.layers.values()]:
|
if shortname in [l.shortname for l in self.layers.values()]:
|
||||||
raise ValidationException(
|
raise ValidationException(
|
||||||
'There is already a layer with shortname "{}" '
|
'There is already a layer with shortname "{0}" '
|
||||||
'for this stack'.format(shortname))
|
'for this stack'.format(shortname))
|
||||||
layer = Layer(**kwargs)
|
layer = Layer(**kwargs)
|
||||||
self.layers[layer.id] = layer
|
self.layers[layer.id] = layer
|
||||||
@ -434,7 +434,7 @@ class OpsWorksBackend(BaseBackend):
|
|||||||
|
|
||||||
if stack_id not in self.stacks:
|
if stack_id not in self.stacks:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Unable to find stack with ID {}".format(stack_id))
|
"Unable to find stack with ID {0}".format(stack_id))
|
||||||
|
|
||||||
unknown_layers = set(layer_ids) - set(self.layers.keys())
|
unknown_layers = set(layer_ids) - set(self.layers.keys())
|
||||||
if unknown_layers:
|
if unknown_layers:
|
||||||
@ -484,7 +484,7 @@ class OpsWorksBackend(BaseBackend):
|
|||||||
if stack_id is not None:
|
if stack_id is not None:
|
||||||
if stack_id not in self.stacks:
|
if stack_id not in self.stacks:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Unable to find stack with ID {}".format(stack_id))
|
"Unable to find stack with ID {0}".format(stack_id))
|
||||||
return [layer.to_dict() for layer in self.stacks[stack_id].layers]
|
return [layer.to_dict() for layer in self.stacks[stack_id].layers]
|
||||||
|
|
||||||
unknown_layers = set(layer_ids) - set(self.layers.keys())
|
unknown_layers = set(layer_ids) - set(self.layers.keys())
|
||||||
@ -506,21 +506,21 @@ class OpsWorksBackend(BaseBackend):
|
|||||||
if layer_id:
|
if layer_id:
|
||||||
if layer_id not in self.layers:
|
if layer_id not in self.layers:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Unable to find layer with ID {}".format(layer_id))
|
"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
|
return instances
|
||||||
|
|
||||||
if stack_id:
|
if stack_id:
|
||||||
if stack_id not in self.stacks:
|
if stack_id not in self.stacks:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Unable to find stack with ID {}".format(stack_id))
|
"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
|
return instances
|
||||||
|
|
||||||
def start_instance(self, instance_id):
|
def start_instance(self, instance_id):
|
||||||
if instance_id not in self.instances:
|
if instance_id not in self.instances:
|
||||||
raise ResourceNotFoundException(
|
raise ResourceNotFoundException(
|
||||||
"Unable to find instance with ID {}".format(instance_id))
|
"Unable to find instance with ID {0}".format(instance_id))
|
||||||
self.instances[instance_id].start()
|
self.instances[instance_id].start()
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ def test_describe_stacks():
|
|||||||
client = boto3.client('opsworks', region_name='us-east-1')
|
client = boto3.client('opsworks', region_name='us-east-1')
|
||||||
for i in range(1, 4):
|
for i in range(1, 4):
|
||||||
client.create_stack(
|
client.create_stack(
|
||||||
Name="test_stack_{}".format(i),
|
Name="test_stack_{0}".format(i),
|
||||||
Region="us-east-1",
|
Region="us-east-1",
|
||||||
ServiceRoleArn="service_arn",
|
ServiceRoleArn="service_arn",
|
||||||
DefaultInstanceProfileArn="profile_arn"
|
DefaultInstanceProfileArn="profile_arn"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user