Example #1
0
    def store(self, owner=None):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''
        new_creds = db_api.user_creds_create(self.context)

        s = {
            'name': self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.parameters.user_parameters(),
            'owner_id': owner and owner.id,
            'user_creds_id': new_creds.id,
            'username': self.context.username,
            'tenant': self.context.tenant_id,
            'status': self.state,
            'status_reason': self.state_description,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        self._set_param_stackid()

        return self.id
Example #2
0
    def store(self, backup=False):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''

        s = {
            'name': self._backup_name() if backup else self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.env.user_env_as_dict(),
            'owner_id': self.owner_id,
            'username': self.context.username,
            'tenant': self.context.tenant_id,
            'action': self.action,
            'status': self.status,
            'status_reason': self.status_reason,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            new_creds = db_api.user_creds_create(self.context)
            s['user_creds_id'] = new_creds.id
            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        self._set_param_stackid()

        return self.id
Example #3
0
    def store(self, owner=None):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''
        new_creds = db_api.user_creds_create(self.context)

        s = {
            'name': self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.parameters.user_parameters(),
            'owner_id': owner and owner.id,
            'user_creds_id': new_creds.id,
            'username': self.context.username,
            'tenant': self.context.tenant_id,
            'status': self.state,
            'status_reason': self.state_description,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        self._set_param_stackid()

        return self.id
Example #4
0
    def store(self, owner=None):
        """
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        """
        new_creds = db_api.user_creds_create(self.context)

        s = {
            "name": self.name,
            "raw_template_id": self.t.store(self.context),
            "parameters": self.parameters.user_parameters(),
            "owner_id": owner and owner.id,
            "user_creds_id": new_creds.id,
            "username": self.context.username,
            "tenant": self.context.tenant_id,
            "status": self.state,
            "status_reason": self.state_description,
            "timeout": self.timeout_mins,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        return self.id
Example #5
0
    def store(self, backup=False):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''

        s = {
            'name': self._backup_name() if backup else self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.env.user_env_as_dict(),
            'owner_id': self.owner_id,
            'username': self.context.username,
            'tenant': self.context.tenant_id,
            'action': self.action,
            'status': self.status,
            'status_reason': self.status_reason,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            new_creds = db_api.user_creds_create(self.context)
            s['user_creds_id'] = new_creds.id
            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        self._set_param_stackid()

        return self.id
Example #6
0
    def store(self, backup=False):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''
        s = {
            'name': self._backup_name() if backup else self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.env.user_env_as_dict(),
            'owner_id': self.owner_id,
            'username': self.username,
            'tenant': self.tenant_id,
            'action': self.action,
            'status': self.status,
            'status_reason': self.status_reason,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
            'stack_user_project_id': self.stack_user_project_id,
            'updated_at': self.updated_time,
            'user_creds_id': self.user_creds_id,
            'backup': backup,
            # 'enduser': self.context.user_id,
            'enduser': self.enduser,
            'stack_apps_style': self.stack_apps_style,
            'isscaler': self.isscaler,
            'description': self.description,
            'app_name': self.app_name,
            'template_id': self.template_id
            # 'stack_apps_style': "ssss",
            # 'isscaler': 1,
            # 'description': "yyyy"
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            if not self.user_creds_id:
                # Create a context containing a trust_id and trustor_user_id
                # if trusts are enabled
                if cfg.CONF.deferred_auth_method == 'trusts':
                    keystone = self.clients.client('keystone')
                    trust_ctx = keystone.create_trust_context()
                    new_creds = db_api.user_creds_create(trust_ctx)
                else:
                    new_creds = db_api.user_creds_create(self.context)
                s['user_creds_id'] = new_creds.id
                self.user_creds_id = new_creds.id

            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id
            self.created_time = new_s.created_at

        self._set_param_stackid()

        return self.id
Example #7
0
    def create_stack(self, context, stack_name, template, params):
        """
        The create_stack method creates a new stack using the template
        provided.
        Note that at this stage the template has already been fetched from the
        heat-api process if using a template-url.
        arg1 -> RPC context.
        arg2 -> Name of the stack you want to create.
        arg3 -> Template of stack you want to create.
        arg4 -> Params passed from API.
        """
        logger.info("template is %s" % template)
        if db_api.stack_get(None, stack_name):
            return {"Error": "Stack already exists with that name."}

        metadata_server = config.FLAGS.heat_metadata_server_url
        # We don't want to reset the stack template, so we are making
        # an instance just for validation.
        template_copy = deepcopy(template)
        stack_validator = parser.Stack(stack_name, template_copy, 0, params, metadata_server=metadata_server)
        response = stack_validator.validate()
        stack_validator = None
        template_copy = None
        if "Malformed Query Response" in response["ValidateTemplateResult"]["Description"]:
            return response["ValidateTemplateResult"]["Description"]

        stack = parser.Stack(stack_name, template, 0, params, metadata_server=metadata_server)
        rt = {}
        rt["template"] = template
        rt["stack_name"] = stack_name
        new_rt = db_api.raw_template_create(None, rt)

        s = {}
        s["name"] = stack_name
        s["raw_template_id"] = new_rt.id
        new_s = db_api.stack_create(None, s)
        stack.id = new_s.id

        pt = {}
        pt["template"] = stack.t
        pt["raw_template_id"] = new_rt.id
        new_pt = db_api.parsed_template_create(None, pt)

        stack.parsed_template_id = new_pt.id
        stack.create()

        return {"stack": {"id": new_s.id, "name": new_s.name, "created_at": str(new_s.created_at)}}
Example #8
0
    def store(self, backup=False):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''
        s = {
            'name': self._backup_name() if backup else self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.env.user_env_as_dict(),
            'owner_id': self.owner_id,
            'username': self.username,
            'tenant': self.tenant_id,
            'action': self.action,
            'status': self.status,
            'status_reason': self.status_reason,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
            'stack_user_project_id': self.stack_user_project_id,
            'updated_at': self.updated_time,
            'user_creds_id': self.user_creds_id,
            'backup': backup,
            'nested_depth': self.nested_depth,
            'convergence': self.convergence
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            if not self.user_creds_id:
                # Create a context containing a trust_id and trustor_user_id
                # if trusts are enabled
                if cfg.CONF.deferred_auth_method == 'trusts':
                    keystone = self.clients.client('keystone')
                    trust_ctx = keystone.create_trust_context()
                    new_creds = db_api.user_creds_create(trust_ctx)
                else:
                    new_creds = db_api.user_creds_create(self.context)
                s['user_creds_id'] = new_creds.id
                self.user_creds_id = new_creds.id

            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id
            self.created_time = new_s.created_at

        self._set_param_stackid()

        return self.id
Example #9
0
    def store(self, backup=False):
        """
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        """
        s = {
            "name": self._backup_name() if backup else self.name,
            "raw_template_id": self.t.store(self.context),
            "parameters": self.env.user_env_as_dict(),
            "owner_id": self.owner_id,
            "username": self.context.username,
            "tenant": self.tenant_id,
            "action": self.action,
            "status": self.status,
            "status_reason": self.status_reason,
            "timeout": self.timeout_mins,
            "disable_rollback": self.disable_rollback,
            "stack_user_project_id": self.stack_user_project_id,
            "updated_at": self.updated_time,
            "user_creds_id": self.user_creds_id,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            if not self.user_creds_id:
                # Create a context containing a trust_id and trustor_user_id
                # if trusts are enabled
                if cfg.CONF.deferred_auth_method == "trusts":
                    trust_ctx = self.clients.keystone().create_trust_context()
                    new_creds = db_api.user_creds_create(trust_ctx)
                else:
                    new_creds = db_api.user_creds_create(self.context)
                s["user_creds_id"] = new_creds.id
                self.user_creds_id = new_creds.id

            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id
            self.created_time = new_s.created_at

        self._set_param_stackid()

        return self.id
Example #10
0
    def store(self, backup=False):
        '''
        Store the stack in the database and return its ID
        If self.id is set, we update the existing stack
        '''

        s = {
            'name': self._backup_name() if backup else self.name,
            'raw_template_id': self.t.store(self.context),
            'parameters': self.env.user_env_as_dict(),
            'owner_id': self.owner_id,
            'username': self.context.username,
            'tenant': self.context.tenant_id,
            'action': self.action,
            'status': self.status,
            'status_reason': self.status_reason,
            'timeout': self.timeout_mins,
            'disable_rollback': self.disable_rollback,
            'stack_user_project_id': self.stack_user_project_id,
        }
        if self.id:
            db_api.stack_update(self.context, self.id, s)
        else:
            # Create a context containing a trust_id and trustor_user_id
            # if trusts are enabled
            if cfg.CONF.deferred_auth_method == 'trusts':
                trust_context = self.clients.keystone().create_trust_context()
                new_creds = db_api.user_creds_create(trust_context)
            else:
                new_creds = db_api.user_creds_create(self.context)
            s['user_creds_id'] = new_creds.id

            new_s = db_api.stack_create(self.context, s)
            self.id = new_s.id

        self._set_param_stackid()

        return self.id
Example #11
0
 def create(cls, context, values):
     return cls._from_db_object(context, cls(context),
                                db_api.stack_create(context, values))
Example #12
0
 def create(cls, context, values):
     return cls._from_db_object(context, cls(context), db_api.stack_create(context, values))
Example #13
0
 def create(cls, context, values):
     return db_api.stack_create(context, values)
Example #14
0
 def create(cls, context, values):
     return db_api.stack_create(context, values)