Example #1
0
    def save(self):
        updates = self.karbor_obj_get_changes()
        if updates:
            if 'parameters' in updates:
                parameters = updates.pop('parameters', None)
                if parameters is not None:
                    updates['parameters'] = jsonutils.dumps(parameters)

            if 'resources' in updates:
                resources = updates.pop('resources', None)
                resources_objlist = db.plan_resources_update(
                    self._context, self.id, resources)
                resources_dictlist = []
                for resource_obj in resources_objlist:
                    resource_dict = {}
                    resource_dict["plan_id"] = resource_obj.get("plan_id")
                    resource_dict["id"] = resource_obj.get("resource_id")
                    resource_dict["type"] = resource_obj.get("resource_type")
                    resource_dict["name"] = resource_obj.get("resource_name")
                    resource_dict["extra_info"] = resource_obj.get(
                        "resource_extra_info")
                    resources_dictlist.append(resource_dict)
                self.resources = resources_dictlist
            db.plan_update(self._context, self.id, updates)
            self.obj_reset_changes()
Example #2
0
    def save(self):
        updates = self.karbor_obj_get_changes()
        if updates:
            if 'parameters' in updates:
                parameters = updates.pop('parameters', None)
                if parameters is not None:
                    updates['parameters'] = jsonutils.dumps(parameters)

            if 'resources' in updates:
                resources = updates.pop('resources', None)
                resources_objlist = db.plan_resources_update(
                    self._context, self.id, resources)
                resources_dictlist = []
                for resource_obj in resources_objlist:
                    resource_dict = {}
                    resource_dict["plan_id"] = resource_obj.get("plan_id")
                    resource_dict["id"] = resource_obj.get("resource_id")
                    resource_dict["type"] = resource_obj.get("resource_type")
                    resource_dict["name"] = resource_obj.get("resource_name")
                    resources_dictlist.append(resource_dict)
                self.resources = resources_dictlist
            db.plan_update(self._context, self.id, updates)
            self.obj_reset_changes()
Example #3
0
 def test_plan_update(self):
     plan = db.plan_create(self.ctxt, self.fake_plan)
     db.plan_update(self.ctxt, plan['id'], {'status': 'started'})
     plan = db.plan_get(self.ctxt, plan['id'])
     self.assertEqual('started', plan['status'])
Example #4
0
 def test_plan_update(self):
     plan = db.plan_create(self.ctxt, self.fake_plan)
     db.plan_update(self.ctxt, plan['id'],
                    {'status': 'started'})
     plan = db.plan_get(self.ctxt, plan['id'])
     self.assertEqual('started', plan['status'])