Exemplo n.º 1
0
 def _migrate_volume_prep(self):
     admin_ctx = context.get_admin_context()
     # create volume's current host and the destination host
     db.service_create(admin_ctx, {"host": "test", "topic": CONF.volume_topic, "created_at": timeutils.utcnow()})
     db.service_create(admin_ctx, {"host": "test2", "topic": CONF.volume_topic, "created_at": timeutils.utcnow()})
     # current status is available
     volume = self._create_volume(admin_ctx)
     return volume
Exemplo n.º 2
0
 def _migrate_volume_prep(self):
     # create volume's current host and the destination host
     db.service_create(self.ctx, {"host": "test", "topic": constants.VOLUME_TOPIC, "created_at": timeutils.utcnow()})
     db.service_create(
         self.ctx, {"host": "test2", "topic": constants.VOLUME_TOPIC, "created_at": timeutils.utcnow()}
     )
     # current status is available
     volume = self._create_volume(self.ctx)
     return volume
Exemplo n.º 3
0
 def test_cluster_get_services(self):
     """Test services is properly populated on non empty cluster."""
     # We create another cluster to see we do the selection correctly
     self._create_populated_cluster(2, name="cluster2")
     # We create our cluster with 2 up nodes and 1 down
     cluster, svcs = self._create_populated_cluster(3, 1)
     # Add a deleted service to the cluster
     db.service_create(self.ctxt, {"cluster_name": cluster.name, "deleted": True})
     db_cluster = db.cluster_get(self.ctxt, name=cluster.name, get_services=True)
     self.assertEqual(3, len(db_cluster.services))
     self.assertSetEqual({svc.id for svc in svcs}, {svc.id for svc in db_cluster.services})
Exemplo n.º 4
0
 def _migrate_volume_prep(self):
     # create volume's current host and the destination host
     db.service_create(self.ctx,
                       {'host': 'test',
                        'topic': constants.VOLUME_TOPIC,
                        'created_at': timeutils.utcnow()})
     db.service_create(self.ctx,
                       {'host': 'test2',
                        'topic': constants.VOLUME_TOPIC,
                        'created_at': timeutils.utcnow()})
     # current status is available
     volume = self._create_volume(self.ctx)
     return volume
Exemplo n.º 5
0
 def _migrate_volume_prep(self):
     # create volume's current host and the destination host
     db.service_create(self.ctx,
                       {'host': 'test',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     db.service_create(self.ctx,
                       {'host': 'test2',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     # current status is available
     volume = self._create_volume(self.ctx)
     return volume
 def _migrate_volume_prep(self):
     admin_ctx = context.get_admin_context()
     # create volume's current host and the destination host
     db.service_create(admin_ctx,
                       {'host': 'test',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     db.service_create(admin_ctx,
                       {'host': 'test2',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     volume = self._create_volume(admin_ctx)
     return volume
Exemplo n.º 7
0
 def test_cluster_get_services(self):
     """Test services is properly populated on non empty cluster."""
     # We create another cluster to see we do the selection correctly
     utils.create_populated_cluster(self.ctxt, 2, name='cluster2')
     # We create our cluster with 2 up nodes and 1 down
     cluster, svcs = utils.create_populated_cluster(self.ctxt, 3, 1)
     # Add a deleted service to the cluster
     db.service_create(self.ctxt,
                       {'cluster_name': cluster.name,
                        'deleted': True})
     db_cluster = db.cluster_get(self.ctxt, name=cluster.name,
                                 get_services=True)
     self.assertEqual(3, len(db_cluster.services))
     self.assertSetEqual({svc.id for svc in svcs},
                         {svc.id for svc in db_cluster.services})
Exemplo n.º 8
0
 def create(self):
     if self.obj_attr_is_set('id'):
         raise exception.ObjectActionError(action='create',
                                           reason=_('already created'))
     updates = self.cinder_obj_get_changes()
     db_service = db.service_create(self._context, updates)
     self._from_db_object(self._context, self, db_service)
 def setUp(self):
     super(TestCleanableManager, self).setUp()
     self.user_id = fake_constants.USER_ID
     self.project_id = fake_constants.PROJECT_ID
     self.context = context.RequestContext(self.user_id, self.project_id,
                                           is_admin=True)
     self.service = db.service_create(self.context, {})
Exemplo n.º 10
0
 def _migrate_volume_prep(self):
     admin_ctx = context.get_admin_context()
     # create volume's current host and the destination host
     db.service_create(
         admin_ctx, {
             'host': 'test',
             'topic': CONF.volume_topic,
             'created_at': timeutils.utcnow()
         })
     db.service_create(
         admin_ctx, {
             'host': 'test2',
             'topic': CONF.volume_topic,
             'created_at': timeutils.utcnow()
         })
     volume = self._create_volume(admin_ctx)
     return volume
Exemplo n.º 11
0
    def test_worker_get_all(self):
        """Test basic get_all method."""
        self._create_workers(1)
        service = db.service_create(self.ctxt, {})
        workers = self._create_workers(3, service_id=service.id)

        db_workers = db.worker_get_all(self.ctxt, service_id=service.id)
        self._assertEqualListsOfObjects(workers, db_workers)
Exemplo n.º 12
0
    def test_worker_get_all(self):
        """Test basic get_all method."""
        self._create_workers(1)
        service = db.service_create(self.ctxt, {})
        workers = self._create_workers(3, service_id=service.id)

        db_workers = db.worker_get_all(self.ctxt, service_id=service.id)
        self._assertEqualListsOfObjects(workers, db_workers)
Exemplo n.º 13
0
 def create(self):
     if self.obj_attr_is_set("id"):
         raise exception.ObjectActionError(action="create", reason=_("already created"))
     updates = self.cinder_obj_get_changes()
     if "cluster" in updates:
         raise exception.ObjectActionError(action="create", reason=_("cluster assigned"))
     db_service = db.service_create(self._context, updates)
     self._from_db_object(self._context, self, db_service)
Exemplo n.º 14
0
 def setUp(self):
     super(TestCleanableManager, self).setUp()
     self.user_id = fake_constants.USER_ID
     self.project_id = fake_constants.PROJECT_ID
     self.context = context.RequestContext(self.user_id,
                                           self.project_id,
                                           is_admin=True)
     self.service = db.service_create(self.context, {})
Exemplo n.º 15
0
 def _create_service_ref(self, context):
     zone = FLAGS.storage_availability_zone
     service_ref = db.service_create(context,
                                     {'host': self.host,
                                      'binary': self.binary,
                                      'topic': self.topic,
                                      'report_count': 0,
                                      'availability_zone': zone})
     self.service_id = service_ref['id']
Exemplo n.º 16
0
 def _migrate_volume_prep(self):
     admin_ctx = context.get_admin_context()
     # create volume's current host and the destination host
     db.service_create(admin_ctx,
                       {'host': 'test',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     db.service_create(admin_ctx,
                       {'host': 'test2',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     # current status is available
     volume = db.volume_create(admin_ctx,
                               {'status': 'available',
                                'host': 'test',
                                'provider_location': '',
                                'attach_status': ''})
     return volume
Exemplo n.º 17
0
 def _create_service_ref(self, context):
     zone = CONF.storage_availability_zone
     service_ref = db.service_create(context,
                                     {'host': self.host,
                                      'binary': self.binary,
                                      'topic': self.topic,
                                      'report_count': 0,
                                      'availability_zone': zone})
     self.service_id = service_ref['id']
Exemplo n.º 18
0
 def _migrate_volume_prep(self):
     admin_ctx = context.get_admin_context()
     # create volume's current host and the destination host
     db.service_create(admin_ctx,
                       {'host': 'test',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     db.service_create(admin_ctx,
                       {'host': 'test2',
                        'topic': CONF.volume_topic,
                        'created_at': timeutils.utcnow()})
     # current status is available
     volume = db.volume_create(admin_ctx,
                               {'status': 'available',
                                'host': 'test',
                                'provider_location': '',
                                'attach_status': ''})
     return volume
Exemplo n.º 19
0
def create_service(ctxt, values=None):
    values = values or {}
    v = default_service_values()
    v.update(values)
    service = db.service_create(ctxt, v)
    # We need to read the contents from the DB if we have set updated_at
    # or created_at fields
    if 'updated_at' in values or 'created_at' in values:
        service = db.service_get(ctxt, service.id)
    return service
Exemplo n.º 20
0
def create_service(ctxt, values=None):
    values = values or {}
    v = default_service_values()
    v.update(values)
    service = db.service_create(ctxt, v)
    # We need to read the contents from the DB if we have set updated_at
    # or created_at fields
    if 'updated_at' in values or 'created_at' in values:
        service = db.service_get(ctxt, service.id)
    return service
Exemplo n.º 21
0
 def test_create_svc_exists_upgrade_cluster(self, is_upgrading_mock):
     """Test that we update cluster_name field when cfg has changed."""
     # Create the service in the DB
     db_svc = db.service_create(context.get_admin_context(),
                                {'host': self.host, 'binary': self.binary,
                                 'topic': self.topic,
                                 'cluster_name': None})
     cluster_name = 'cluster'
     app = service.Service.create(host=self.host, binary=self.binary,
                                  cluster=cluster_name, topic=self.topic)
     self._check_app(app, cluster_name, svc_id=db_svc.id)
Exemplo n.º 22
0
 def test_create_svc_exists_upgrade_cluster(self):
     """Test that we update cluster_name field when cfg has changed."""
     # Create the service in the DB
     db_svc = db.service_create(context.get_admin_context(),
                                {'host': self.host, 'binary': self.binary,
                                 'topic': self.topic,
                                 'cluster_name': None})
     cluster_name = 'cluster'
     app = service.Service.create(host=self.host, binary=self.binary,
                                  cluster=cluster_name, topic=self.topic)
     self._check_app(app, cluster_name, svc_id=db_svc.id,
                     added_to_cluster=cluster_name)
Exemplo n.º 23
0
 def test_create_svc_exists_not_upgrade_cluster(self, is_upgrading_mock):
     """Test we don't update cluster_name on cfg change when upgrading."""
     # Create the service in the DB
     db_svc = db.service_create(context.get_admin_context(),
                                {'host': self.host, 'binary': self.binary,
                                 'topic': self.topic,
                                 'cluster': None})
     cluster_name = 'cluster'
     app = service.Service.create(host=self.host, binary=self.binary,
                                  cluster=cluster_name, topic=self.topic)
     self._check_app(app, cluster_name, cluster_exists=False,
                     is_upgrading=True, svc_id=db_svc.id)
Exemplo n.º 24
0
    def _create_populated_cluster(self, num_services, num_down_svcs=0, **values):
        """Helper method that creates a cluster with up and down services."""
        up_time = timeutils.utcnow()
        down_time = up_time - datetime.timedelta(seconds=CONF.service_down_time + 1)
        cluster = self._create_cluster(**values)

        svcs = [
            db.service_create(
                self.ctxt, {"cluster_name": cluster.name, "updated_at": down_time if i < num_down_svcs else up_time}
            )
            for i in range(num_services)
        ]
        return cluster, svcs
Exemplo n.º 25
0
 def _create_service_ref(self, context):
     zone = FLAGS.node_availability_zone
     service_ref = db.service_create(
         context,
         {
             "host": self.host,
             "binary": self.binary,
             "topic": self.topic,
             "report_count": 0,
             "availability_zone": zone,
         },
     )
     self.service_id = service_ref["id"]
Exemplo n.º 26
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already created'))
        updates = self.cinder_obj_get_changes()
        if 'cluster' in updates:
            raise exception.ObjectActionError(
                action='create', reason=_('cluster assigned'))
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']

        db_service = db.service_create(self._context, updates)
        self._from_db_object(self._context, self, db_service)
Exemplo n.º 27
0
    def create(self):
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already created'))
        updates = self.cinder_obj_get_changes()
        if 'cluster' in updates:
            raise exception.ObjectActionError(
                action='create', reason=_('cluster assigned'))
        if 'uuid' not in updates:
            updates['uuid'] = uuidutils.generate_uuid()
            self.uuid = updates['uuid']

        db_service = db.service_create(self._context, updates)
        self._from_db_object(self._context, self, db_service)
Exemplo n.º 28
0
def create_populated_cluster(ctxt, num_services, num_down_svcs=0, **values):
    """Helper method that creates a cluster with up and down services."""
    up_time = timeutils.utcnow()
    down_time = (up_time -
                 datetime.timedelta(seconds=CONF.service_down_time + 1))
    cluster = create_cluster(ctxt, **values)

    svcs = [
        db.service_create(
            ctxt,
            {'cluster_name': cluster.name,
             'host': 'host' + str(i),
             'updated_at': down_time if i < num_down_svcs else up_time})
        for i in range(num_services)
    ]
    return cluster, svcs
Exemplo n.º 29
0
def create_populated_cluster(ctxt, num_services, num_down_svcs=0, **values):
    """Helper method that creates a cluster with up and down services."""
    up_time = timeutils.utcnow()
    down_time = (up_time -
                 datetime.timedelta(seconds=CONF.service_down_time + 1))
    cluster = create_cluster(ctxt, **values)

    svcs = [
        db.service_create(
            ctxt,
            {'cluster_name': cluster.name,
             'host': 'host' + str(i),
             'updated_at': down_time if i < num_down_svcs else up_time})
        for i in range(num_services)
    ]
    return cluster, svcs
Exemplo n.º 30
0
 def test_create_svc_exists_not_upgrade_cluster(self, is_upgrading_mock):
     """Test we don't update cluster_name on cfg change when upgrading."""
     # Create the service in the DB
     db_svc = db.service_create(
         context.get_admin_context(), {
             'host': self.host,
             'binary': self.binary,
             'topic': self.topic,
             'cluster': None
         })
     cluster_name = 'cluster'
     app = service.Service.create(host=self.host,
                                  binary=self.binary,
                                  cluster=cluster_name,
                                  topic=self.topic)
     self._check_app(app,
                     cluster_name,
                     cluster_exists=False,
                     is_upgrading=True,
                     svc_id=db_svc.id)
Exemplo n.º 31
0
 def _create_service(self, **values):
     values.setdefault('uuid', self.uuid())
     db.service_create(self.context, values)
Exemplo n.º 32
0
 def _create_service(self, values):
     v = self._get_base_values()
     v.update(values)
     return db.service_create(self.ctxt, v)
Exemplo n.º 33
0
 def _create_service(self, values):
     v = self._get_base_values()
     v.update(values)
     return db.service_create(self.ctxt, v)