Ejemplo n.º 1
0
    def load(cls, context, stack_id=None, stack=None, resolve_data=True,
             parent_resource=None, show_deleted=True):
        '''Retrieve a Stack from the database.'''
        if stack is None:
            stack = db_api.stack_get(context, stack_id,
                                     show_deleted=show_deleted,
                                     eager_load=True)
        if stack is None:
            message = _('No stack exists with id "%s"') % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(
            context, stack.raw_template_id, stack.raw_template)
        env = environment.Environment(stack.parameters)
        stack = cls(context, stack.name, template, env,
                    stack.id, stack.action, stack.status, stack.status_reason,
                    stack.timeout, resolve_data, stack.disable_rollback,
                    parent_resource, owner_id=stack.owner_id,
                    stack_user_project_id=stack.stack_user_project_id,
                    created_time=stack.created_at,
                    updated_time=stack.updated_at,
                    user_creds_id=stack.user_creds_id, tenant_id=stack.tenant,
                    validate_parameters=False)

        return stack
Ejemplo n.º 2
0
 def _from_db(cls,
              context,
              stack,
              parent_resource=None,
              resolve_data=True,
              use_stored_context=False):
     template = Template.load(context, stack.raw_template_id,
                              stack.raw_template)
     env = environment.Environment(stack.parameters)
     return cls(context,
                stack.name,
                template,
                env,
                stack.id,
                stack.action,
                stack.status,
                stack.status_reason,
                stack.timeout,
                resolve_data,
                stack.disable_rollback,
                parent_resource,
                owner_id=stack.owner_id,
                stack_user_project_id=stack.stack_user_project_id,
                created_time=stack.created_at,
                updated_time=stack.updated_at,
                user_creds_id=stack.user_creds_id,
                tenant_id=stack.tenant,
                validate_parameters=False,
                use_stored_context=use_stored_context)
Ejemplo n.º 3
0
 def _from_db(cls, context, stack, parent_resource=None, resolve_data=True, use_stored_context=False):
     template = Template.load(context, stack.raw_template_id, stack.raw_template)
     env = environment.Environment(stack.parameters)
     return cls(
         context,
         stack.name,
         template,
         env,
         stack.id,
         stack.action,
         stack.status,
         stack.status_reason,
         stack.timeout,
         resolve_data,
         stack.disable_rollback,
         parent_resource,
         owner_id=stack.owner_id,
         stack_user_project_id=stack.stack_user_project_id,
         created_time=stack.created_at,
         updated_time=stack.updated_at,
         user_creds_id=stack.user_creds_id,
         tenant_id=stack.tenant,
         validate_parameters=False,
         use_stored_context=use_stored_context,
     )
Ejemplo n.º 4
0
    def load(cls,
             context,
             stack_id=None,
             stack=None,
             resolve_data=True,
             parent_resource=None,
             show_deleted=True):
        '''Retrieve a Stack from the database.'''
        if stack is None:
            stack = db_api.stack_get(context,
                                     stack_id,
                                     show_deleted=show_deleted)
        if stack is None:
            message = 'No stack exists with id "%s"' % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(context, stack.raw_template_id)
        env = environment.Environment(stack.parameters)
        stack = cls(context,
                    stack.name,
                    template,
                    env,
                    stack.id,
                    stack.action,
                    stack.status,
                    stack.status_reason,
                    stack.timeout,
                    resolve_data,
                    stack.disable_rollback,
                    parent_resource,
                    owner_id=stack.owner_id)

        return stack
Ejemplo n.º 5
0
    def load(cls, context, stack_id=None, stack=None, resolve_data=True, parent_resource=None, show_deleted=True):
        """Retrieve a Stack from the database."""
        if stack is None:
            stack = db_api.stack_get(context, stack_id, show_deleted=show_deleted)
        if stack is None:
            message = _('No stack exists with id "%s"') % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(context, stack.raw_template_id)
        env = environment.Environment(stack.parameters)
        stack = cls(
            context,
            stack.name,
            template,
            env,
            stack.id,
            stack.action,
            stack.status,
            stack.status_reason,
            stack.timeout,
            resolve_data,
            stack.disable_rollback,
            parent_resource,
            owner_id=stack.owner_id,
        )

        return stack
Ejemplo n.º 6
0
    def load(cls, context, stack_id=None, stack=None, resolve_data=True,
             parent_resource=None, show_deleted=True):
        '''Retrieve a Stack from the database.'''
        if stack is None:
            stack = db_api.stack_get(context, stack_id,
                                     show_deleted=show_deleted,
                                     eager_load=True)
        if stack is None:
            message = _('No stack exists with id "%s"') % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(
            context, stack.raw_template_id, stack.raw_template)
        env = environment.Environment(stack.parameters)
        stack = cls(context, stack.name, template, env,
                    stack.id, stack.action, stack.status, stack.status_reason,
                    stack.timeout, resolve_data, stack.disable_rollback,
                    parent_resource, owner_id=stack.owner_id,
                    stack_user_project_id=stack.stack_user_project_id,
                    created_time=stack.created_at,
                    updated_time=stack.updated_at,
                    user_creds_id=stack.user_creds_id, tenant_id=stack.tenant,
                    validate_parameters=False)

        return stack
Ejemplo n.º 7
0
    def load(cls, context, stack_id=None, stack=None, resolve_data=True):
        '''Retrieve a Stack from the database'''
        if stack is None:
            stack = db_api.stack_get(context, stack_id)
        if stack is None:
            message = 'No stack exists with id "%s"' % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(context, stack.raw_template_id)
        params = Parameters(stack.name, template, stack.parameters)
        stack = cls(context, stack.name, template, params, stack.id,
                    stack.status, stack.status_reason, stack.timeout,
                    resolve_data, stack.disable_rollback)

        return stack
Ejemplo n.º 8
0
    def load(cls, context, stack_id=None, stack=None, resolve_data=True):
        '''Retrieve a Stack from the database.'''
        if stack is None:
            stack = db_api.stack_get(context, stack_id)
        if stack is None:
            message = 'No stack exists with id "%s"' % str(stack_id)
            raise exception.NotFound(message)

        template = Template.load(context, stack.raw_template_id)
        params = Parameters(stack.name, template, stack.parameters)
        stack = cls(context, stack.name, template, params,
                    stack.id, stack.status, stack.status_reason, stack.timeout,
                    resolve_data, stack.disable_rollback)

        return stack
Ejemplo n.º 9
0
 def _backup_stack(self, create_if_missing=True):
     """
     Get a Stack containing any in-progress resources from the previous
     stack state prior to an update.
     """
     s = db_api.stack_get_by_name_and_owner_id(self.context, self._backup_name(), owner_id=self.id)
     if s is not None:
         LOG.debug("Loaded existing backup stack")
         return self.load(self.context, stack=s)
     elif create_if_missing:
         templ = Template.load(self.context, self.t.id)
         templ.files = copy.deepcopy(self.t.files)
         prev = type(self)(self.context, self.name, templ, self.env, owner_id=self.id)
         prev.store(backup=True)
         LOG.debug("Created new backup stack")
         return prev
     else:
         return None
Ejemplo n.º 10
0
 def _from_db(cls, context, stack, parent_resource=None, resolve_data=True,
              use_stored_context=False):
     template = Template.load(
         context, stack.raw_template_id, stack.raw_template)
     env = environment.Environment(stack.parameters)
     return cls(context, stack.name, template, env,
                stack.id, stack.action, stack.status, stack.status_reason,
                stack.timeout, resolve_data, stack.disable_rollback,
                parent_resource, owner_id=stack.owner_id,
                stack_user_project_id=stack.stack_user_project_id,
                created_time=stack.created_at,
                updated_time=stack.updated_at,
                user_creds_id=stack.user_creds_id, tenant_id=stack.tenant,
                use_stored_context=use_stored_context,
                username=stack.username,
                #add by xm-20150603
                stack_apps_style=stack.stack_apps_style, isscaler=stack.isscaler,
                enduser=stack.enduser, description=stack.description,
                app_name=stack.app_name, template_id=stack.template_id)
Ejemplo n.º 11
0
 def _backup_stack(self, create_if_missing=True):
     '''
     Get a Stack containing any in-progress resources from the previous
     stack state prior to an update.
     '''
     s = db_api.stack_get_by_name(self.context, self._backup_name(),
                                  owner_id=self.id)
     if s is not None:
         logger.debug(_('Loaded existing backup stack'))
         return self.load(self.context, stack=s)
     elif create_if_missing:
         templ = Template.load(self.context, self.t.id)
         templ.files = copy.deepcopy(self.t.files)
         prev = type(self)(self.context, self.name, templ, self.env,
                           owner_id=self.id)
         prev.store(backup=True)
         logger.debug(_('Created new backup stack'))
         return prev
     else:
         return None