Replace self.properties.get on self.properties[]
Remove unnecessary using self.properties.get for more clear code. Using properties.get(prop, default) causes next issues: 1. properties.get(prop) if prop not in properties_schema will return None instead of expected KeyError. 2. properties.get(prop, default) returns "default" value if current properties is not presented in properties_schema. So using self.properties.get() makes sense only when we plan to use this property with default option in another resource, which has not it in property schema. This patch replaces this methods in resources/openstack folder. Change-Id: I523eb3feacb0cb7a16a928a92896ce56188e376f
This commit is contained in:
parent
4032e40cce
commit
4b5f296acc
|
@ -200,10 +200,10 @@ class CinderVolume(vb.BaseVolume):
|
||||||
'size': self.properties[self.SIZE],
|
'size': self.properties[self.SIZE],
|
||||||
'availability_zone': self.properties[self.AVAILABILITY_ZONE]
|
'availability_zone': self.properties[self.AVAILABILITY_ZONE]
|
||||||
}
|
}
|
||||||
if self.properties.get(self.IMAGE):
|
if self.properties[self.IMAGE]:
|
||||||
arguments['imageRef'] = self.client_plugin('glance').get_image_id(
|
arguments['imageRef'] = self.client_plugin('glance').get_image_id(
|
||||||
self.properties[self.IMAGE])
|
self.properties[self.IMAGE])
|
||||||
elif self.properties.get(self.IMAGE_REF):
|
elif self.properties[self.IMAGE_REF]:
|
||||||
arguments['imageRef'] = self.properties[self.IMAGE_REF]
|
arguments['imageRef'] = self.properties[self.IMAGE_REF]
|
||||||
|
|
||||||
optionals = (self.SNAPSHOT_ID, self.VOLUME_TYPE, self.SOURCE_VOLID,
|
optionals = (self.SNAPSHOT_ID, self.VOLUME_TYPE, self.SOURCE_VOLID,
|
||||||
|
@ -244,9 +244,9 @@ class CinderVolume(vb.BaseVolume):
|
||||||
if self.NAME in prop_diff or self.DESCRIPTION in prop_diff:
|
if self.NAME in prop_diff or self.DESCRIPTION in prop_diff:
|
||||||
vol = cinder.volumes.get(self.resource_id)
|
vol = cinder.volumes.get(self.resource_id)
|
||||||
update_name = (prop_diff.get(self.NAME) or
|
update_name = (prop_diff.get(self.NAME) or
|
||||||
self.properties.get(self.NAME))
|
self.properties[self.NAME])
|
||||||
update_description = (prop_diff.get(self.DESCRIPTION) or
|
update_description = (prop_diff.get(self.DESCRIPTION) or
|
||||||
self.properties.get(self.DESCRIPTION))
|
self.properties[self.DESCRIPTION])
|
||||||
kwargs = self._fetch_name_and_description(
|
kwargs = self._fetch_name_and_description(
|
||||||
cinder.volume_api_version, update_name, update_description)
|
cinder.volume_api_version, update_name, update_description)
|
||||||
cinder.volumes.update(vol, **kwargs)
|
cinder.volumes.update(vol, **kwargs)
|
||||||
|
@ -360,7 +360,7 @@ class CinderVolume(vb.BaseVolume):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
# Scheduler hints are only supported from Cinder API v2
|
# Scheduler hints are only supported from Cinder API v2
|
||||||
if (self.properties.get(self.CINDER_SCHEDULER_HINTS)
|
if (self.properties[self.CINDER_SCHEDULER_HINTS]
|
||||||
and self.client().volume_api_version == 1):
|
and self.client().volume_api_version == 1):
|
||||||
raise exception.StackValidationFailed(
|
raise exception.StackValidationFailed(
|
||||||
message=_('Scheduler hints are not supported by the current '
|
message=_('Scheduler hints are not supported by the current '
|
||||||
|
@ -418,11 +418,11 @@ class CinderVolumeAttachment(vb.BaseVolumeAttachment):
|
||||||
# could be updated in UpdateReplace manner,
|
# could be updated in UpdateReplace manner,
|
||||||
# we still first detach the old resource so that
|
# we still first detach the old resource so that
|
||||||
# self.resource_id is not replaced prematurely
|
# self.resource_id is not replaced prematurely
|
||||||
volume_id = self.properties.get(self.VOLUME_ID)
|
volume_id = self.properties[self.VOLUME_ID]
|
||||||
if self.VOLUME_ID in prop_diff:
|
if self.VOLUME_ID in prop_diff:
|
||||||
volume_id = prop_diff.get(self.VOLUME_ID)
|
volume_id = prop_diff.get(self.VOLUME_ID)
|
||||||
|
|
||||||
device = self.properties.get(self.DEVICE)
|
device = self.properties[self.DEVICE]
|
||||||
if self.DEVICE in prop_diff:
|
if self.DEVICE in prop_diff:
|
||||||
device = prop_diff.get(self.DEVICE)
|
device = prop_diff.get(self.DEVICE)
|
||||||
|
|
||||||
|
|
|
@ -50,8 +50,9 @@ class CloudConfig(software_config.SoftwareConfig):
|
||||||
}
|
}
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
cloud_config = template_format.yaml.dump(self.properties.get(
|
cloud_config = template_format.yaml.dump(
|
||||||
self.CLOUD_CONFIG), Dumper=template_format.yaml_dumper)
|
self.properties[self.CLOUD_CONFIG],
|
||||||
|
Dumper=template_format.yaml_dumper)
|
||||||
props = {
|
props = {
|
||||||
self.NAME: self.physical_resource_name(),
|
self.NAME: self.physical_resource_name(),
|
||||||
self.CONFIG: '#cloud-config\n%s' % cloud_config,
|
self.CONFIG: '#cloud-config\n%s' % cloud_config,
|
||||||
|
|
|
@ -107,7 +107,7 @@ class MultipartMime(software_config.SoftwareConfig):
|
||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
subparts = []
|
subparts = []
|
||||||
for item in self.properties.get(self.PARTS):
|
for item in self.properties[self.PARTS]:
|
||||||
config = item.get(self.CONFIG)
|
config = item.get(self.CONFIG)
|
||||||
part_type = item.get(self.TYPE, self.TEXT)
|
part_type = item.get(self.TYPE, self.TEXT)
|
||||||
part = config
|
part = config
|
||||||
|
|
|
@ -228,9 +228,9 @@ class RandomString(resource.Resource):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(RandomString, self).validate()
|
super(RandomString, self).validate()
|
||||||
sequence = self.properties.get(self.SEQUENCE)
|
sequence = self.properties[self.SEQUENCE]
|
||||||
char_sequences = self.properties.get(self.CHARACTER_SEQUENCES)
|
char_sequences = self.properties[self.CHARACTER_SEQUENCES]
|
||||||
char_classes = self.properties.get(self.CHARACTER_CLASSES)
|
char_classes = self.properties[self.CHARACTER_CLASSES]
|
||||||
|
|
||||||
if sequence and (char_sequences or char_classes):
|
if sequence and (char_sequences or char_classes):
|
||||||
msg = (_("Cannot use deprecated '%(seq)s' property along with "
|
msg = (_("Cannot use deprecated '%(seq)s' property along with "
|
||||||
|
@ -245,7 +245,7 @@ class RandomString(resource.Resource):
|
||||||
return sum(char_dict[min_prop] for char_dict in char_dicts)
|
return sum(char_dict[min_prop] for char_dict in char_dicts)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
length = self.properties.get(self.LENGTH)
|
length = self.properties[self.LENGTH]
|
||||||
min_length = (char_min(char_sequences, self.CHARACTER_SEQUENCES_MIN) +
|
min_length = (char_min(char_sequences, self.CHARACTER_SEQUENCES_MIN) +
|
||||||
char_min(char_classes, self.CHARACTER_CLASSES_MIN))
|
char_min(char_classes, self.CHARACTER_CLASSES_MIN))
|
||||||
if min_length > length:
|
if min_length > length:
|
||||||
|
@ -254,16 +254,16 @@ class RandomString(resource.Resource):
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
char_sequences = self.properties.get(self.CHARACTER_SEQUENCES)
|
char_sequences = self.properties[self.CHARACTER_SEQUENCES]
|
||||||
char_classes = self.properties.get(self.CHARACTER_CLASSES)
|
char_classes = self.properties[self.CHARACTER_CLASSES]
|
||||||
length = self.properties.get(self.LENGTH)
|
length = self.properties[self.LENGTH]
|
||||||
|
|
||||||
if char_sequences or char_classes:
|
if char_sequences or char_classes:
|
||||||
random_string = self._generate_random_string(char_sequences,
|
random_string = self._generate_random_string(char_sequences,
|
||||||
char_classes,
|
char_classes,
|
||||||
length)
|
length)
|
||||||
else:
|
else:
|
||||||
sequence = self.properties.get(self.SEQUENCE)
|
sequence = self.properties[self.SEQUENCE]
|
||||||
if not sequence: # Deprecated property not provided, use a default
|
if not sequence: # Deprecated property not provided, use a default
|
||||||
sequence = "lettersdigits"
|
sequence = "lettersdigits"
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ class SoftwareComponent(sc.SoftwareConfig):
|
||||||
props = dict(self.properties)
|
props = dict(self.properties)
|
||||||
props[self.NAME] = self.physical_resource_name()
|
props[self.NAME] = self.physical_resource_name()
|
||||||
# use config property of SoftwareConfig to store configs list
|
# use config property of SoftwareConfig to store configs list
|
||||||
configs = self.properties.get(self.CONFIGS)
|
configs = self.properties[self.CONFIGS]
|
||||||
props[self.CONFIG] = {self.CONFIGS: configs}
|
props[self.CONFIG] = {self.CONFIGS: configs}
|
||||||
# set 'group' to enable component processing by in-instance hook
|
# set 'group' to enable component processing by in-instance hook
|
||||||
props[self.GROUP] = 'component'
|
props[self.GROUP] = 'component'
|
||||||
|
|
|
@ -179,20 +179,20 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
default_client_name = 'heat'
|
default_client_name = 'heat'
|
||||||
|
|
||||||
def _signal_transport_cfn(self):
|
def _signal_transport_cfn(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SIGNAL_TRANSPORT) == self.CFN_SIGNAL
|
self.SIGNAL_TRANSPORT] == self.CFN_SIGNAL
|
||||||
|
|
||||||
def _signal_transport_heat(self):
|
def _signal_transport_heat(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SIGNAL_TRANSPORT) == self.HEAT_SIGNAL
|
self.SIGNAL_TRANSPORT] == self.HEAT_SIGNAL
|
||||||
|
|
||||||
def _signal_transport_none(self):
|
def _signal_transport_none(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SIGNAL_TRANSPORT) == self.NO_SIGNAL
|
self.SIGNAL_TRANSPORT] == self.NO_SIGNAL
|
||||||
|
|
||||||
def _signal_transport_temp_url(self):
|
def _signal_transport_temp_url(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SIGNAL_TRANSPORT) == self.TEMP_URL_SIGNAL
|
self.SIGNAL_TRANSPORT] == self.TEMP_URL_SIGNAL
|
||||||
|
|
||||||
def _build_properties(self, properties, config_id, action):
|
def _build_properties(self, properties, config_id, action):
|
||||||
props = {
|
props = {
|
||||||
|
@ -360,7 +360,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
scl.NAME: self.DEPLOY_SERVER_ID,
|
scl.NAME: self.DEPLOY_SERVER_ID,
|
||||||
scl.DESCRIPTION: _('ID of the server being deployed to'),
|
scl.DESCRIPTION: _('ID of the server being deployed to'),
|
||||||
scl.TYPE: 'String',
|
scl.TYPE: 'String',
|
||||||
'value': self.properties.get(self.SERVER)
|
'value': self.properties[self.SERVER]
|
||||||
}, {
|
}, {
|
||||||
scl.NAME: self.DEPLOY_ACTION,
|
scl.NAME: self.DEPLOY_ACTION,
|
||||||
scl.DESCRIPTION: _('Name of the current action being deployed'),
|
scl.DESCRIPTION: _('Name of the current action being deployed'),
|
||||||
|
@ -382,7 +382,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
scl.DESCRIPTION: _('How the server should signal to heat with '
|
scl.DESCRIPTION: _('How the server should signal to heat with '
|
||||||
'the deployment output values.'),
|
'the deployment output values.'),
|
||||||
scl.TYPE: 'String',
|
scl.TYPE: 'String',
|
||||||
'value': self.properties.get(self.SIGNAL_TRANSPORT)
|
'value': self.properties[self.SIGNAL_TRANSPORT]
|
||||||
}])
|
}])
|
||||||
if self._signal_transport_cfn():
|
if self._signal_transport_cfn():
|
||||||
inputs.append({
|
inputs.append({
|
||||||
|
@ -565,7 +565,7 @@ class SoftwareDeployment(signal_responder.SignalResponder):
|
||||||
:raises StackValidationFailed: if any property failed validation.
|
:raises StackValidationFailed: if any property failed validation.
|
||||||
'''
|
'''
|
||||||
super(SoftwareDeployment, self).validate()
|
super(SoftwareDeployment, self).validate()
|
||||||
server = self.properties.get(self.SERVER)
|
server = self.properties[self.SERVER]
|
||||||
if server:
|
if server:
|
||||||
res = self.stack.resource_by_refid(server)
|
res = self.stack.resource_by_refid(server)
|
||||||
if res:
|
if res:
|
||||||
|
|
|
@ -135,8 +135,8 @@ class StructuredDeployment(sd.SoftwareDeployment):
|
||||||
def _build_derived_config(self, action, source,
|
def _build_derived_config(self, action, source,
|
||||||
derived_inputs, derived_options):
|
derived_inputs, derived_options):
|
||||||
cfg = source.get(sc.SoftwareConfig.CONFIG)
|
cfg = source.get(sc.SoftwareConfig.CONFIG)
|
||||||
input_key = self.properties.get(self.INPUT_KEY)
|
input_key = self.properties[self.INPUT_KEY]
|
||||||
check_input_val = self.properties.get(self.INPUT_VALUES_VALIDATE)
|
check_input_val = self.properties[self.INPUT_VALUES_VALIDATE]
|
||||||
|
|
||||||
inputs = dict((i['name'], i['value']) for i in derived_inputs)
|
inputs = dict((i['name'], i['value']) for i in derived_inputs)
|
||||||
|
|
||||||
|
|
|
@ -124,9 +124,9 @@ class FloatingIP(neutron.NeutronResource):
|
||||||
gateway_network = resource.properties.get(
|
gateway_network = resource.properties.get(
|
||||||
router.RouterGateway.NETWORK) or resource.properties.get(
|
router.RouterGateway.NETWORK) or resource.properties.get(
|
||||||
router.RouterGateway.NETWORK_ID)
|
router.RouterGateway.NETWORK_ID)
|
||||||
floating_network = self.properties.get(
|
floating_network = self.properties[
|
||||||
self.FLOATING_NETWORK) or self.properties.get(
|
self.FLOATING_NETWORK] or self.properties[
|
||||||
self.FLOATING_NETWORK_ID)
|
self.FLOATING_NETWORK_ID]
|
||||||
if gateway_network == floating_network:
|
if gateway_network == floating_network:
|
||||||
deps += (self, resource)
|
deps += (self, resource)
|
||||||
|
|
||||||
|
@ -175,9 +175,9 @@ class FloatingIP(neutron.NeutronResource):
|
||||||
if gateway:
|
if gateway:
|
||||||
gateway_network = gateway.get(
|
gateway_network = gateway.get(
|
||||||
router.Router.EXTERNAL_GATEWAY_NETWORK)
|
router.Router.EXTERNAL_GATEWAY_NETWORK)
|
||||||
floating_network = self.properties.get(
|
floating_network = self.properties[
|
||||||
self.FLOATING_NETWORK) or self.properties.get(
|
self.FLOATING_NETWORK] or self.properties[
|
||||||
self.FLOATING_NETWORK_ID)
|
self.FLOATING_NETWORK_ID]
|
||||||
if gateway_network == floating_network:
|
if gateway_network == floating_network:
|
||||||
deps += (self, resource)
|
deps += (self, resource)
|
||||||
|
|
||||||
|
@ -186,8 +186,8 @@ class FloatingIP(neutron.NeutronResource):
|
||||||
self._validate_depr_property_required(
|
self._validate_depr_property_required(
|
||||||
self.properties, self.FLOATING_NETWORK, self.FLOATING_NETWORK_ID)
|
self.properties, self.FLOATING_NETWORK, self.FLOATING_NETWORK_ID)
|
||||||
# fixed_ip_address cannot be specified without a port_id
|
# fixed_ip_address cannot be specified without a port_id
|
||||||
if self.properties.get(self.PORT_ID) is None and self.properties.get(
|
if self.properties[self.PORT_ID] is None and self.properties[
|
||||||
self.FIXED_IP_ADDRESS) is not None:
|
self.FIXED_IP_ADDRESS] is not None:
|
||||||
raise exception.ResourcePropertyDependency(
|
raise exception.ResourcePropertyDependency(
|
||||||
prop1=self.FIXED_IP_ADDRESS, prop2=self.PORT_ID)
|
prop1=self.FIXED_IP_ADDRESS, prop2=self.PORT_ID)
|
||||||
|
|
||||||
|
@ -216,11 +216,11 @@ class FloatingIP(neutron.NeutronResource):
|
||||||
neutron_client = self.neutron()
|
neutron_client = self.neutron()
|
||||||
|
|
||||||
port_id = prop_diff.get(self.PORT_ID,
|
port_id = prop_diff.get(self.PORT_ID,
|
||||||
self.properties.get(self.PORT_ID))
|
self.properties[self.PORT_ID])
|
||||||
|
|
||||||
fixed_ip_address = prop_diff.get(
|
fixed_ip_address = prop_diff.get(
|
||||||
self.FIXED_IP_ADDRESS,
|
self.FIXED_IP_ADDRESS,
|
||||||
self.properties.get(self.FIXED_IP_ADDRESS))
|
self.properties[self.FIXED_IP_ADDRESS])
|
||||||
|
|
||||||
request_body = {
|
request_body = {
|
||||||
'floatingip': {
|
'floatingip': {
|
||||||
|
@ -302,15 +302,15 @@ class FloatingIPAssociation(neutron.NeutronResource):
|
||||||
client = self.neutron()
|
client = self.neutron()
|
||||||
try:
|
try:
|
||||||
client.update_floatingip(
|
client.update_floatingip(
|
||||||
self.properties.get(self.FLOATINGIP_ID),
|
self.properties[self.FLOATINGIP_ID],
|
||||||
{'floatingip': {'port_id': None}})
|
{'floatingip': {'port_id': None}})
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
self.client_plugin().ignore_not_found(ex)
|
self.client_plugin().ignore_not_found(ex)
|
||||||
|
|
||||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||||
if prop_diff:
|
if prop_diff:
|
||||||
floatingip_id = self.properties.get(self.FLOATINGIP_ID)
|
floatingip_id = self.properties[self.FLOATINGIP_ID]
|
||||||
port_id = self.properties.get(self.PORT_ID)
|
port_id = self.properties[self.PORT_ID]
|
||||||
neutron_client = self.neutron()
|
neutron_client = self.neutron()
|
||||||
# if the floatingip_id is changed, disassociate the port which
|
# if the floatingip_id is changed, disassociate the port which
|
||||||
# associated with the old floatingip_id
|
# associated with the old floatingip_id
|
||||||
|
@ -328,7 +328,7 @@ class FloatingIPAssociation(neutron.NeutronResource):
|
||||||
port_id = prop_diff.get(self.PORT_ID) or port_id
|
port_id = prop_diff.get(self.PORT_ID) or port_id
|
||||||
|
|
||||||
fixed_ip_address = (prop_diff.get(self.FIXED_IP_ADDRESS) or
|
fixed_ip_address = (prop_diff.get(self.FIXED_IP_ADDRESS) or
|
||||||
self.properties.get(self.FIXED_IP_ADDRESS))
|
self.properties[self.FIXED_IP_ADDRESS])
|
||||||
|
|
||||||
request_body = {
|
request_body = {
|
||||||
'floatingip': {
|
'floatingip': {
|
||||||
|
|
|
@ -604,7 +604,7 @@ class PoolMember(neutron.NeutronResource):
|
||||||
protocol_port = self.properties[self.PROTOCOL_PORT]
|
protocol_port = self.properties[self.PROTOCOL_PORT]
|
||||||
address = self.properties[self.ADDRESS]
|
address = self.properties[self.ADDRESS]
|
||||||
admin_state_up = self.properties[self.ADMIN_STATE_UP]
|
admin_state_up = self.properties[self.ADMIN_STATE_UP]
|
||||||
weight = self.properties.get(self.WEIGHT)
|
weight = self.properties[self.WEIGHT]
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
'pool_id': pool,
|
'pool_id': pool,
|
||||||
|
|
|
@ -267,8 +267,8 @@ class Port(neutron.NeutronResource):
|
||||||
dep_network = res.properties.get(
|
dep_network = res.properties.get(
|
||||||
subnet.Subnet.NETWORK) or res.properties.get(
|
subnet.Subnet.NETWORK) or res.properties.get(
|
||||||
subnet.Subnet.NETWORK_ID)
|
subnet.Subnet.NETWORK_ID)
|
||||||
network = self.properties.get(
|
network = self.properties[
|
||||||
self.NETWORK) or self.properties.get(self.NETWORK_ID)
|
self.NETWORK] or self.properties[self.NETWORK_ID]
|
||||||
if dep_network == network:
|
if dep_network == network:
|
||||||
deps += (self, res)
|
deps += (self, res)
|
||||||
|
|
||||||
|
|
|
@ -93,8 +93,8 @@ class ProviderNet(net.Net):
|
||||||
'''
|
'''
|
||||||
super(ProviderNet, self).validate()
|
super(ProviderNet, self).validate()
|
||||||
|
|
||||||
if (self.properties.get(self.PROVIDER_SEGMENTATION_ID) and
|
if (self.properties[self.PROVIDER_SEGMENTATION_ID] and
|
||||||
self.properties.get(self.PROVIDER_NETWORK_TYPE) != 'vlan'):
|
self.properties[self.PROVIDER_NETWORK_TYPE] != 'vlan'):
|
||||||
msg = _('segmentation_id not allowed for flat network type.')
|
msg = _('segmentation_id not allowed for flat network type.')
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
||||||
|
|
|
@ -149,10 +149,10 @@ class Router(neutron.NeutronResource):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(Router, self).validate()
|
super(Router, self).validate()
|
||||||
is_distributed = self.properties.get(self.DISTRIBUTED)
|
is_distributed = self.properties[self.DISTRIBUTED]
|
||||||
l3_agent_id = self.properties.get(self.L3_AGENT_ID)
|
l3_agent_id = self.properties[self.L3_AGENT_ID]
|
||||||
l3_agent_ids = self.properties.get(self.L3_AGENT_IDS)
|
l3_agent_ids = self.properties[self.L3_AGENT_IDS]
|
||||||
is_ha = self.properties.get(self.HA)
|
is_ha = self.properties[self.HA]
|
||||||
if l3_agent_id and l3_agent_ids:
|
if l3_agent_id and l3_agent_ids:
|
||||||
raise exception.ResourcePropertyConflict(self.L3_AGENT_ID,
|
raise exception.ResourcePropertyConflict(self.L3_AGENT_ID,
|
||||||
self.L3_AGENT_IDS)
|
self.L3_AGENT_IDS)
|
||||||
|
@ -170,7 +170,7 @@ class Router(neutron.NeutronResource):
|
||||||
|
|
||||||
def add_dependencies(self, deps):
|
def add_dependencies(self, deps):
|
||||||
super(Router, self).add_dependencies(deps)
|
super(Router, self).add_dependencies(deps)
|
||||||
external_gw = self.properties.get(self.EXTERNAL_GATEWAY)
|
external_gw = self.properties[self.EXTERNAL_GATEWAY]
|
||||||
if external_gw:
|
if external_gw:
|
||||||
external_gw_net = external_gw.get(self.EXTERNAL_GATEWAY_NETWORK)
|
external_gw_net = external_gw.get(self.EXTERNAL_GATEWAY_NETWORK)
|
||||||
for res in six.itervalues(self.stack):
|
for res in six.itervalues(self.stack):
|
||||||
|
@ -442,7 +442,7 @@ class RouterGateway(neutron.NeutronResource):
|
||||||
if resource.has_interface('OS::Neutron::RouterInterface'):
|
if resource.has_interface('OS::Neutron::RouterInterface'):
|
||||||
dep_router_id = resource.properties.get(
|
dep_router_id = resource.properties.get(
|
||||||
RouterInterface.ROUTER_ID)
|
RouterInterface.ROUTER_ID)
|
||||||
router_id = self.properties.get(self.ROUTER_ID)
|
router_id = self.properties[self.ROUTER_ID]
|
||||||
if dep_router_id == router_id:
|
if dep_router_id == router_id:
|
||||||
deps += (self, resource)
|
deps += (self, resource)
|
||||||
# depend on any subnet in this template with the same network_id
|
# depend on any subnet in this template with the same network_id
|
||||||
|
@ -452,13 +452,13 @@ class RouterGateway(neutron.NeutronResource):
|
||||||
dep_network = resource.properties.get(
|
dep_network = resource.properties.get(
|
||||||
subnet.Subnet.NETWORK) or resource.properties.get(
|
subnet.Subnet.NETWORK) or resource.properties.get(
|
||||||
subnet.Subnet.NETWORK_ID)
|
subnet.Subnet.NETWORK_ID)
|
||||||
network = self.properties.get(
|
network = self.properties[
|
||||||
self.NETWORK) or self.properties.get(self.NETWORK_ID)
|
self.NETWORK] or self.properties[self.NETWORK_ID]
|
||||||
if dep_network == network:
|
if dep_network == network:
|
||||||
deps += (self, resource)
|
deps += (self, resource)
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
router_id = self.properties.get(self.ROUTER_ID)
|
router_id = self.properties[self.ROUTER_ID]
|
||||||
network_id = self.client_plugin().resolve_network(
|
network_id = self.client_plugin().resolve_network(
|
||||||
dict(self.properties), self.NETWORK, 'network_id')
|
dict(self.properties), self.NETWORK, 'network_id')
|
||||||
self.neutron().add_gateway_router(
|
self.neutron().add_gateway_router(
|
||||||
|
|
|
@ -134,7 +134,7 @@ class SecurityGroup(neutron.NeutronResource):
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(SecurityGroup, self).validate()
|
super(SecurityGroup, self).validate()
|
||||||
if self.properties.get(self.NAME) == 'default':
|
if self.properties[self.NAME] == 'default':
|
||||||
msg = _('Security groups cannot be assigned the name "default".')
|
msg = _('Security groups cannot be assigned the name "default".')
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
||||||
|
|
|
@ -235,9 +235,9 @@ class Subnet(neutron.NeutronResource):
|
||||||
super(Subnet, self).validate()
|
super(Subnet, self).validate()
|
||||||
self._validate_depr_property_required(self.properties,
|
self._validate_depr_property_required(self.properties,
|
||||||
self.NETWORK, self.NETWORK_ID)
|
self.NETWORK, self.NETWORK_ID)
|
||||||
ra_mode = self.properties.get(self.IPV6_RA_MODE)
|
ra_mode = self.properties[self.IPV6_RA_MODE]
|
||||||
address_mode = self.properties.get(self.IPV6_ADDRESS_MODE)
|
address_mode = self.properties[self.IPV6_ADDRESS_MODE]
|
||||||
if (self.properties.get(self.IP_VERSION) == 4) and (
|
if (self.properties[self.IP_VERSION] == 4) and (
|
||||||
ra_mode or address_mode):
|
ra_mode or address_mode):
|
||||||
msg = _('ipv6_ra_mode and ipv6_address_mode are not supported '
|
msg = _('ipv6_ra_mode and ipv6_address_mode are not supported '
|
||||||
'for ipv4.')
|
'for ipv4.')
|
||||||
|
|
|
@ -68,7 +68,7 @@ class NovaFloatingIp(resource.Resource):
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
try:
|
try:
|
||||||
pool = self.properties.get(self.POOL)
|
pool = self.properties[self.POOL]
|
||||||
floating_ip = self.nova().floating_ips.create(pool=pool)
|
floating_ip = self.nova().floating_ips.create(pool=pool)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
|
|
|
@ -64,7 +64,7 @@ class ServerGroup(resource.Resource):
|
||||||
self.client_plugin('nova').ignore_not_found(e)
|
self.client_plugin('nova').ignore_not_found(e)
|
||||||
|
|
||||||
def physical_resource_name(self):
|
def physical_resource_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
return super(ServerGroup, self).physical_resource_name()
|
return super(ServerGroup, self).physical_resource_name()
|
||||||
|
|
|
@ -499,7 +499,7 @@ class Server(stack_user.StackUser):
|
||||||
self._register_access_key()
|
self._register_access_key()
|
||||||
|
|
||||||
def _server_name(self):
|
def _server_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -507,7 +507,7 @@ class Server(stack_user.StackUser):
|
||||||
|
|
||||||
def _config_drive(self):
|
def _config_drive(self):
|
||||||
# This method is overridden by the derived CloudServer resource
|
# This method is overridden by the derived CloudServer resource
|
||||||
return self.properties.get(self.CONFIG_DRIVE)
|
return self.properties[self.CONFIG_DRIVE]
|
||||||
|
|
||||||
def _populate_deployments_metadata(self, meta):
|
def _populate_deployments_metadata(self, meta):
|
||||||
meta['deployments'] = meta.get('deployments', [])
|
meta['deployments'] = meta.get('deployments', [])
|
||||||
|
@ -593,23 +593,23 @@ class Server(stack_user.StackUser):
|
||||||
self.data_set('password', password, True)
|
self.data_set('password', password, True)
|
||||||
|
|
||||||
def user_data_raw(self):
|
def user_data_raw(self):
|
||||||
return self.properties.get(self.USER_DATA_FORMAT) == self.RAW
|
return self.properties[self.USER_DATA_FORMAT] == self.RAW
|
||||||
|
|
||||||
def user_data_software_config(self):
|
def user_data_software_config(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.USER_DATA_FORMAT) == self.SOFTWARE_CONFIG
|
self.USER_DATA_FORMAT] == self.SOFTWARE_CONFIG
|
||||||
|
|
||||||
def transport_poll_server_cfn(self):
|
def transport_poll_server_cfn(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SOFTWARE_CONFIG_TRANSPORT) == self.POLL_SERVER_CFN
|
self.SOFTWARE_CONFIG_TRANSPORT] == self.POLL_SERVER_CFN
|
||||||
|
|
||||||
def transport_poll_server_heat(self):
|
def transport_poll_server_heat(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SOFTWARE_CONFIG_TRANSPORT) == self.POLL_SERVER_HEAT
|
self.SOFTWARE_CONFIG_TRANSPORT] == self.POLL_SERVER_HEAT
|
||||||
|
|
||||||
def transport_poll_temp_url(self):
|
def transport_poll_temp_url(self):
|
||||||
return self.properties.get(
|
return self.properties[
|
||||||
self.SOFTWARE_CONFIG_TRANSPORT) == self.POLL_TEMP_URL
|
self.SOFTWARE_CONFIG_TRANSPORT] == self.POLL_TEMP_URL
|
||||||
|
|
||||||
def get_software_config(self, ud_content):
|
def get_software_config(self, ud_content):
|
||||||
try:
|
try:
|
||||||
|
@ -621,10 +621,10 @@ class Server(stack_user.StackUser):
|
||||||
return ud_content
|
return ud_content
|
||||||
|
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
security_groups = self.properties.get(self.SECURITY_GROUPS)
|
security_groups = self.properties[self.SECURITY_GROUPS]
|
||||||
|
|
||||||
user_data_format = self.properties.get(self.USER_DATA_FORMAT)
|
user_data_format = self.properties[self.USER_DATA_FORMAT]
|
||||||
ud_content = self.properties.get(self.USER_DATA)
|
ud_content = self.properties[self.USER_DATA]
|
||||||
if self.user_data_software_config() or self.user_data_raw():
|
if self.user_data_software_config() or self.user_data_raw():
|
||||||
if uuidutils.is_uuid_like(ud_content):
|
if uuidutils.is_uuid_like(ud_content):
|
||||||
# attempt to load the userdata from software config
|
# attempt to load the userdata from software config
|
||||||
|
@ -652,18 +652,18 @@ class Server(stack_user.StackUser):
|
||||||
flavor = self.properties[self.FLAVOR]
|
flavor = self.properties[self.FLAVOR]
|
||||||
availability_zone = self.properties[self.AVAILABILITY_ZONE]
|
availability_zone = self.properties[self.AVAILABILITY_ZONE]
|
||||||
|
|
||||||
image = self.properties.get(self.IMAGE)
|
image = self.properties[self.IMAGE]
|
||||||
if image:
|
if image:
|
||||||
image = self.client_plugin('glance').get_image_id(image)
|
image = self.client_plugin('glance').get_image_id(image)
|
||||||
|
|
||||||
flavor_id = self.client_plugin().get_flavor_id(flavor)
|
flavor_id = self.client_plugin().get_flavor_id(flavor)
|
||||||
|
|
||||||
instance_meta = self.properties.get(self.METADATA)
|
instance_meta = self.properties[self.METADATA]
|
||||||
if instance_meta is not None:
|
if instance_meta is not None:
|
||||||
instance_meta = self.client_plugin().meta_serialize(
|
instance_meta = self.client_plugin().meta_serialize(
|
||||||
instance_meta)
|
instance_meta)
|
||||||
|
|
||||||
scheduler_hints = self.properties.get(self.SCHEDULER_HINTS)
|
scheduler_hints = self.properties[self.SCHEDULER_HINTS]
|
||||||
if cfg.CONF.stack_scheduler_hints:
|
if cfg.CONF.stack_scheduler_hints:
|
||||||
if scheduler_hints is None:
|
if scheduler_hints is None:
|
||||||
scheduler_hints = {}
|
scheduler_hints = {}
|
||||||
|
@ -672,16 +672,16 @@ class Server(stack_user.StackUser):
|
||||||
scheduler_hints['heat_stack_name'] = self.stack.name
|
scheduler_hints['heat_stack_name'] = self.stack.name
|
||||||
scheduler_hints['heat_path_in_stack'] = self.stack.path_in_stack()
|
scheduler_hints['heat_path_in_stack'] = self.stack.path_in_stack()
|
||||||
scheduler_hints['heat_resource_name'] = self.name
|
scheduler_hints['heat_resource_name'] = self.name
|
||||||
nics = self._build_nics(self.properties.get(self.NETWORKS))
|
nics = self._build_nics(self.properties[self.NETWORKS])
|
||||||
block_device_mapping = self._build_block_device_mapping(
|
block_device_mapping = self._build_block_device_mapping(
|
||||||
self.properties.get(self.BLOCK_DEVICE_MAPPING))
|
self.properties[self.BLOCK_DEVICE_MAPPING])
|
||||||
block_device_mapping_v2 = self._build_block_device_mapping_v2(
|
block_device_mapping_v2 = self._build_block_device_mapping_v2(
|
||||||
self.properties.get(self.BLOCK_DEVICE_MAPPING_V2))
|
self.properties[self.BLOCK_DEVICE_MAPPING_V2])
|
||||||
reservation_id = self.properties.get(self.RESERVATION_ID)
|
reservation_id = self.properties[self.RESERVATION_ID]
|
||||||
disk_config = self.properties.get(self.DISK_CONFIG)
|
disk_config = self.properties[self.DISK_CONFIG]
|
||||||
admin_pass = self.properties.get(self.ADMIN_PASS) or None
|
admin_pass = self.properties[self.ADMIN_PASS] or None
|
||||||
personality_files = self.properties.get(self.PERSONALITY)
|
personality_files = self.properties[self.PERSONALITY]
|
||||||
key_name = self.properties.get(self.KEY_NAME)
|
key_name = self.properties[self.KEY_NAME]
|
||||||
|
|
||||||
server = None
|
server = None
|
||||||
try:
|
try:
|
||||||
|
@ -912,7 +912,7 @@ class Server(stack_user.StackUser):
|
||||||
# It is not known which subnet a server might be assigned
|
# It is not known which subnet a server might be assigned
|
||||||
# to so all subnets in a network should be created before
|
# to so all subnets in a network should be created before
|
||||||
# the servers in that network.
|
# the servers in that network.
|
||||||
nets = self.properties.get(self.NETWORKS)
|
nets = self.properties[self.NETWORKS]
|
||||||
if not nets:
|
if not nets:
|
||||||
return
|
return
|
||||||
for res in six.itervalues(self.stack):
|
for res in six.itervalues(self.stack):
|
||||||
|
@ -1002,7 +1002,7 @@ class Server(stack_user.StackUser):
|
||||||
def _update_flavor(self, server, prop_diff):
|
def _update_flavor(self, server, prop_diff):
|
||||||
flavor_update_policy = (
|
flavor_update_policy = (
|
||||||
prop_diff.get(self.FLAVOR_UPDATE_POLICY) or
|
prop_diff.get(self.FLAVOR_UPDATE_POLICY) or
|
||||||
self.properties.get(self.FLAVOR_UPDATE_POLICY))
|
self.properties[self.FLAVOR_UPDATE_POLICY])
|
||||||
flavor = prop_diff[self.FLAVOR]
|
flavor = prop_diff[self.FLAVOR]
|
||||||
|
|
||||||
if flavor_update_policy == 'REPLACE':
|
if flavor_update_policy == 'REPLACE':
|
||||||
|
@ -1017,7 +1017,7 @@ class Server(stack_user.StackUser):
|
||||||
def _update_image(self, server, prop_diff):
|
def _update_image(self, server, prop_diff):
|
||||||
image_update_policy = (
|
image_update_policy = (
|
||||||
prop_diff.get(self.IMAGE_UPDATE_POLICY) or
|
prop_diff.get(self.IMAGE_UPDATE_POLICY) or
|
||||||
self.properties.get(self.IMAGE_UPDATE_POLICY))
|
self.properties[self.IMAGE_UPDATE_POLICY])
|
||||||
if image_update_policy == 'REPLACE':
|
if image_update_policy == 'REPLACE':
|
||||||
raise resource.UpdateReplace(self.name)
|
raise resource.UpdateReplace(self.name)
|
||||||
image = prop_diff[self.IMAGE]
|
image = prop_diff[self.IMAGE]
|
||||||
|
@ -1027,7 +1027,7 @@ class Server(stack_user.StackUser):
|
||||||
preserve_ephemeral = (
|
preserve_ephemeral = (
|
||||||
image_update_policy == 'REBUILD_PRESERVE_EPHEMERAL')
|
image_update_policy == 'REBUILD_PRESERVE_EPHEMERAL')
|
||||||
password = (prop_diff.get(self.ADMIN_PASS) or
|
password = (prop_diff.get(self.ADMIN_PASS) or
|
||||||
self.properties.get(self.ADMIN_PASS))
|
self.properties[self.ADMIN_PASS])
|
||||||
return scheduler.TaskRunner(
|
return scheduler.TaskRunner(
|
||||||
self.client_plugin().rebuild, server, image_id,
|
self.client_plugin().rebuild, server, image_id,
|
||||||
password=password,
|
password=password,
|
||||||
|
@ -1040,7 +1040,7 @@ class Server(stack_user.StackUser):
|
||||||
if not new_networks:
|
if not new_networks:
|
||||||
new_networks = []
|
new_networks = []
|
||||||
attach_first_free_port = True
|
attach_first_free_port = True
|
||||||
old_networks = self.properties.get(self.NETWORKS)
|
old_networks = self.properties[self.NETWORKS]
|
||||||
|
|
||||||
if not server:
|
if not server:
|
||||||
server = self.nova().servers.get(self.resource_id)
|
server = self.nova().servers.get(self.resource_id)
|
||||||
|
@ -1180,7 +1180,7 @@ class Server(stack_user.StackUser):
|
||||||
|
|
||||||
# either volume_id or snapshot_id needs to be specified, but not both
|
# either volume_id or snapshot_id needs to be specified, but not both
|
||||||
# for block device mapping.
|
# for block device mapping.
|
||||||
bdm = self.properties.get(self.BLOCK_DEVICE_MAPPING) or []
|
bdm = self.properties[self.BLOCK_DEVICE_MAPPING] or []
|
||||||
bootable_vol = False
|
bootable_vol = False
|
||||||
for mapping in bdm:
|
for mapping in bdm:
|
||||||
device_name = mapping[self.BLOCK_DEVICE_MAPPING_DEVICE_NAME]
|
device_name = mapping[self.BLOCK_DEVICE_MAPPING_DEVICE_NAME]
|
||||||
|
@ -1198,7 +1198,7 @@ class Server(stack_user.StackUser):
|
||||||
' device mapping %s') % device_name
|
' device mapping %s') % device_name
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
||||||
bdm_v2 = self.properties.get(self.BLOCK_DEVICE_MAPPING_V2) or []
|
bdm_v2 = self.properties[self.BLOCK_DEVICE_MAPPING_V2] or []
|
||||||
if bdm and bdm_v2:
|
if bdm and bdm_v2:
|
||||||
raise exception.ResourcePropertyConflict(
|
raise exception.ResourcePropertyConflict(
|
||||||
self.BLOCK_DEVICE_MAPPING, self.BLOCK_DEVICE_MAPPING_V2)
|
self.BLOCK_DEVICE_MAPPING, self.BLOCK_DEVICE_MAPPING_V2)
|
||||||
|
@ -1237,7 +1237,7 @@ class Server(stack_user.StackUser):
|
||||||
bootable_vol = self._validate_block_device_mapping()
|
bootable_vol = self._validate_block_device_mapping()
|
||||||
|
|
||||||
# make sure the image exists if specified.
|
# make sure the image exists if specified.
|
||||||
image = self.properties.get(self.IMAGE)
|
image = self.properties[self.IMAGE]
|
||||||
if not image and not bootable_vol:
|
if not image and not bootable_vol:
|
||||||
msg = _('Neither image nor bootable volume is specified for'
|
msg = _('Neither image nor bootable volume is specified for'
|
||||||
' instance %s') % self.name
|
' instance %s') % self.name
|
||||||
|
@ -1245,7 +1245,7 @@ class Server(stack_user.StackUser):
|
||||||
|
|
||||||
# network properties 'uuid' and 'network' shouldn't be used
|
# network properties 'uuid' and 'network' shouldn't be used
|
||||||
# both at once for all networks
|
# both at once for all networks
|
||||||
networks = self.properties.get(self.NETWORKS) or []
|
networks = self.properties[self.NETWORKS] or []
|
||||||
# record if any networks include explicit ports
|
# record if any networks include explicit ports
|
||||||
networks_with_port = False
|
networks_with_port = False
|
||||||
for network in networks:
|
for network in networks:
|
||||||
|
@ -1284,14 +1284,14 @@ class Server(stack_user.StackUser):
|
||||||
server=self.name))
|
server=self.name))
|
||||||
|
|
||||||
# retrieve provider's absolute limits if it will be needed
|
# retrieve provider's absolute limits if it will be needed
|
||||||
metadata = self.properties.get(self.METADATA)
|
metadata = self.properties[self.METADATA]
|
||||||
personality = self.properties.get(self.PERSONALITY)
|
personality = self.properties[self.PERSONALITY]
|
||||||
if metadata is not None or personality:
|
if metadata is not None or personality:
|
||||||
limits = self.client_plugin().absolute_limits()
|
limits = self.client_plugin().absolute_limits()
|
||||||
|
|
||||||
# if 'security_groups' present for the server and explict 'port'
|
# if 'security_groups' present for the server and explict 'port'
|
||||||
# in one or more entries in 'networks', raise validation error
|
# in one or more entries in 'networks', raise validation error
|
||||||
if networks_with_port and self.properties.get(self.SECURITY_GROUPS):
|
if networks_with_port and self.properties[self.SECURITY_GROUPS]:
|
||||||
raise exception.ResourcePropertyConflict(
|
raise exception.ResourcePropertyConflict(
|
||||||
self.SECURITY_GROUPS,
|
self.SECURITY_GROUPS,
|
||||||
"/".join([self.NETWORKS, self.NETWORK_PORT]))
|
"/".join([self.NETWORKS, self.NETWORK_PORT]))
|
||||||
|
|
|
@ -122,7 +122,7 @@ class SaharaCluster(resource.Resource):
|
||||||
raise exception.ResourcePropertyConflict(value, depr_value)
|
raise exception.ResourcePropertyConflict(value, depr_value)
|
||||||
|
|
||||||
def _cluster_name(self):
|
def _cluster_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
return self.physical_resource_name()
|
return self.physical_resource_name()
|
||||||
|
@ -146,8 +146,8 @@ class SaharaCluster(resource.Resource):
|
||||||
'img': self.IMAGE, 'tmpl': cluster_template_id}
|
'img': self.IMAGE, 'tmpl': cluster_template_id}
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
||||||
key_name = self.properties.get(self.KEY_NAME)
|
key_name = self.properties[self.KEY_NAME]
|
||||||
net_id = self.properties.get(self.MANAGEMENT_NETWORK)
|
net_id = self.properties[self.MANAGEMENT_NETWORK]
|
||||||
if net_id:
|
if net_id:
|
||||||
if self.is_using_neutron():
|
if self.is_using_neutron():
|
||||||
net_id = self.client_plugin('neutron').find_neutron_resource(
|
net_id = self.client_plugin('neutron').find_neutron_resource(
|
||||||
|
@ -220,7 +220,7 @@ class SaharaCluster(resource.Resource):
|
||||||
self._validate_depr_keys(self.properties, self.IMAGE_ID, self.IMAGE)
|
self._validate_depr_keys(self.properties, self.IMAGE_ID, self.IMAGE)
|
||||||
# check if running on neutron and MANAGEMENT_NETWORK missing
|
# check if running on neutron and MANAGEMENT_NETWORK missing
|
||||||
if (self.is_using_neutron() and
|
if (self.is_using_neutron() and
|
||||||
not self.properties.get(self.MANAGEMENT_NETWORK)):
|
not self.properties[self.MANAGEMENT_NETWORK]):
|
||||||
msg = _("%s must be provided"
|
msg = _("%s must be provided"
|
||||||
) % self.MANAGEMENT_NETWORK
|
) % self.MANAGEMENT_NETWORK
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
|
@ -160,7 +160,7 @@ class SaharaNodeGroupTemplate(resource.Resource):
|
||||||
physical_resource_name_limit = 50
|
physical_resource_name_limit = 50
|
||||||
|
|
||||||
def _ngt_name(self):
|
def _ngt_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
return self.physical_resource_name()
|
return self.physical_resource_name()
|
||||||
|
@ -172,10 +172,10 @@ class SaharaNodeGroupTemplate(resource.Resource):
|
||||||
description = self.properties[self.DESCRIPTION]
|
description = self.properties[self.DESCRIPTION]
|
||||||
flavor_id = self.client_plugin("nova").get_flavor_id(
|
flavor_id = self.client_plugin("nova").get_flavor_id(
|
||||||
self.properties[self.FLAVOR])
|
self.properties[self.FLAVOR])
|
||||||
volumes_per_node = self.properties.get(self.VOLUMES_PER_NODE)
|
volumes_per_node = self.properties[self.VOLUMES_PER_NODE]
|
||||||
volumes_size = self.properties.get(self.VOLUMES_SIZE)
|
volumes_size = self.properties[self.VOLUMES_SIZE]
|
||||||
volume_type = self.properties.get(self.VOLUME_TYPE)
|
volume_type = self.properties[self.VOLUME_TYPE]
|
||||||
floating_ip_pool = self.properties.get(self.FLOATING_IP_POOL)
|
floating_ip_pool = self.properties[self.FLOATING_IP_POOL]
|
||||||
security_groups = self.properties[self.SECURITY_GROUPS]
|
security_groups = self.properties[self.SECURITY_GROUPS]
|
||||||
auto_security_group = self.properties[self.AUTO_SECURITY_GROUP]
|
auto_security_group = self.properties[self.AUTO_SECURITY_GROUP]
|
||||||
availability_zone = self.properties[self.AVAILABILITY_ZONE]
|
availability_zone = self.properties[self.AVAILABILITY_ZONE]
|
||||||
|
@ -185,7 +185,7 @@ class SaharaNodeGroupTemplate(resource.Resource):
|
||||||
floating_ip_pool = self.client_plugin(
|
floating_ip_pool = self.client_plugin(
|
||||||
'neutron').find_neutron_resource(
|
'neutron').find_neutron_resource(
|
||||||
self.properties, self.FLOATING_IP_POOL, 'network')
|
self.properties, self.FLOATING_IP_POOL, 'network')
|
||||||
node_configs = self.properties.get(self.NODE_CONFIGS)
|
node_configs = self.properties[self.NODE_CONFIGS]
|
||||||
|
|
||||||
node_group_template = self.client().node_group_templates.create(
|
node_group_template = self.client().node_group_templates.create(
|
||||||
self._ngt_name(),
|
self._ngt_name(),
|
||||||
|
@ -349,7 +349,7 @@ class SaharaClusterTemplate(resource.Resource):
|
||||||
physical_resource_name_limit = 50
|
physical_resource_name_limit = 50
|
||||||
|
|
||||||
def _cluster_template_name(self):
|
def _cluster_template_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
return self.physical_resource_name()
|
return self.physical_resource_name()
|
||||||
|
@ -357,9 +357,9 @@ class SaharaClusterTemplate(resource.Resource):
|
||||||
def handle_create(self):
|
def handle_create(self):
|
||||||
plugin_name = self.properties[self.PLUGIN_NAME]
|
plugin_name = self.properties[self.PLUGIN_NAME]
|
||||||
hadoop_version = self.properties[self.HADOOP_VERSION]
|
hadoop_version = self.properties[self.HADOOP_VERSION]
|
||||||
description = self.properties.get(self.DESCRIPTION)
|
description = self.properties[self.DESCRIPTION]
|
||||||
image_id = self.properties.get(self.IMAGE_ID)
|
image_id = self.properties[self.IMAGE_ID]
|
||||||
net_id = self.properties.get(self.MANAGEMENT_NETWORK)
|
net_id = self.properties[self.MANAGEMENT_NETWORK]
|
||||||
if net_id:
|
if net_id:
|
||||||
if self.is_using_neutron():
|
if self.is_using_neutron():
|
||||||
net_id = self.client_plugin('neutron').find_neutron_resource(
|
net_id = self.client_plugin('neutron').find_neutron_resource(
|
||||||
|
@ -367,9 +367,9 @@ class SaharaClusterTemplate(resource.Resource):
|
||||||
else:
|
else:
|
||||||
net_id = self.client_plugin('nova').get_nova_network_id(
|
net_id = self.client_plugin('nova').get_nova_network_id(
|
||||||
net_id)
|
net_id)
|
||||||
anti_affinity = self.properties.get(self.ANTI_AFFINITY)
|
anti_affinity = self.properties[self.ANTI_AFFINITY]
|
||||||
cluster_configs = self.properties.get(self.CLUSTER_CONFIGS)
|
cluster_configs = self.properties[self.CLUSTER_CONFIGS]
|
||||||
node_groups = self.properties.get(self.NODE_GROUPS)
|
node_groups = self.properties[self.NODE_GROUPS]
|
||||||
cluster_template = self.client().cluster_templates.create(
|
cluster_template = self.client().cluster_templates.create(
|
||||||
self._cluster_template_name(),
|
self._cluster_template_name(),
|
||||||
plugin_name, hadoop_version,
|
plugin_name, hadoop_version,
|
||||||
|
@ -402,7 +402,7 @@ class SaharaClusterTemplate(resource.Resource):
|
||||||
return res
|
return res
|
||||||
# check if running on neutron and MANAGEMENT_NETWORK missing
|
# check if running on neutron and MANAGEMENT_NETWORK missing
|
||||||
if (self.is_using_neutron() and
|
if (self.is_using_neutron() and
|
||||||
not self.properties.get(self.MANAGEMENT_NETWORK)):
|
not self.properties[self.MANAGEMENT_NETWORK]):
|
||||||
msg = _("%s must be provided"
|
msg = _("%s must be provided"
|
||||||
) % self.MANAGEMENT_NETWORK
|
) % self.MANAGEMENT_NETWORK
|
||||||
raise exception.StackValidationFailed(message=msg)
|
raise exception.StackValidationFailed(message=msg)
|
||||||
|
|
|
@ -109,7 +109,7 @@ class SwiftContainer(resource.Resource):
|
||||||
default_client_name = 'swift'
|
default_client_name = 'swift'
|
||||||
|
|
||||||
def physical_resource_name(self):
|
def physical_resource_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class SwiftContainer(resource.Resource):
|
||||||
"account", self.properties[self.X_ACCOUNT_META])
|
"account", self.properties[self.X_ACCOUNT_META])
|
||||||
|
|
||||||
for key in (self.X_CONTAINER_READ, self.X_CONTAINER_WRITE):
|
for key in (self.X_CONTAINER_READ, self.X_CONTAINER_WRITE):
|
||||||
if self.properties.get(key) is not None:
|
if self.properties[key] is not None:
|
||||||
container_headers[key] = self.properties[key]
|
container_headers[key] = self.properties[key]
|
||||||
|
|
||||||
LOG.debug('SwiftContainer create container %(container)s with '
|
LOG.debug('SwiftContainer create container %(container)s with '
|
||||||
|
|
|
@ -273,7 +273,7 @@ class OSDBInstance(resource.Resource):
|
||||||
return self._dbinstance
|
return self._dbinstance
|
||||||
|
|
||||||
def _dbinstance_name(self):
|
def _dbinstance_name(self):
|
||||||
name = self.properties.get(self.NAME)
|
name = self.properties[self.NAME]
|
||||||
if name:
|
if name:
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -286,14 +286,14 @@ class OSDBInstance(resource.Resource):
|
||||||
self.flavor = self.client_plugin().get_flavor_id(
|
self.flavor = self.client_plugin().get_flavor_id(
|
||||||
self.properties[self.FLAVOR])
|
self.properties[self.FLAVOR])
|
||||||
self.volume = {'size': self.properties[self.SIZE]}
|
self.volume = {'size': self.properties[self.SIZE]}
|
||||||
self.databases = self.properties.get(self.DATABASES)
|
self.databases = self.properties[self.DATABASES]
|
||||||
self.users = self.properties.get(self.USERS)
|
self.users = self.properties[self.USERS]
|
||||||
restore_point = self.properties.get(self.RESTORE_POINT)
|
restore_point = self.properties[self.RESTORE_POINT]
|
||||||
if restore_point:
|
if restore_point:
|
||||||
restore_point = {"backupRef": restore_point}
|
restore_point = {"backupRef": restore_point}
|
||||||
zone = self.properties.get(self.AVAILABILITY_ZONE)
|
zone = self.properties[self.AVAILABILITY_ZONE]
|
||||||
self.datastore_type = self.properties.get(self.DATASTORE_TYPE)
|
self.datastore_type = self.properties[self.DATASTORE_TYPE]
|
||||||
self.datastore_version = self.properties.get(self.DATASTORE_VERSION)
|
self.datastore_version = self.properties[self.DATASTORE_VERSION]
|
||||||
|
|
||||||
# convert user databases to format required for troveclient.
|
# convert user databases to format required for troveclient.
|
||||||
# that is, list of database dictionaries
|
# that is, list of database dictionaries
|
||||||
|
@ -303,7 +303,7 @@ class OSDBInstance(resource.Resource):
|
||||||
|
|
||||||
# convert networks to format required by troveclient
|
# convert networks to format required by troveclient
|
||||||
nics = []
|
nics = []
|
||||||
for nic in self.properties.get(self.NICS):
|
for nic in self.properties[self.NICS]:
|
||||||
nic_dict = {}
|
nic_dict = {}
|
||||||
net = nic.get(self.NET)
|
net = nic.get(self.NET)
|
||||||
if net:
|
if net:
|
||||||
|
@ -430,17 +430,17 @@ class OSDBInstance(resource.Resource):
|
||||||
if res:
|
if res:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
datastore_type = self.properties.get(self.DATASTORE_TYPE)
|
datastore_type = self.properties[self.DATASTORE_TYPE]
|
||||||
datastore_version = self.properties.get(self.DATASTORE_VERSION)
|
datastore_version = self.properties[self.DATASTORE_VERSION]
|
||||||
|
|
||||||
self.client_plugin().validate_datastore(
|
self.client_plugin().validate_datastore(
|
||||||
datastore_type, datastore_version,
|
datastore_type, datastore_version,
|
||||||
self.DATASTORE_TYPE, self.DATASTORE_VERSION)
|
self.DATASTORE_TYPE, self.DATASTORE_VERSION)
|
||||||
|
|
||||||
# check validity of user and databases
|
# check validity of user and databases
|
||||||
users = self.properties.get(self.USERS)
|
users = self.properties[self.USERS]
|
||||||
if users:
|
if users:
|
||||||
databases = self.properties.get(self.DATABASES)
|
databases = self.properties[self.DATABASES]
|
||||||
if not databases:
|
if not databases:
|
||||||
msg = _('Databases property is required if users property '
|
msg = _('Databases property is required if users property '
|
||||||
'is provided for resource %s.') % self.name
|
'is provided for resource %s.') % self.name
|
||||||
|
@ -459,7 +459,7 @@ class OSDBInstance(resource.Resource):
|
||||||
|
|
||||||
# check validity of NICS
|
# check validity of NICS
|
||||||
is_neutron = self.is_using_neutron()
|
is_neutron = self.is_using_neutron()
|
||||||
nics = self.properties.get(self.NICS)
|
nics = self.properties[self.NICS]
|
||||||
for nic in nics:
|
for nic in nics:
|
||||||
if not is_neutron and nic.get(self.PORT):
|
if not is_neutron and nic.get(self.PORT):
|
||||||
msg = _("Can not use %s property on Nova-network.") % self.PORT
|
msg = _("Can not use %s property on Nova-network.") % self.PORT
|
||||||
|
|
Loading…
Reference in New Issue