예제 #1
0
 def test_volume_type_delete_with_consistencygroups_in_use(self):
     volume_type = db.volume_type_create(self.ctxt,
                                         {'name': 'fake volume type'})
     consistency_group1 = db.consistencygroup_create(
         self.ctxt, {'volume_type_id': volume_type['id']})
     consistency_group2 = db.consistencygroup_create(
         self.ctxt, {'volume_type_id': volume_type['id']})
     self.assertRaises(exception.VolumeTypeInUse, volume_types.destroy,
                       self.ctxt, volume_type['id'])
     db.consistencygroup_destroy(self.ctxt, consistency_group1['id'])
     self.assertRaises(exception.VolumeTypeInUse, volume_types.destroy,
                       self.ctxt, volume_type['id'])
     db.consistencygroup_destroy(self.ctxt, consistency_group2['id'])
     volume_types.destroy(self.ctxt, volume_type['id'])
예제 #2
0
    def create(self, cg_snap_id=None, cg_id=None):
        """Create a consistency group.

        If cg_snap_id or cg_id are specified then volume_type_id,
        availability_zone, and host will be taken from the source Consistency
        Group.
        """
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already_created'))
        updates = self.cinder_obj_get_changes()

        if 'cgsnapshots' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('cgsnapshots assigned'))

        if 'volumes' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('volumes assigned'))

        if 'cluster' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('cluster assigned'))

        db_consistencygroups = db.consistencygroup_create(
            self._context, updates, cg_snap_id, cg_id)
        self._from_db_object(self._context, self, db_consistencygroups)
예제 #3
0
    def create(self, cg_snap_id=None, cg_id=None):
        """Create a consistency group.

        If cg_snap_id or cg_id are specified then volume_type_id,
        availability_zone, and host will be taken from the source Consistency
        Group.
        """
        if self.obj_attr_is_set('id'):
            raise exception.ObjectActionError(action='create',
                                              reason=_('already_created'))
        updates = self.cinder_obj_get_changes()

        if 'cgsnapshots' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('cgsnapshots assigned'))

        if 'volumes' in updates:
            raise exception.ObjectActionError(action='create',
                                              reason=_('volumes assigned'))

        db_consistencygroups = db.consistencygroup_create(self._context,
                                                          updates,
                                                          cg_snap_id,
                                                          cg_id)
        self._from_db_object(self._context, self, db_consistencygroups)
예제 #4
0
def create_consistencygroup(ctxt,
                            host='test_host@fakedrv#fakepool',
                            name='test_cg',
                            description='this is a test cg',
                            status='available',
                            availability_zone='fake_az',
                            volume_type_id=None,
                            cgsnapshot_id=None,
                            source_cgid=None,
                            **kwargs):
    """Create a consistencygroup object in the DB."""
    cg = {}
    cg['host'] = host
    cg['user_id'] = ctxt.user_id
    cg['project_id'] = ctxt.project_id
    cg['status'] = status
    cg['name'] = name
    cg['description'] = description
    cg['availability_zone'] = availability_zone
    if volume_type_id:
        cg['volume_type_id'] = volume_type_id
    cg['cgsnapshot_id'] = cgsnapshot_id
    cg['source_cgid'] = source_cgid
    for key in kwargs:
        cg[key] = kwargs[key]
    return db.consistencygroup_create(ctxt, cg)
예제 #5
0
 def test_volume_type_delete_with_consistencygroups_in_use(self):
     volume_type = db.volume_type_create(self.ctxt, {'name':
                                                     'fake volume type'})
     consistency_group1 = db.consistencygroup_create(self.ctxt,
                                                     {'volume_type_id':
                                                      volume_type['id']})
     consistency_group2 = db.consistencygroup_create(self.ctxt,
                                                     {'volume_type_id':
                                                      volume_type['id']})
     self.assertRaises(exception.VolumeTypeInUse, volume_types.destroy,
                       self.ctxt, volume_type['id'])
     db.consistencygroup_destroy(self.ctxt, consistency_group1['id'])
     self.assertRaises(exception.VolumeTypeInUse, volume_types.destroy,
                       self.ctxt, volume_type['id'])
     db.consistencygroup_destroy(self.ctxt, consistency_group2['id'])
     volume_types.destroy(self.ctxt, volume_type['id'])
예제 #6
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_consistencygroups = db.consistencygroup_create(
         self._context, updates)
     self._from_db_object(self._context, self, db_consistencygroups)
예제 #7
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_consistencygroups = db.consistencygroup_create(self._context,
                                                       updates)
     self._from_db_object(self._context, self, db_consistencygroups)
예제 #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()

        if "cgsnapshots" in updates:
            raise exception.ObjectActionError(action="create", reason=_("cgsnapshots assigned"))

        if "volumes" in updates:
            raise exception.ObjectActionError(action="create", reason=_("volumes assigned"))

        db_consistencygroups = db.consistencygroup_create(self._context, updates)
        self._from_db_object(self._context, self, db_consistencygroups)
예제 #9
0
 def _create_consistencygroup(
         name='test_consistencygroup',
         description='this is a test consistency group',
         volume_type_id='123456',
         availability_zone='az1',
         status='creating'):
     """Create a consistency group object."""
     consistencygroup = {}
     consistencygroup['user_id'] = 'fake'
     consistencygroup['project_id'] = 'fake'
     consistencygroup['availability_zone'] = availability_zone
     consistencygroup['name'] = name
     consistencygroup['description'] = description
     consistencygroup['volume_type_id'] = volume_type_id
     consistencygroup['status'] = status
     consistencygroup['host'] = 'fakehost'
     return db.consistencygroup_create(context.get_admin_context(),
                                       consistencygroup)['id']
예제 #10
0
 def _create_consistencygroup(
     name="test_consistencygroup",
     description="this is a test consistency group",
     volume_type_id="123456",
     availability_zone="az1",
     host="fakehost",
     status="creating",
 ):
     """Create a consistency group object."""
     consistencygroup = {}
     consistencygroup["user_id"] = "fake"
     consistencygroup["project_id"] = "fake"
     consistencygroup["availability_zone"] = availability_zone
     consistencygroup["name"] = name
     consistencygroup["description"] = description
     consistencygroup["volume_type_id"] = volume_type_id
     consistencygroup["host"] = host
     consistencygroup["status"] = status
     return db.consistencygroup_create(context.get_admin_context(), consistencygroup)["id"]
예제 #11
0
 def _create_consistencygroup(
         name='test_consistencygroup',
         description='this is a test consistency group',
         volume_type_id='123456',
         availability_zone='az1',
         status='creating'):
     """Create a consistency group object."""
     consistencygroup = {}
     consistencygroup['user_id'] = 'fake'
     consistencygroup['project_id'] = 'fake'
     consistencygroup['availability_zone'] = availability_zone
     consistencygroup['name'] = name
     consistencygroup['description'] = description
     consistencygroup['volume_type_id'] = volume_type_id
     consistencygroup['status'] = status
     consistencygroup['host'] = 'fakehost'
     return db.consistencygroup_create(
         context.get_admin_context(),
         consistencygroup)['id']