Merge "Get rid of undesirable properties.data usage"
This commit is contained in:
commit
a8ace9daa4
@ -113,6 +113,14 @@ manipulate when including that resource in a template. Some examples would be:
|
|||||||
* The port to listen to on Neutron LBaaS nodes
|
* The port to listen to on Neutron LBaaS nodes
|
||||||
* The size of a Cinder volume
|
* The size of a Cinder volume
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
Properties should normally be accessed through self.properties.
|
||||||
|
This resolves intrinsic functions, provides default values when required
|
||||||
|
and performs property translation for backward compatible schema changes.
|
||||||
|
The self.properties.data dict provides access to the raw data supplied by
|
||||||
|
the user in the template without any of those transformations.
|
||||||
|
|
||||||
*Attributes* describe runtime state data of the physical resource that the
|
*Attributes* describe runtime state data of the physical resource that the
|
||||||
plug-in can expose to other resources in a Stack. Generally, these aren't
|
plug-in can expose to other resources in a Stack. Generally, these aren't
|
||||||
available until the physical resource has been created and is in a usable
|
available until the physical resource has been created and is in a usable
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
@ -150,20 +148,20 @@ class CinderQuota(resource.Resource):
|
|||||||
if props is None:
|
if props is None:
|
||||||
props = self.properties
|
props = self.properties
|
||||||
|
|
||||||
args = copy.copy(props.data)
|
kwargs = dict((k, v) for k, v in props.items()
|
||||||
project = args.pop(self.PROJECT)
|
if k != self.PROJECT and v is not None)
|
||||||
# TODO(ricolin): Move this to stack validate stage. In some cases
|
# TODO(ricolin): Move this to stack validate stage. In some cases
|
||||||
# we still can't get project or other properties form other resources
|
# we still can't get project or other properties form other resources
|
||||||
# at validate stage.
|
# at validate stage.
|
||||||
self.validate_quotas(project, **args)
|
self.validate_quotas(props[self.PROJECT], **kwargs)
|
||||||
self.client().quotas.update(project, **args)
|
self.client().quotas.update(props[self.PROJECT], **kwargs)
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
self.client().quotas.delete(self.properties[self.PROJECT])
|
self.client().quotas.delete(self.properties[self.PROJECT])
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(CinderQuota, self).validate()
|
super(CinderQuota, self).validate()
|
||||||
if len(self.properties.data) == 1:
|
if sum(1 for p in self.properties.values() if p is not None) <= 1:
|
||||||
raise exception.PropertyUnspecifiedError(self.GIGABYTES,
|
raise exception.PropertyUnspecifiedError(self.GIGABYTES,
|
||||||
self.SNAPSHOTS,
|
self.SNAPSHOTS,
|
||||||
self.VOLUMES)
|
self.VOLUMES)
|
||||||
|
@ -18,7 +18,6 @@ from heat.common import short_id
|
|||||||
from heat.common import timeutils as iso8601utils
|
from heat.common import timeutils as iso8601utils
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine import environment
|
from heat.engine import environment
|
||||||
from heat.engine import function
|
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.engine.resources import stack_resource
|
from heat.engine.resources import stack_resource
|
||||||
from heat.engine import rsrc_defn
|
from heat.engine import rsrc_defn
|
||||||
@ -225,10 +224,15 @@ class InstanceGroup(stack_resource.StackResource):
|
|||||||
def _get_conf_properties(self):
|
def _get_conf_properties(self):
|
||||||
conf_refid = self.properties[self.LAUNCH_CONFIGURATION_NAME]
|
conf_refid = self.properties[self.LAUNCH_CONFIGURATION_NAME]
|
||||||
conf = self.stack.resource_by_refid(conf_refid)
|
conf = self.stack.resource_by_refid(conf_refid)
|
||||||
props = function.resolve(conf.properties.data)
|
props = dict((k, v) for k, v in conf.properties.items()
|
||||||
|
if k in conf.properties.data)
|
||||||
|
for key in [conf.BLOCK_DEVICE_MAPPINGS, conf.NOVA_SCHEDULER_HINTS]:
|
||||||
|
if props.get(key) is not None:
|
||||||
|
props[key] = list(dict((k, v) for k, v in prop.items()
|
||||||
|
if k in conf.properties.data[key][idx])
|
||||||
|
for idx, prop in enumerate(props[key]))
|
||||||
if 'InstanceId' in props:
|
if 'InstanceId' in props:
|
||||||
props = conf.rebuild_lc_properties(props['InstanceId'])
|
props = conf.rebuild_lc_properties(props['InstanceId'])
|
||||||
|
|
||||||
props['Tags'] = self._tags()
|
props['Tags'] = self._tags()
|
||||||
# if the launch configuration is created from an existing instance.
|
# if the launch configuration is created from an existing instance.
|
||||||
# delete the 'InstanceId' property
|
# delete the 'InstanceId' property
|
||||||
|
@ -20,7 +20,6 @@ from heat.common.i18n import _
|
|||||||
from heat.common import template_format
|
from heat.common import template_format
|
||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine import environment
|
from heat.engine import environment
|
||||||
from heat.engine import function
|
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.engine import resource
|
from heat.engine import resource
|
||||||
from heat.engine import template
|
from heat.engine import template
|
||||||
@ -199,7 +198,8 @@ class RemoteStack(resource.Resource):
|
|||||||
env = environment.Environment(s_data['environment'])
|
env = environment.Environment(s_data['environment'])
|
||||||
files = s_data['files']
|
files = s_data['files']
|
||||||
tmpl = template.Template(s_data['template'], env=env, files=files)
|
tmpl = template.Template(s_data['template'], env=env, files=files)
|
||||||
props = function.resolve(self.properties.data)
|
props = dict((k, v) for k, v in self.properties.items()
|
||||||
|
if k in self.properties.data)
|
||||||
props[self.TEMPLATE] = jsonutils.dumps(tmpl.t)
|
props[self.TEMPLATE] = jsonutils.dumps(tmpl.t)
|
||||||
props[self.PARAMETERS] = env.params
|
props[self.PARAMETERS] = env.params
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
@ -135,11 +133,10 @@ class NeutronQuota(neutron.NeutronResource):
|
|||||||
if props is None:
|
if props is None:
|
||||||
props = self.properties
|
props = self.properties
|
||||||
|
|
||||||
args = copy.copy(props.data)
|
kwargs = dict((k, v) for k, v in props.items()
|
||||||
project = args.pop(self.PROJECT)
|
if k != self.PROJECT and v is not None)
|
||||||
body = {"quota": args}
|
body = {"quota": kwargs}
|
||||||
|
self.client().update_quota(props[self.PROJECT], body)
|
||||||
self.client().update_quota(project, body)
|
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
if self.resource_id is not None:
|
if self.resource_id is not None:
|
||||||
@ -148,7 +145,7 @@ class NeutronQuota(neutron.NeutronResource):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(NeutronQuota, self).validate()
|
super(NeutronQuota, self).validate()
|
||||||
if len(self.properties.data) == 1:
|
if sum(1 for p in self.properties.values() if p is not None) <= 1:
|
||||||
raise exception.PropertyUnspecifiedError(
|
raise exception.PropertyUnspecifiedError(
|
||||||
*sorted(set(self.PROPERTIES) - {self.PROJECT}))
|
*sorted(set(self.PROPERTIES) - {self.PROJECT}))
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import copy
|
|
||||||
|
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
from heat.common.i18n import _
|
from heat.common.i18n import _
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
@ -228,17 +226,16 @@ class NovaQuota(resource.Resource):
|
|||||||
if props is None:
|
if props is None:
|
||||||
props = self.properties
|
props = self.properties
|
||||||
|
|
||||||
args = copy.copy(props.data)
|
kwargs = dict((k, v) for k, v in props.items()
|
||||||
project = args.pop(self.PROJECT)
|
if k != self.PROJECT and v is not None)
|
||||||
|
self.client().quotas.update(props.get(self.PROJECT), **kwargs)
|
||||||
self.client().quotas.update(project, **args)
|
|
||||||
|
|
||||||
def handle_delete(self):
|
def handle_delete(self):
|
||||||
self.client().quotas.delete(self.properties[self.PROJECT])
|
self.client().quotas.delete(self.properties[self.PROJECT])
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(NovaQuota, self).validate()
|
super(NovaQuota, self).validate()
|
||||||
if len(self.properties.data) == 1:
|
if sum(1 for p in self.properties.values() if p is not None) <= 1:
|
||||||
raise exception.PropertyUnspecifiedError(
|
raise exception.PropertyUnspecifiedError(
|
||||||
*sorted(set(self.PROPERTIES) - {self.PROJECT}))
|
*sorted(set(self.PROPERTIES) - {self.PROJECT}))
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ from heat.common.i18n import _
|
|||||||
from heat.engine import attributes
|
from heat.engine import attributes
|
||||||
from heat.engine.clients import progress
|
from heat.engine.clients import progress
|
||||||
from heat.engine import constraints
|
from heat.engine import constraints
|
||||||
from heat.engine import function
|
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.engine.resources.openstack.neutron import port as neutron_port
|
from heat.engine.resources.openstack.neutron import port as neutron_port
|
||||||
from heat.engine.resources.openstack.neutron import subnet
|
from heat.engine.resources.openstack.neutron import subnet
|
||||||
@ -1579,7 +1578,14 @@ class Server(server_base.BaseServer, sh.SchedulerHintsMixin,
|
|||||||
|
|
||||||
def handle_restore(self, defn, restore_data):
|
def handle_restore(self, defn, restore_data):
|
||||||
image_id = restore_data['resource_data']['snapshot_image_id']
|
image_id = restore_data['resource_data']['snapshot_image_id']
|
||||||
props = function.resolve(self.properties.data)
|
props = dict((k, v) for k, v in self.properties.items()
|
||||||
|
if k in self.properties.data)
|
||||||
|
for key in [self.BLOCK_DEVICE_MAPPING, self.BLOCK_DEVICE_MAPPING_V2,
|
||||||
|
self.NETWORKS]:
|
||||||
|
if props.get(key) is not None:
|
||||||
|
props[key] = list(dict((k, v) for k, v in prop.items()
|
||||||
|
if v is not None)
|
||||||
|
for prop in props[key])
|
||||||
props[self.IMAGE] = image_id
|
props[self.IMAGE] = image_id
|
||||||
return defn.freeze(properties=props)
|
return defn.freeze(properties=props)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user