Exemple #1
0
    def get_domains():
        """
        Fetch domains

        :return: list with ovs.dal.hybrids.domain.Domain objects
        :rtype: list
        """
        return DomainList.get_domains()
Exemple #2
0
    def get_domain_guids():
        """
        Fetch domain guids

        :return: list of strings
        :rtype: list
        """

        return [domain.guid for domain in DomainList.get_domains()]
    def check_recovery_domains(result_handler):
        result_handler.info('Checking recovery domains:')
        prim_domains = [domain.name for domain in DomainList.get_domains() if len(domain.storage_router_layout['regular']) >= 1]
        for domain in DomainList.get_domains():
            layout = domain.storage_router_layout
            recovery = layout['recovery']
            regular = layout['regular']
            # Check recovery usage
            if len(recovery) >= 1 and domain.name not in prim_domains:
                sr_ips = ', '.join([StorageRouter(guid).ip for guid in recovery])
                result_handler.warning('Domain {0} set as recovery domain on storagerouter(s) {1}, but nowhere as regular domain'.format(domain.name, sr_ips))
            else:
                result_handler.info('Domain {0} passed test, set {1} time(s) as regular domain'.format(domain.name, len(regular)))

            # Check for double usage
            intersection = set(recovery).intersection(regular)
            if intersection:
                sr_ips = ', '.join([StorageRouter(guid).ip for guid in intersection])
                result_handler.warning('Recovery domain {0} is also found to be a regular domain in {1}.'.format(domain.name, sr_ips))
Exemple #4
0
 def list(self, vdisk_guid=None):
     """
     Lists all available Domains
     :param vdisk_guid: Optional vDisk GUID. If passed in, only domains suitable for this vDisk will be returned
     :type vdisk_guid: str
     """
     domains = set()
     if vdisk_guid is not None:
         vdisk = VDisk(vdisk_guid)
         possible_storagerouter_guids = set(sd.storagerouter_guid for sd in vdisk.vpool.storagedrivers)
         storagerouter_guid = vdisk.storagerouter_guid
         for domain in DomainList.get_domains():
             domain_sr_guids = domain.storage_router_layout['regular']
             if storagerouter_guid in domain_sr_guids:
                 domain_sr_guids.remove(storagerouter_guid)
             if len(domain_sr_guids) > 0 and not set(domain_sr_guids).isdisjoint(possible_storagerouter_guids):
                 domains.add(domain)
         return list(domains)
     return DomainList.get_domains()
Exemple #5
0
    def get_domain_by_name(domain_name):
        """
        Fetch domain by name

        :param domain_name: correctly spelled name of a domain
        :type domain_name: str
        :return: domain object
        :rtype: ovs.dal.hybrids.domain.Domain
        """
        for domain in DomainList.get_domains():
            if domain.name == domain_name:
                return domain
Exemple #6
0
 def create(self, request, contents=None):
     """
     Creates a new Domain
     :param request: The raw request:
     :type request: Request
     :param contents: Requested contents (serializer hint)
     :type contents: str
     """
     contents = None if contents is None else contents.split(',')
     serializer = FullSerializer(Domain, contents=contents, instance=Domain(), data=request.DATA)
     domain = serializer.deserialize()
     current_domains = DomainList.get_by_name(domain.name)
     if len(current_domains) > 0:
         raise HttpNotAcceptableException(error_description='A Domain with the given name already exists',
                                          error='duplicate')
     domain.save()
     return domain
Exemple #7
0
 def list(self):
     """
     Lists all available Domains
     """
     return DomainList.get_domains()
Exemple #8
0
 def list(self):
     """
     Lists all available Domains
     """
     return DomainList.get_domains()