示例#1
0
 def get_roles_from_disks(storagerouter_guid=None):
     """
     Fetch disk roles from all disks with optional storagerouter_ip
     :param storagerouter_guid: guid of a storage router
     :type storagerouter_guid: str
     :return: list of lists with roles
     :rtype: list > list
     """
     if not storagerouter_guid:
         return [partition.roles for disk in DiskList.get_disks() for partition in disk.partitions]
     else:
         return [partition.roles for disk in DiskList.get_disks()
                 if disk.storagerouter_guid == storagerouter_guid for partition in disk.partitions]
    def remove_disk(node_guid, device_alias):
        """
        Removes a disk
        :param node_guid: Guid of the node to remove a disk from
        :type node_guid: str
        :param device_alias: Alias of the device to remove  (eg: /dev/disk/by-path/pci-0000:03:00.0-sas-0x5000c29f4cf04566-lun-0)
        :type device_alias: str
        :return: None
        """
        asds = {}
        node = AlbaNode(node_guid)
        node_id = node.node_id
        device_id = device_alias.split('/')[-1]
        offline_node = False

        # Verify client connectivity
        try:
            _ = node.client.get_disks()
        except (requests.ConnectionError, requests.Timeout, InvalidCredentialsError):
            AlbaNodeController._logger.warning('Could not connect to node {0} to validate disks'.format(node.guid))
            offline_node = True

        # Retrieve ASD information for the ALBA Disk
        for backend in AlbaBackendList.get_albabackends():
            local_stack = backend.local_stack
            if node_id in local_stack and device_id in local_stack[node_id]:
                asds.update(local_stack[node_id][device_id]['asds'])
        for asd_info in asds.values():
            if (offline_node is False and asd_info.get('status') != 'available') or (offline_node is True and asd_info.get('status_detail') == 'nodedown'):
                AlbaNodeController._logger.error('Disk {0} has still non-available ASDs on node {1}'.format(device_alias, node.ip))
                raise RuntimeError('Disk {0} on ALBA node {1} has still some non-available ASDs'.format(device_alias, node_id))

        # Retrieve the Disk from the framework model matching the ALBA Disk
        disk_to_clear = None
        for disk in DiskList.get_disks():
            if device_alias in disk.aliases:
                disk_to_clear = disk
                break

        # Remove the ALBA Disk making use of the ASD Manager Client
        if offline_node is False:
            result = node.client.remove_disk(disk_id=device_id, partition_aliases=disk_to_clear.partitions[0].aliases if len(disk_to_clear.partitions) > 0 else [])
            if result['_success'] is False:
                raise RuntimeError('Error removing disk {0}: {1}'.format(device_alias, result['_error']))

        # Clean the model
        for model_disk in node.disks:
            if device_alias in model_disk.aliases:
                for osd in model_disk.osds:
                    osd.delete()
                model_disk.delete()
        if disk_to_clear is not None:
            for partition in disk_to_clear.partitions:
                partition.roles = []
                partition.mountpoint = None
                partition.save()
        node.invalidate_dynamics()
        if node.storagerouter is not None:
            DiskController.sync_with_reality(storagerouter_guid=node.storagerouter_guid)
示例#3
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
示例#4
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
示例#5
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     :param storagerouterguid: The StorageRouter to get the disks from
     :type storagerouterguid: guid
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
示例#6
0
 def list(self, storagerouterguid=None):
     """
     Overview of all disks
     :param storagerouterguid: The StorageRouter to get the disks from
     :type storagerouterguid: guid
     """
     if storagerouterguid is not None:
         storagerouter = StorageRouter(storagerouterguid)
         return storagerouter.disks
     return DiskList.get_disks()
    def get_disk_by_name(diskname, storagerouter_guid):
        """
        :param diskname: the name of the disk (EXAMPLE=sdb)
        :type diskname: str

        :param storagerouter_guid: the guid of the storagerouter
        :type storagerouter_guid: str

        :return: a physical disk with it properties
        :rtype: ovs.dal.hybrids.disk
        """

        # Get all disks with args.diskname for the specified storagerouter
        for d in DiskList.get_disks():
            if d.name == diskname and d.storagerouter_guid == storagerouter_guid:
                return d
 def get_disks():
     """
     Retrieve all physical disks
     :return: Data-object Disk list
     """
     return DiskList.get_disks()