def save(self):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()

        # NOTE(sbauza): We do NOT save the set of compute nodes that an
        # instance group is connected to in this method. Instance groups are
        # implicitly connected to compute nodes when the
        # InstanceGroup.add_members() method is called, which adds the mapping
        # table entries.
        # So, since the only way to have hosts in the updates is to set that
        # field explicitly, we prefer to raise an Exception so the developer
        # knows he has to call obj_reset_changes(['hosts']) right after setting
        # the field.
        if 'hosts' in updates:
            raise exception.InstanceGroupSaveException(field='hosts')

        if not updates:
            return

        payload = dict(updates)
        payload['server_group_id'] = self.uuid

        try:
            db_group = self._save_in_db(self._context, self.uuid, updates)
        except exception.InstanceGroupNotFound:
            db.instance_group_update(self._context, self.uuid, updates)
            db_group = db.instance_group_get(self._context, self.uuid)
        self._from_db_object(self._context, self, db_group)
        compute_utils.notify_about_server_group_update(self._context, "update",
                                                       payload)
Beispiel #2
0
    def save(self):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()

        # NOTE(sbauza): We do NOT save the set of compute nodes that an
        # instance group is connected to in this method. Instance groups are
        # implicitly connected to compute nodes when the
        # InstanceGroup.add_members() method is called, which adds the mapping
        # table entries.
        # So, since the only way to have hosts in the updates is to set that
        # field explicitely, we prefer to raise an Exception so the developer
        # knows he has to call obj_reset_changes(['hosts']) right after setting
        # the field.
        if 'hosts' in updates:
            raise exception.InstanceGroupSaveException(field='hosts')

        if not updates:
            return

        payload = dict(updates)
        payload['server_group_id'] = self.uuid

        db.instance_group_update(self._context, self.uuid, updates)
        db_inst = db.instance_group_get(self._context, self.uuid)
        self._from_db_object(self._context, self, db_inst)
        compute_utils.notify_about_server_group_update(self._context,
                                                       "update", payload)
Beispiel #3
0
    def save(self, context):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()
        if not updates:
            return

        db.instance_group_update(context, self.uuid, updates)
        db_inst = db.instance_group_get(context, self.uuid)
        self._from_db_object(context, self, db_inst)
    def save(self, context):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()
        if not updates:
            return

        db.instance_group_update(context, self.uuid, updates)
        db_inst = db.instance_group_get(context, self.uuid)
        self._from_db_object(context, self, db_inst)
Beispiel #5
0
 def test_refresh(self):
     values = self._get_default_values()
     db_result = self._create_instance_group(self.context, values)
     obj_result = instance_group.InstanceGroup.get_by_uuid(self.context, db_result.uuid)
     self.assertEqual(obj_result.name, "fake_name")
     values = {"name": "new_name", "user_id": "new_user", "project_id": "new_project"}
     db.instance_group_update(self.context, db_result["uuid"], values)
     obj_result.refresh()
     self.assertEqual(obj_result.name, "new_name")
     self.assertEqual(set([]), obj_result.obj_what_changed())
Beispiel #6
0
 def test_refresh(self):
     values = self._get_default_values()
     db_result = self._create_instance_group(self.context, values)
     obj_result = instance_group.InstanceGroup.get_by_uuid(self.context,
                                                           db_result.uuid)
     self.assertEqual(obj_result.name, 'fake_name')
     values = {'name': 'new_name', 'user_id': 'new_user',
               'project_id': 'new_project'}
     db.instance_group_update(self.context, db_result['uuid'],
                              values)
     obj_result.refresh()
     self.assertEqual(obj_result.name, 'new_name')
     self.assertEqual(set([]), obj_result.obj_what_changed())
 def test_refresh(self):
     values = self._get_default_values()
     db_result = self._create_instance_group(self.context, values)
     obj_result = instance_group.InstanceGroup.get_by_uuid(self.context,
                                                           db_result.uuid)
     self.assertEqual(obj_result.name, 'fake_name')
     values = {'name': 'new_name', 'user_id': 'new_user',
               'project_id': 'new_project'}
     db.instance_group_update(self.context, db_result['uuid'],
                              values)
     obj_result.refresh()
     self.assertEqual(obj_result.name, 'new_name')
     self.assertEqual(set([]), obj_result.obj_what_changed())
Beispiel #8
0
    def save(self):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()
        if not updates:
            return

        payload = dict(updates)
        payload['server_group_id'] = self.uuid

        db.instance_group_update(self._context, self.uuid, updates)
        db_inst = db.instance_group_get(self._context, self.uuid)
        self._from_db_object(self._context, self, db_inst)
        compute_utils.notify_about_server_group_update(self._context, "update",
                                                       payload)
Beispiel #9
0
    def save(self, context):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()
        if not updates:
            return

        metadata = None
        if 'metadetails' in updates:
            metadata = updates.pop('metadetails')
            updates.update({'metadata': metadata})

        db.instance_group_update(context, self.uuid, updates)
        db_inst = db.instance_group_get(context, self.uuid)
        self._from_db_object(context, self, db_inst)
Beispiel #10
0
    def save(self):
        """Save updates to this instance group."""

        updates = self.obj_get_changes()
        if not updates:
            return

        payload = dict(updates)
        payload['server_group_id'] = self.uuid

        db.instance_group_update(self._context, self.uuid, updates)
        db_inst = db.instance_group_get(self._context, self.uuid)
        self._from_db_object(self._context, self, db_inst)
        compute_utils.notify_about_server_group_update(self._context,
                                                       "update", payload)