-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
{diskpool} Refine output and add new command #3490
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ def _value_from_path(each_item, path): | |
try: | ||
for part in path.split('.'): | ||
obj = obj.get(part, None) | ||
if isinstance(obj, list): | ||
obj = _process_array(obj) | ||
except AttributeError: | ||
obj = None | ||
return obj or ' ' | ||
|
@@ -35,8 +37,56 @@ def transform_disk_pool_list_output(result): | |
usable by the CLI and tools such as jpterm. """ | ||
return build_table_output(result, [ | ||
('Name', 'name'), | ||
('Availability Zones', 'availabilityZones'), | ||
('Resource Group', 'resourceGroup'), | ||
Comment on lines
-38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask why do we need to modify those value? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as service request There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
('Status', 'status'), | ||
('Location', 'location'), | ||
('Last Modified', 'systemData.lastModifiedAt') | ||
]) | ||
|
||
|
||
def transform_disk_pool_show_output(result): | ||
from collections import OrderedDict | ||
|
||
new_result = OrderedDict() | ||
new_result['Name'] = result.pop('name') | ||
new_result['Resource Group'] = result.pop('resourceGroup') | ||
new_result['Status'] = result.pop('status') | ||
new_result['Location'] = result.pop('location') | ||
new_result['Last Modified'] = result.get('systemData').get('lastModifiedAt', None) \ | ||
if result.get('systemData') else None | ||
return new_result | ||
|
||
|
||
def transform_disk_pool_iscsi_target_list_output(result): | ||
""" Transform to convert SDK output into a form that is more readily | ||
usable by the CLI and tools such as jpterm. """ | ||
return build_table_output(result, [ | ||
('Name', 'name'), | ||
('Acl Mode', 'aclMode'), | ||
('Endpoints', 'endpoints'), | ||
('Status', 'status'), | ||
('Provisioning State', 'provisioningState'), | ||
('Target Iqn', 'targetIqn') | ||
]) | ||
|
||
|
||
def _process_array(array): | ||
if array: | ||
item = ','.join(array) | ||
else: | ||
item = None | ||
return item | ||
|
||
|
||
def transform_disk_pool_iscsi_target_show_output(result): | ||
from collections import OrderedDict | ||
|
||
new_result = OrderedDict() | ||
new_result['Name'] = result.pop('name') | ||
new_result['Acl Mode'] = result.pop('aclMode') | ||
new_result['Endpoints'] = _process_array(result.pop('endpoints')) | ||
|
||
new_result['Status'] = result['status'] | ||
new_result['Provisioning State'] = result['provisioningState'] | ||
new_result['Target Iqn'] = result['targetIqn'] | ||
return new_result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is generated code