Ejemplo n.º 1
0
 def add_disk(disk_id):
     """
     Add a disk
     :param disk_id: Identifier of the disk  (eg: '/dev/disk/by-path/pci-0000:03:00.0-sas-0x5000c29f4cf04566-lun-0' or 'pci-0000:03:00.0-sas-0x5000c29f4cf04566-lun-0')
     :type disk_id: str
     :return: Disk information about the newly added disk
     :rtype: dict
     """
     disk_data = DiskController.get_disk_data_by_alias(device_alias=disk_id)
     if disk_data['available'] is False:
         raise BadRequest('Disk already configured')
     alias = disk_data['aliases'][0]
     API._logger.info('Add disk {0}'.format(alias))
     with file_mutex('add_disk'), file_mutex('disk_{0}'.format(disk_id)):
         DiskController.prepare_disk(device_alias=alias)
     return DiskController.get_disk_data_by_alias(device_alias=alias)
Ejemplo n.º 2
0
 def asd_add(slot_id):
     # type: (str) -> None
     """
     Add an ASD to the slot specified
     :param slot_id: Identifier of the slot
     :type slot_id: str
     :return: None
     :rtype: NoneType
     """
     disk = DiskList.get_by_alias(slot_id)
     if disk.available is True:
         with file_mutex('add_disk'), file_mutex(
                 'disk_{0}'.format(slot_id)):
             DiskController.prepare_disk(disk=disk)
             disk = Disk(disk.id)
     with file_mutex('add_asd'):
         ASDController.create_asd(disk)
Ejemplo n.º 3
0
 def add_disk(disk_id):
     """
     Add a disk
     :param disk_id: Identifier of the disk
     :type disk_id: str
     """
     API._log('Add disk {0}'.format(disk_id))
     all_disks = DiskController.list_disks()
     if disk_id not in all_disks:
         raise BadRequest('Disk not available')
     if all_disks[disk_id]['available'] is False:
         raise BadRequest('Disk already configured')
     with file_mutex('add_disk'), file_mutex('disk_{0}'.format(disk_id)):
         DiskController.prepare_disk(disk_id)
     all_disks = DiskController.list_disks()
     if disk_id not in all_disks:
         raise BadRequest('Disk could not be added')
     return all_disks[disk_id]