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 failover segment',
                      dict(uuid=updates['uuid']))

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

        db_segment = db.failover_segment_create(self._context, updates)

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

        self._from_db_object(self._context, self, db_segment)
Ejemplo n.º 2
0
 def _get_failover_segment(self):
     values = {'uuid': uuidsentinel.failover_segment_id,
               'name': 'fake_segment_name',
               'service_type': 'fake_service_type',
               'description': 'fake_description',
               'recovery_method': 'auto'}
     return db.failover_segment_create(self.ctxt, values)
Ejemplo n.º 3
0
    def test_host_get_by_uuid_filter_by_invalid_failover_segment(self):
        # create hosts under failover_segment
        # 'uuidsentinel.failover_segment_id'
        for host in self._get_fake_values_list():
            self._create_host(host)

        # create one more failover_segment
        values = {'uuid': uuidsentinel.failover_segment_id_1,
                  'name': 'fake_segment_name_1',
                  'service_type': 'fake_service_type',
                  'description': 'fake_description',
                  'recovery_method': 'auto'}
        db.failover_segment_create(self.ctxt, values)

        # try to get host with failover_segment
        # 'uuidsentinel.failover_segment_id_1'
        self.assertRaises(
            exception.HostNotFoundUnderFailoverSegment, db.host_get_by_uuid,
            self.ctxt, uuidsentinel.uuid_1, uuidsentinel.failover_segment_id_1)
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 failover segment',
                      dict(uuid=updates['uuid']))

        db_segment = db.failover_segment_create(self._context, updates)
        self._from_db_object(self._context, self, db_segment)
Ejemplo n.º 5
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 failover segment',
                      dict(uuid=updates['uuid']))

        db_segment = db.failover_segment_create(self._context, updates)
        self._from_db_object(self._context, self, db_segment)
Ejemplo n.º 6
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 failover segment',
                      dict(uuid=updates['uuid']))

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

        db_segment = db.failover_segment_create(self._context, updates)

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

        self._from_db_object(self._context, self, db_segment)
Ejemplo n.º 7
0
 def _create_failover_segment(self, values):
     return db.failover_segment_create(self.ctxt, values)