コード例 #1
0
 def test_notify_about_aggregate_update_without_name_id(self):
     # Set empty aggregate payload
     aggregate_payload = {}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.start",
                                                 aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
コード例 #2
0
    def update_metadata(self, updates):
        if self.in_api:
            metadata_delete = _metadata_delete_from_db
            metadata_add = _metadata_add_to_db
        else:
            metadata_delete = db.aggregate_metadata_delete
            metadata_add = db.aggregate_metadata_add

        payload = {'aggregate_id': self.id, 'meta_data': updates}
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updatemetadata.start",
                                                    payload)
        to_add = {}
        for key, value in updates.items():
            if value is None:
                try:
                    metadata_delete(self._context, self.id, key)
                except exception.AggregateMetadataNotFound:
                    pass
                try:
                    self.metadata.pop(key)
                except KeyError:
                    pass
            else:
                to_add[key] = value
                self.metadata[key] = value
        metadata_add(self._context, self.id, to_add)
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updatemetadata.end",
                                                    payload)
        self.obj_reset_changes(fields=['metadata'])
コード例 #3
0
ファイル: test_compute_utils.py プロジェクト: ewindisch/nova
 def test_notify_about_aggregate_update_without_name_id(self):
     # Set empty aggregate payload
     aggregate_payload = {}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.start",
                                                 aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
コード例 #4
0
ファイル: aggregate.py プロジェクト: stackhpc/nova
    def save(self):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.start",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.START)
        updates.pop('id', None)
        db_aggregate = _aggregate_update_to_db(self._context, self.id, updates)
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end", payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.END)
        self._from_db_object(self._context, self, db_aggregate)
コード例 #5
0
ファイル: aggregate.py プロジェクト: 4everming/nova
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')

        # NOTE(mdoff): Once we have made it past a point where we know
        # all aggregates have been migrated, we can remove this. Ideally
        # in Ocata with a blocker migration to be sure.
        if not self._ensure_migrated(self._context):
            raise exception.ObjectActionError(
                action='create',
                reason='main database still contains aggregates')

        self._assert_no_hosts('create')
        updates = self.obj_get_changes()
        payload = dict(updates)
        if 'metadata' in updates:
            # NOTE(danms): For some reason the notification format is weird
            payload['meta_data'] = payload.pop('metadata')
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for aggregate',
                      dict(uuid=updates['uuid']))
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.start",
                                                    payload)
        metadata = updates.pop('metadata', None)
        db_aggregate = _aggregate_create_in_db(self._context, updates,
                                               metadata=metadata)
        self._from_db_object(self._context, self, db_aggregate)
        payload['aggregate_id'] = self.id
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.end",
                                                    payload)
コード例 #6
0
ファイル: aggregate.py プロジェクト: arbrandes/nova
 def update_metadata(self, updates):
     payload = {'aggregate_id': self.id,
                'meta_data': updates}
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.start",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.START)
     to_add = {}
     for key, value in updates.items():
         if value is None:
             try:
                 _metadata_delete_from_db(self._context, self.id, key)
             except exception.AggregateMetadataNotFound:
                 pass
             try:
                 self.metadata.pop(key)
             except KeyError:
                 pass
         else:
             to_add[key] = value
             self.metadata[key] = value
     _metadata_add_to_db(self._context, self.id, to_add)
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.end",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.END)
     self.obj_reset_changes(fields=['metadata'])
コード例 #7
0
ファイル: aggregate.py プロジェクト: arbrandes/nova
    def save(self):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.start",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.START)
        updates.pop('id', None)
        db_aggregate = _aggregate_update_to_db(self._context,
                                               self.id, updates)
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.UPDATE_PROP,
            phase=fields.NotificationPhase.END)
        self._from_db_object(self._context, self, db_aggregate)
コード例 #8
0
ファイル: aggregate.py プロジェクト: B-Rich/nova-1
 def update_metadata(self, context, updates):
     payload = {'aggregate_id': self.id,
                'meta_data': updates}
     compute_utils.notify_about_aggregate_update(context,
                                                 "updatemetadata.start",
                                                 payload)
     to_add = {}
     for key, value in updates.items():
         if value is None:
             try:
                 db.aggregate_metadata_delete(context, self.id, key)
             except exception.AggregateMetadataNotFound:
                 pass
             try:
                 self.metadata.pop(key)
             except KeyError:
                 pass
         else:
             to_add[key] = value
             self.metadata[key] = value
     db.aggregate_metadata_add(context, self.id, to_add)
     compute_utils.notify_about_aggregate_update(context,
                                                 "updatemetadata.end",
                                                 payload)
     self.obj_reset_changes(fields=['metadata'])
コード例 #9
0
ファイル: aggregate.py プロジェクト: unicell/nova
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     self._assert_no_hosts('create')
     updates = self.obj_get_changes()
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     if 'uuid' not in updates:
         updates['uuid'] = uuidutils.generate_uuid()
         LOG.debug('Generated uuid %(uuid)s for aggregate',
                   dict(uuid=updates['uuid']))
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.start",
                                                 payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(self._context, updates,
                                        metadata=metadata)
     self._from_db_object(self._context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.end",
                                                 payload)
コード例 #10
0
ファイル: aggregate.py プロジェクト: stackhpc/nova
 def update_metadata(self, updates):
     payload = {'aggregate_id': self.id, 'meta_data': updates}
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.start",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.START)
     to_add = {}
     for key, value in updates.items():
         if value is None:
             try:
                 _metadata_delete_from_db(self._context, self.id, key)
             except exception.AggregateMetadataNotFound:
                 pass
             try:
                 self.metadata.pop(key)
             except KeyError:
                 pass
         else:
             to_add[key] = value
             self.metadata[key] = value
     _metadata_add_to_db(self._context, self.id, to_add)
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "updatemetadata.end",
                                                 payload)
     compute_utils.notify_about_aggregate_action(
         context=self._context,
         aggregate=self,
         action=fields.NotificationAction.UPDATE_METADATA,
         phase=fields.NotificationPhase.END)
     self.obj_reset_changes(fields=['metadata'])
コード例 #11
0
ファイル: test_compute_utils.py プロジェクト: jorgevgut/nova
 def test_notify_about_aggregate_update_with_name(self):
     # Set aggregate payload
     aggregate_payload = {"name": "fakegroup"}
     compute_utils.notify_about_aggregate_update(self.context, "create.start", aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "aggregate.create.start")
     payload = msg.payload
     self.assertEqual(payload["name"], "fakegroup")
コード例 #12
0
ファイル: test_compute_utils.py プロジェクト: jorgevgut/nova
 def test_notify_about_aggregate_update_with_id(self):
     # Set aggregate payload
     aggregate_payload = {"aggregate_id": 1}
     compute_utils.notify_about_aggregate_update(self.context, "create.end", aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, "INFO")
     self.assertEqual(msg.event_type, "aggregate.create.end")
     payload = msg.payload
     self.assertEqual(payload["aggregate_id"], 1)
コード例 #13
0
ファイル: test_compute_utils.py プロジェクト: SUSE-Cloud/nova
 def test_notify_about_aggregate_update_with_id(self):
     # Set aggregate payload
     aggregate_payload = {'aggregate_id': 1}
     compute_utils.notify_about_aggregate_update(self.context, "create.end",
                                                 aggregate_payload)
     self.assertEquals(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg.priority, 'INFO')
     self.assertEquals(msg.event_type, 'aggregate.create.end')
     payload = msg.payload
     self.assertEquals(payload['aggregate_id'], 1)
コード例 #14
0
 def test_notify_about_aggregate_update_with_id(self):
     # Set aggregate payload
     aggregate_payload = {'aggregate_id': 1}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.end",
                                                 aggregate_payload)
     self.assertEquals(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEquals(msg.priority, 'INFO')
     self.assertEquals(msg.event_type, 'aggregate.create.end')
     payload = msg.payload
     self.assertEquals(payload['aggregate_id'], 1)
コード例 #15
0
 def test_notify_about_aggregate_update_with_name(self):
     # Set aggregate payload
     aggregate_payload = {'name': 'fakegroup'}
     compute_utils.notify_about_aggregate_update(self.context,
                                                 "create.start",
                                                 aggregate_payload)
     self.assertEqual(len(fake_notifier.NOTIFICATIONS), 1)
     msg = fake_notifier.NOTIFICATIONS[0]
     self.assertEqual(msg.priority, 'INFO')
     self.assertEqual(msg.event_type, 'aggregate.create.start')
     payload = msg.payload
     self.assertEqual(payload['name'], 'fakegroup')
コード例 #16
0
ファイル: aggregate.py プロジェクト: gilmeir/nova
    def save(self, context):
        self._assert_no_hosts("save")
        updates = self.obj_get_changes()

        payload = {"aggregate_id": self.id}
        if "metadata" in updates:
            payload["meta_data"] = updates["metadata"]
        compute_utils.notify_about_aggregate_update(context, "updateprop.start", payload)
        updates.pop("id", None)
        db_aggregate = db.aggregate_update(context, self.id, updates)
        compute_utils.notify_about_aggregate_update(context, "updateprop.end", payload)
        return self._from_db_object(context, self, db_aggregate)
コード例 #17
0
ファイル: aggregate.py プロジェクト: ubuntuserver/nova
 def create(self, context):
     self._assert_no_hosts("create")
     updates = self.obj_get_changes()
     payload = dict(updates)
     if "metadata" in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload["meta_data"] = payload.pop("metadata")
     compute_utils.notify_about_aggregate_update(context, "create.start", payload)
     metadata = updates.pop("metadata", None)
     db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
     self._from_db_object(context, self, db_aggregate)
     payload["aggregate_id"] = self.id
     compute_utils.notify_about_aggregate_update(context, "create.end", payload)
コード例 #18
0
    def save(self, context):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        db_aggregate = db.aggregate_update(context, self.id, updates)
        compute_utils.notify_about_aggregate_update(context, "updateprop.end",
                                                    payload)
        return self._from_db_object(context, self, db_aggregate)
コード例 #19
0
 def create(self, context):
     self._assert_no_hosts('create')
     updates = self.obj_get_changes()
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     compute_utils.notify_about_aggregate_update(context, "create.start",
                                                 payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
     self._from_db_object(context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(context, "create.end",
                                                 payload)
コード例 #20
0
ファイル: aggregate.py プロジェクト: B-Rich/nova-1
    def save(self, context):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        db_aggregate = db.aggregate_update(context, self.id, updates)
        compute_utils.notify_about_aggregate_update(context,
                                                    "updateprop.end",
                                                    payload)
        return self._from_db_object(context, self, db_aggregate)
コード例 #21
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')

        # NOTE(mdoff): Once we have made it past a point where we know
        # all aggregates have been migrated, we can remove this. Ideally
        # in Ocata with a blocker migration to be sure.
        if not self._ensure_migrated(self._context):
            raise exception.ObjectActionError(
                action='create',
                reason='main database still contains aggregates')

        self._assert_no_hosts('create')
        updates = self.obj_get_changes()
        payload = dict(updates)
        if 'metadata' in updates:
            # NOTE(danms): For some reason the notification format is weird
            payload['meta_data'] = payload.pop('metadata')
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']
            LOG.debug('Generated uuid %(uuid)s for aggregate',
                      dict(uuid=updates['uuid']))
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.start",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.CREATE,
            phase=fields.NotificationPhase.START)

        metadata = updates.pop('metadata', None)
        db_aggregate = _aggregate_create_in_db(self._context, updates,
                                               metadata=metadata)
        self._from_db_object(self._context, self, db_aggregate)
        payload['aggregate_id'] = self.id
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.end",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.CREATE,
            phase=fields.NotificationPhase.END)
コード例 #22
0
ファイル: aggregate.py プロジェクト: prometheanfire/nova
 def create(self, context):
     self._assert_no_hosts('create')
     updates = {}
     for key in self.obj_what_changed():
         updates[key] = self[key]
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     compute_utils.notify_about_aggregate_update(context,
                                                 "create.start",
                                                 payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(context, updates, metadata=metadata)
     self._from_db_object(context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(context,
                                                 "create.end",
                                                 payload)
コード例 #23
0
    def save(self):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        try:
            db_aggregate = _aggregate_update_to_db(self._context, self.id,
                                                   updates)
        except exception.AggregateNotFound:
            db_aggregate = db.aggregate_update(self._context, self.id, updates)

        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end", payload)
        self._from_db_object(self._context, self, db_aggregate)
コード例 #24
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason='already created')
     self._assert_no_hosts('create')
     updates = self.obj_get_changes()
     payload = dict(updates)
     if 'metadata' in updates:
         # NOTE(danms): For some reason the notification format is weird
         payload['meta_data'] = payload.pop('metadata')
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.start", payload)
     metadata = updates.pop('metadata', None)
     db_aggregate = db.aggregate_create(self._context,
                                        updates,
                                        metadata=metadata)
     self._from_db_object(self._context, self, db_aggregate)
     payload['aggregate_id'] = self.id
     compute_utils.notify_about_aggregate_update(self._context,
                                                 "create.end", payload)
コード例 #25
0
ファイル: aggregate.py プロジェクト: 4everming/nova
    def save(self):
        self._assert_no_hosts('save')
        updates = self.obj_get_changes()

        payload = {'aggregate_id': self.id}
        if 'metadata' in updates:
            payload['meta_data'] = updates['metadata']
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.start",
                                                    payload)
        updates.pop('id', None)
        try:
            db_aggregate = _aggregate_update_to_db(self._context,
                                                   self.id, updates)
        except exception.AggregateNotFound:
            db_aggregate = db.aggregate_update(self._context, self.id, updates)

        compute_utils.notify_about_aggregate_update(self._context,
                                                    "updateprop.end",
                                                    payload)
        self._from_db_object(self._context, self, db_aggregate)
コード例 #26
0
ファイル: aggregate.py プロジェクト: juju812/openstack_kolla
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')

        self._assert_no_hosts('create')
        updates = self.obj_get_changes()
        payload = dict(updates)
        if 'metadata' in updates:
            # NOTE(danms): For some reason the notification format is weird
            payload['meta_data'] = payload.pop('metadata')
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']
            LOG.debug('Generated uuid %(uuid)s for aggregate',
                      dict(uuid=updates['uuid']))
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.start",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.CREATE,
            phase=fields.NotificationPhase.START)

        metadata = updates.pop('metadata', None)
        db_aggregate = _aggregate_create_in_db(self._context, updates,
                                               metadata=metadata)
        self._from_db_object(self._context, self, db_aggregate)
        payload['aggregate_id'] = self.id
        compute_utils.notify_about_aggregate_update(self._context,
                                                    "create.end",
                                                    payload)
        compute_utils.notify_about_aggregate_action(
            context=self._context,
            aggregate=self,
            action=fields.NotificationAction.CREATE,
            phase=fields.NotificationPhase.END)