Skip to content

Commit

Permalink
Merge pull request #373 from kedark3/rhv_disks_enhancement
Browse files Browse the repository at this point in the history
[RFR]Adding new method for listing disks on RHV
  • Loading branch information
mshriver authored Apr 9, 2019
2 parents 81340ea + 46c2d84 commit 790a806
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions wrapanapi/systems/rhevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,31 @@ def list_cluster(self, **kwargs):
cluster_list = self.api.system_service().clusters_service().list(**kwargs)
return [cluster.name for cluster in cluster_list]

def get_disks(self, name):
return self.api.system_service().disks_service().list(search=name)

def list_disks(self, status=None, **kwargs):
"""
List all of the disks present on RHV
Keywords:
status (optional) -- status of the disk.One of OK, LOCKED, ILLEGAL.
Returns:
list of disk names(str)
"""
disks_list = self.api.system_service().disks_service().list()
if status is None:
return [disk.name for disk in disks_list]
try:
return [
disk.name for disk in disks_list
if disk.status == types.DiskStatus.__members__[status.upper()]
]

except (KeyError, AttributeError): # catches the __members__ lookup on first loop iteration
raise ValueError('invalid status passed, only values "OK","LOCKED","ILLEGAL" allowed.')

def info(self):
# and we got nothing!
pass
Expand Down

0 comments on commit 790a806

Please sign in to comment.