コード例 #1
0
ファイル: resource.py プロジェクト: carrierstack/heat
    def __init__(self, name, definition, stack):
        if '/' in name:
            raise ValueError(_('Resource name may not contain "/"'))

        self.stack = stack
        self.context = stack.context
        self.name = name
        self.t = definition
        self.reparse()
        self.attributes = Attributes(self.name, self.attributes_schema,
                                     self._resolve_attribute)

        self.abandon_in_progress = False

        self.resource_id = None
        # if the stack is being deleted, assume we've already been deleted
        if stack.action == stack.DELETE:
            self.action = self.DELETE
        else:
            self.action = self.INIT
        self.status = self.COMPLETE
        self.status_reason = ''
        self.id = None
        self._data = {}
        self._rsrc_metadata = None
        self.created_time = None
        self.updated_time = None

        resource = stack.db_resource_get(name)
        if resource:
            self._load_data(resource)
コード例 #2
0
    def __init__(self, name, json_snippet, stack):
        if '/' in name:
            raise ValueError(_('Resource name may not contain "/"'))

        self.stack = stack
        self.context = stack.context
        self.name = name
        self.json_snippet = json_snippet
        self.t = stack.resolve_static_data(json_snippet)
        self.properties = Properties(self.properties_schema,
                                     self.t.get('Properties', {}),
                                     self._resolve_runtime_data, self.name)
        self.attributes = Attributes(self.name, self.attributes_schema,
                                     self._resolve_attribute)

        resource = db_api.resource_get_by_name_and_stack(
            self.context, name, stack.id)
        if resource:
            self.resource_id = resource.nova_instance
            self.action = resource.action
            self.status = resource.status
            self.status_reason = resource.status_reason
            self.id = resource.id
            self.data = resource.data
        else:
            self.resource_id = None
            # if the stack is being deleted, assume we've already been deleted
            if stack.action == stack.DELETE:
                self.action = self.DELETE
            else:
                self.action = self.INIT
            self.status = self.COMPLETE
            self.status_reason = ''
            self.id = None
            self.data = []
コード例 #3
0
ファイル: resource.py プロジェクト: jazeltq/heat
    def resource_to_template(cls, resource_type):
        """
        :param resource_type: The resource type to be displayed in the template
        :returns: A template where the resource's properties_schema is mapped
            as parameters, and the resource's attributes_schema is mapped as
            outputs
        """
        (parameters, properties) = Properties.schema_to_parameters_and_properties(cls.properties_schema)

        resource_name = cls.__name__
        return {
            "Parameters": parameters,
            "Resources": {resource_name: {"Type": resource_type, "Properties": properties}},
            "Outputs": Attributes.as_outputs(resource_name, cls),
        }
コード例 #4
0
ファイル: resource.py プロジェクト: HuaiJiang/heat
    def __init__(self, name, definition, stack):
        if '/' in name:
            raise ValueError(_('Resource name may not contain "/"'))

        self.stack = stack
        self.context = stack.context
        self.name = name
        if isinstance(definition, rsrc_defn.ResourceDefinition):
            self.t = definition
        else:
            self.t = self.stack.resolve_static_data(definition)
        self.reparse()
        self.attributes = Attributes(self.name, self.attributes_schema,
                                     self._resolve_attribute)

        self.abandon_in_progress = False

        resource = stack.db_resource_get(name)

        if resource:
            self.resource_id = resource.nova_instance
            self.action = resource.action
            self.status = resource.status
            self.status_reason = resource.status_reason
            self.id = resource.id
            try:
                self._data = db_api.resource_data_get_all(self, resource.data)
            except exception.NotFound:
                self._data = {}
            self._rsrc_metadata = resource.rsrc_metadata
            self.created_time = resource.created_at
            self.updated_time = resource.updated_at
        else:
            self.resource_id = None
            # if the stack is being deleted, assume we've already been deleted
            if stack.action == stack.DELETE:
                self.action = self.DELETE
            else:
                self.action = self.INIT
            self.status = self.COMPLETE
            self.status_reason = ''
            self.id = None
            self._data = {}
            self._rsrc_metadata = None
            self.created_time = None
            self.updated_time = None
コード例 #5
0
    def __init__(self, name, json_snippet, stack):
        if '/' in name:
            raise ValueError(_('Resource name may not contain "/"'))

        self.stack = stack
        self.context = stack.context
        self.name = name
        self.json_snippet = json_snippet
        self.reparse()
        self.attributes = Attributes(self.name,
                                     self.attributes_schema,
                                     self._resolve_attribute)

        self.abandon_in_progress = False

        if stack.id:
            resource = db_api.resource_get_by_name_and_stack(self.context,
                                                             name, stack.id)
        else:
            resource = None

        if resource:
            self.resource_id = resource.nova_instance
            self.action = resource.action
            self.status = resource.status
            self.status_reason = resource.status_reason
            self.id = resource.id
            try:
                self._data = db_api.resource_data_get_all(self, resource.data)
            except exception.NotFound:
                self._data = {}
            self.created_time = resource.created_at
            self.updated_time = resource.updated_at
        else:
            self.resource_id = None
            # if the stack is being deleted, assume we've already been deleted
            if stack.action == stack.DELETE:
                self.action = self.DELETE
            else:
                self.action = self.INIT
            self.status = self.COMPLETE
            self.status_reason = ''
            self.id = None
            self._data = {}
            self.created_time = None
            self.updated_time = None
コード例 #6
0
ファイル: resource.py プロジェクト: NeCTAR-RC/heat
    def resource_to_template(cls, resource_type):
        '''
        :param resource_type: The resource type to be displayed in the template
        :returns: A template where the resource's properties_schema is mapped
            as parameters, and the resource's attributes_schema is mapped as
            outputs
        '''
        (parameters, properties) = (Properties.
                                    schema_to_parameters_and_properties(
                                        cls.properties_schema))

        resource_name = cls.__name__
        return {
            'Parameters': parameters,
            'Resources': {
                resource_name: {
                    'Type': resource_type,
                    'Properties': properties
                }
            },
            'Outputs': Attributes.as_outputs(resource_name, cls)
        }
コード例 #7
0
    def resource_to_template(cls, resource_type):
        '''
        :param resource_type: The resource type to be displayed in the template
        :returns: A template where the resource's properties_schema is mapped
            as parameters, and the resource's attributes_schema is mapped as
            outputs
        '''
        (parameters,
         properties) = (Properties.schema_to_parameters_and_properties(
             cls.properties_schema))

        resource_name = cls.__name__
        return {
            'Parameters': parameters,
            'Resources': {
                resource_name: {
                    'Type': resource_type,
                    'Properties': properties
                }
            },
            'Outputs': Attributes.as_outputs(resource_name, cls)
        }