예제 #1
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 'consistencygroup' in updates:
            raise exception.ObjectActionError(
                action='create', reason=_('consistencygroup assigned'))

        db_cgsnapshots = db.cgsnapshot_create(self._context, updates)
        self._from_db_object(self._context, self, db_cgsnapshots)
예제 #2
0
파일: cgsnapshot.py 프로젝트: njhsi/cinder
    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 'consistencygroup' in updates:
            raise exception.ObjectActionError(
                action='create', reason=_('consistencygroup assigned'))

        db_cgsnapshots = db.cgsnapshot_create(self._context, updates)
        self._from_db_object(self._context, self, db_cgsnapshots)
예제 #3
0
 def _create_cgsnapshot(
     name="test_cgsnapshot", description="this is a test cgsnapshot", consistencygroup_id="1", status="creating"
 ):
     """Create a cgsnapshot object."""
     cgsnapshot = {}
     cgsnapshot["user_id"] = "fake"
     cgsnapshot["project_id"] = "fake"
     cgsnapshot["consistencygroup_id"] = consistencygroup_id
     cgsnapshot["name"] = name
     cgsnapshot["description"] = description
     cgsnapshot["status"] = status
     return db.cgsnapshot_create(context.get_admin_context(), cgsnapshot)["id"]
예제 #4
0
 def _create_cgsnapshot(name='test_cgsnapshot',
                        description='this is a test cgsnapshot',
                        consistencygroup_id='1',
                        status='creating'):
     """Create a cgsnapshot object."""
     cgsnapshot = {}
     cgsnapshot['user_id'] = 'fake'
     cgsnapshot['project_id'] = 'fake'
     cgsnapshot['consistencygroup_id'] = consistencygroup_id
     cgsnapshot['name'] = name
     cgsnapshot['description'] = description
     cgsnapshot['status'] = status
     return db.cgsnapshot_create(context.get_admin_context(),
                                 cgsnapshot)['id']
예제 #5
0
 def _create_cgsnapshot(
         name='test_cgsnapshot',
         description='this is a test cgsnapshot',
         consistencygroup_id='1',
         status='creating'):
     """Create a cgsnapshot object."""
     cgsnapshot = {}
     cgsnapshot['user_id'] = 'fake'
     cgsnapshot['project_id'] = 'fake'
     cgsnapshot['consistencygroup_id'] = consistencygroup_id
     cgsnapshot['name'] = name
     cgsnapshot['description'] = description
     cgsnapshot['status'] = status
     return db.cgsnapshot_create(context.get_admin_context(),
                                 cgsnapshot)['id']
예제 #6
0
파일: utils.py 프로젝트: abusse/cinder
def create_cgsnapshot(ctxt,
                      name='test_cgsnap',
                      description='this is a test cgsnap',
                      status='available',
                      consistencygroup_id=None,
                      **kwargs):
    """Create a cgsnapshot object in the DB."""
    cgsnap = {}
    cgsnap['user_id'] = ctxt.user_id
    cgsnap['project_id'] = ctxt.project_id
    cgsnap['status'] = status
    cgsnap['name'] = name
    cgsnap['description'] = description
    cgsnap['consistencygroup_id'] = consistencygroup_id
    for key in kwargs:
        cgsnap[key] = kwargs[key]
    return db.cgsnapshot_create(ctxt, cgsnap)
예제 #7
0
파일: utils.py 프로젝트: carriercomm/cinder
def create_cgsnapshot(ctxt,
                      name='test_cgsnap',
                      description='this is a test cgsnap',
                      status='available',
                      consistencygroup_id=None,
                      **kwargs):
    """Create a cgsnapshot object in the DB."""
    cgsnap = {}
    cgsnap['user_id'] = ctxt.user_id
    cgsnap['project_id'] = ctxt.project_id
    cgsnap['status'] = status
    cgsnap['name'] = name
    cgsnap['description'] = description
    cgsnap['consistencygroup_id'] = consistencygroup_id
    for key in kwargs:
        cgsnap[key] = kwargs[key]
    return db.cgsnapshot_create(ctxt, cgsnap)
예제 #8
0
def create_cgsnapshot(
    ctxt,
    name="test_cgsnap",
    description="this is a test cgsnap",
    status="available",
    consistencygroup_id=None,
    **kwargs
):
    """Create a cgsnapshot object in the DB."""
    cgsnap = {}
    cgsnap["user_id"] = ctxt.user_id
    cgsnap["project_id"] = ctxt.project_id
    cgsnap["status"] = status
    cgsnap["name"] = name
    cgsnap["description"] = description
    cgsnap["consistencygroup_id"] = consistencygroup_id
    for key in kwargs:
        cgsnap[key] = kwargs[key]
    return db.cgsnapshot_create(ctxt, cgsnap)
예제 #9
0
def create_cgsnapshot(ctxt,
                      consistencygroup_id,
                      name='test_cgsnapshot',
                      description='this is a test cgsnapshot',
                      status='creating',
                      recursive_create_if_needed=True,
                      return_vo=True,
                      **kwargs):
    """Create a cgsnapshot object in the DB."""
    values = {
        'user_id': ctxt.user_id or fake.USER_ID,
        'project_id': ctxt.project_id or fake.PROJECT_ID,
        'status': status,
        'name': name,
        'description': description,
        'consistencygroup_id': consistencygroup_id}
    values.update(kwargs)

    if recursive_create_if_needed and consistencygroup_id:
        create_cg = False
        try:
            objects.ConsistencyGroup.get_by_id(ctxt,
                                               consistencygroup_id)
            create_vol = not db.volume_get_all_by_group(
                ctxt, consistencygroup_id)
        except exception.ConsistencyGroupNotFound:
            create_cg = True
            create_vol = True
        if create_cg:
            create_consistencygroup(ctxt, id=consistencygroup_id)
        if create_vol:
            create_volume(ctxt, consistencygroup_id=consistencygroup_id)

    cgsnap = db.cgsnapshot_create(ctxt, values)

    if not return_vo:
        return cgsnap

    return objects.CGSnapshot.get_by_id(ctxt, cgsnap.id)
예제 #10
0
def create_cgsnapshot(ctxt,
                      consistencygroup_id,
                      name='test_cgsnapshot',
                      description='this is a test cgsnapshot',
                      status='creating',
                      recursive_create_if_needed=True,
                      return_vo=True,
                      **kwargs):
    """Create a cgsnapshot object in the DB."""
    values = {
        'user_id': ctxt.user_id or fake.USER_ID,
        'project_id': ctxt.project_id or fake.PROJECT_ID,
        'status': status,
        'name': name,
        'description': description,
        'consistencygroup_id': consistencygroup_id}
    values.update(kwargs)

    if recursive_create_if_needed and consistencygroup_id:
        create_cg = False
        try:
            objects.ConsistencyGroup.get_by_id(ctxt,
                                               consistencygroup_id)
            create_vol = not db.volume_get_all_by_group(
                ctxt, consistencygroup_id)
        except exception.ConsistencyGroupNotFound:
            create_cg = True
            create_vol = True
        if create_cg:
            create_consistencygroup(ctxt, id=consistencygroup_id)
        if create_vol:
            create_volume(ctxt, consistencygroup_id=consistencygroup_id)

    cgsnap = db.cgsnapshot_create(ctxt, values)

    if not return_vo:
        return cgsnap

    return objects.CGSnapshot.get_by_id(ctxt, cgsnap.id)