Exemplo n.º 1
0
    def _unique_service_in_role(self, req, disk_meta):
        params = {'filters': {'role_id': disk_meta['role_id']}}
        service_disks = registry.list_service_disk_metadata(
            req.context, **params)
        if disk_meta['disk_location'] == 'share_cluster':
            share_cluster_count = 0
            for disk in service_disks:
                if disk['service'] == disk_meta['service'] and \
                        disk['disk_location'] != 'share_cluster':
                    id = disk['id']
                    registry.delete_service_disk_metadata(req.context, id)
                if disk['disk_location'] == 'share_cluster':
                    share_cluster_count += 1
            if share_cluster_count >= 2:
                msg = "There were more than two disk services %s in role %s" %\
                    (disk_meta['service'], disk_meta['role_id'])
                LOG.error(msg)
                raise HTTPBadRequest(explanation=msg,
                                     request=req,
                                     content_type="text/plain")

        else:
            for service_disk in service_disks:
                if service_disk['disk_location'] == 'share_cluster' and \
                        service_disk['service'] == disk_meta['service']:
                    id = service_disk['id']
                    registry.delete_service_disk_metadata(req.context, id)
                elif service_disk['service'] == disk_meta['service']:
                    msg = "disk service %s has existed in role %s" % (
                        disk_meta['service'], disk_meta['role_id'])
                    LOG.error(msg)
                    raise HTTPBadRequest(explanation=msg,
                                         request=req,
                                         content_type="text/plain")
Exemplo n.º 2
0
def get_service_disk_list(req, params):
    try:
        service_disks = registry.list_service_disk_metadata(
            req.context, **params)
    except exception.Invalid as e:
        raise HTTPBadRequest(explanation=e.msg, request=req)
    return service_disks
Exemplo n.º 3
0
def get_service_disk_list(req, params):
    try:
        service_disks = registry.list_service_disk_metadata(
            req.context, **params)
    except exception.Invalid as e:
        raise HTTPBadRequest(explanation=e.msg, request=req)
    return service_disks
Exemplo n.º 4
0
    def _unique_service_in_role(self, req, disk_meta):
        params = {'filters': {'role_id': disk_meta['role_id']}}
        service_disks = registry.list_service_disk_metadata(
            req.context, **params)
        if disk_meta['disk_location'] == 'share_cluster':
            share_cluster_count = 0
            for disk in service_disks:
                if disk['service'] == disk_meta['service'] and \
                        disk['disk_location'] != 'share_cluster':
                    id = disk['id']
                    registry.delete_service_disk_metadata(req.context, id)
                if disk['disk_location'] == 'share_cluster':
                    share_cluster_count += 1
            if share_cluster_count >= 2:
                msg = "There were more than two disk services %s in role %s" %\
                    (disk_meta['service'], disk_meta['role_id'])
                LOG.error(msg)
                raise HTTPBadRequest(explanation=msg,
                                     request=req,
                                     content_type="text/plain")

        else:
            for service_disk in service_disks:
                if service_disk['disk_location'] == 'share_cluster' and \
                        service_disk['service'] == disk_meta['service']:
                    id = service_disk['id']
                    registry.delete_service_disk_metadata(req.context, id)
                elif service_disk['service'] == disk_meta['service']:
                    msg = "disk service %s has existed in role %s" % (
                        disk_meta['service'], disk_meta['role_id'])
                    LOG.error(msg)
                    raise HTTPBadRequest(explanation=msg,
                                         request=req,
                                         content_type="text/plain")
Exemplo n.º 5
0
def _get_services_disk(req, role):
    params = {'filters': {'role_id': role['id']}}
    services_disk = registry.list_service_disk_metadata(req.context, **params)
    for service_disk in services_disk:
        if service_disk.get('role_id', None):
            service_disk['role_id'] = role['name']
        _del_general_params(service_disk)
    return services_disk
Exemplo n.º 6
0
 def _get_services_disk(self, req, role):
     params = {'filters': {'role_id': role['id']}}
     services_disk = registry.list_service_disk_metadata(
         req.context, **params)
     for service_disk in services_disk:
         if service_disk.get('role_id', None):
             service_disk['role_id'] = role['name']
         self._del_general_params(service_disk)
     return services_disk
Exemplo n.º 7
0
 def _unique_service_in_role(self, req, disk_meta):                        
     params = {'filters': {'role_id': disk_meta['role_id']}}
     service_disks = registry.list_service_disk_metadata(req.context, **params)
     for service_disk in service_disks:
         if service_disk['service'] == disk_meta['service']:
             msg = "disk service %s has existed in role %s" %(disk_meta['service'], disk_meta['role_id'])
             raise HTTPBadRequest(explanation=msg,
                                 request=req,
                                 content_type="text/plain") 
Exemplo n.º 8
0
 def service_disk_list(self, req):
     self._enforce(req, 'service_disk_list')
     params = self._get_query_params(req)
     filters=params.get('filters',None)
     if 'role_id' in filters:
         role_id=filters['role_id']
         self._raise_404_if_role_deleted(req, role_id)
     try:
         service_disks = registry.list_service_disk_metadata(req.context, **params)
     except exception.Invalid as e:
         raise HTTPBadRequest(explanation=e.msg, request=req)
     return dict(disk_meta=service_disks)
Exemplo n.º 9
0
 def service_disk_list(self, req):
     self._enforce(req, 'service_disk_list')
     params = self._get_query_params(req)
     filters = params.get('filters', None)
     if 'role_id' in filters:
         role_id = filters['role_id']
         self._raise_404_if_role_deleted(req, role_id)
     try:
         service_disks = registry.list_service_disk_metadata(
             req.context, **params)
     except exception.Invalid as e:
         raise HTTPBadRequest(explanation=e.msg, request=req)
     return dict(disk_meta=service_disks)