Ejemplo n.º 1
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.masakari_obj_get_changes()

        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for host',
                      dict(uuid=updates['uuid']))

        if 'failover_segment' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason='failover segment '
                                              'assigned')

        api_utils.notify_about_host_api(
            self._context,
            self,
            action=fields.EventNotificationAction.HOST_CREATE,
            phase=fields.EventNotificationPhase.START)

        db_host = db.host_create(self._context, updates)

        api_utils.notify_about_host_api(
            self._context,
            self,
            action=fields.EventNotificationAction.HOST_CREATE,
            phase=fields.EventNotificationPhase.END)

        self._from_db_object(self._context, self, db_host)
Ejemplo n.º 2
0
    def destroy(self):
        if not self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='already destroyed')
        if not self.obj_attr_is_set('notification_uuid'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='no uuid')

        db.notification_delete(self._context, self.notification_uuid)
        delattr(self, base.get_attrname('id'))
Ejemplo n.º 3
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.masakari_obj_get_changes()
        # NOTE(ShilpaSD): This field doesn't exist in the Notification
        # db model so don't save it.
        updates.pop('recovery_workflow_details', None)

        if 'notification_uuid' not in updates:
            updates['notification_uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for notifications',
                      dict(uuid=updates['notification_uuid']))

        if 'payload' in updates:
            updates['payload'] = jsonutils.dumps(updates['payload'])

        api_utils.notify_about_notification_api(
            self._context,
            self,
            action=fields.EventNotificationAction.NOTIFICATION_CREATE,
            phase=fields.EventNotificationPhase.START)

        db_notification = db.notification_create(self._context, updates)

        api_utils.notify_about_notification_api(
            self._context,
            self,
            action=fields.EventNotificationAction.NOTIFICATION_CREATE,
            phase=fields.EventNotificationPhase.END)

        self._from_db_object(self._context, self, db_notification)
Ejemplo n.º 4
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.masakari_obj_get_changes()

        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for host',
                      dict(uuid=updates['uuid']))

        if 'failover_segment' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason='failover segment '
                                              'assigned')
        db_host = db.host_create(self._context, updates)
        self._from_db_object(self._context, self, db_host)
Ejemplo n.º 5
0
 def save(self):
     updates = self.masakari_obj_get_changes()
     if 'failover_segment' in updates:
         raise exception.ObjectActionError(action='save',
                                           reason='failover segment '
                                           'changed')
     updates.pop('id', None)
     db_host = db.host_update(self._context, self.uuid, updates)
     self._from_db_object(self._context, self, db_host)
Ejemplo n.º 6
0
    def destroy(self):
        if not self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='already destroyed')
        if not self.obj_attr_is_set('uuid'):
            raise exception.ObjectActionError(action='destroy',
                                              reason='no uuid')

        api_utils.notify_about_segment_api(self._context, self,
            action=fields.EventNotificationAction.SEGMENT_DELETE,
            phase=fields.EventNotificationPhase.START)

        db.failover_segment_delete(self._context, self.uuid)

        api_utils.notify_about_segment_api(self._context, self,
            action=fields.EventNotificationAction.SEGMENT_DELETE,
            phase=fields.EventNotificationPhase.END)

        delattr(self, base.get_attrname('id'))
Ejemplo n.º 7
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason='already created')
        updates = self.masakari_obj_get_changes()

        if 'notification_uuid' not in updates:
            updates['notification_uuid'] = uuidutils.generate_uuid()
            LOG.debug('Generated uuid %(uuid)s for notifications',
                      dict(uuid=updates['notification_uuid']))

        if 'payload' in updates:
            updates['payload'] = jsonutils.dumps(updates['payload'])

        db_notification = db.notification_create(self._context, updates)
        self._from_db_object(self._context, self, db_notification)
Ejemplo n.º 8
0
    def save(self):
        updates = self.masakari_obj_get_changes()
        if 'failover_segment' in updates:
            raise exception.ObjectActionError(action='save',
                                              reason='failover segment '
                                              'changed')
        updates.pop('id', None)

        api_utils.notify_about_host_api(
            self._context,
            self,
            action=fields.EventNotificationAction.HOST_UPDATE,
            phase=fields.EventNotificationPhase.START)

        db_host = db.host_update(self._context, self.uuid, updates)

        api_utils.notify_about_host_api(
            self._context,
            self,
            action=fields.EventNotificationAction.HOST_UPDATE,
            phase=fields.EventNotificationPhase.END)

        self._from_db_object(self._context, self, db_host)