mirror of
https://github.com/vmware/vsphere-automation-sdk-python.git
synced 2024-11-21 17:29:59 -05:00
fix format for vc_import_history_common.py
Signed-off-by: Tianhao He <het@vmware.com>
This commit is contained in:
parent
2650d90c57
commit
7ad32f66fd
@ -45,79 +45,79 @@ STATUS_TRANSLATION_MATRIX = {
|
||||
|
||||
|
||||
def get_message_as_text(msg):
|
||||
"""
|
||||
Creates displayable message in correct form from a message of
|
||||
the API. There will be no translations.
|
||||
"""
|
||||
Creates displayable message in correct form from a message of
|
||||
the API. There will be no translations.
|
||||
|
||||
@param msg: Message returned by the API
|
||||
@type msg: LocalizableMessage
|
||||
"""
|
||||
if not msg:
|
||||
return None
|
||||
return msg.default_message % msg.args
|
||||
@param msg: Message returned by the API
|
||||
@type msg: LocalizableMessage
|
||||
"""
|
||||
if not msg:
|
||||
return None
|
||||
return msg.default_message % msg.args
|
||||
|
||||
|
||||
def get_defer_history_import_status(import_history):
|
||||
"""
|
||||
Gets the status of the Defer History Data Import and print it to
|
||||
the stdout. It does not do exception handling.
|
||||
"""
|
||||
Gets the status of the Defer History Data Import and print it to
|
||||
the stdout. It does not do exception handling.
|
||||
|
||||
Stdout example output for running status:
|
||||
Stdout example output for running status:
|
||||
|
||||
--------------------
|
||||
Defer History Data Import Status: Running
|
||||
Description: vCenter Server history import
|
||||
Started: 2017-10-24 14:30:50.752000
|
||||
Progress: 10%
|
||||
Last progress message: Importing historical data...
|
||||
--------------------
|
||||
--------------------
|
||||
Defer History Data Import Status: Running
|
||||
Description: vCenter Server history import
|
||||
Started: 2017-10-24 14:30:50.752000
|
||||
Progress: 10%
|
||||
Last progress message: Importing historical data...
|
||||
--------------------
|
||||
|
||||
@param import_history: object representing the vAPI Endpoint
|
||||
@type import_history: deployment_client.ImportHistory
|
||||
@param import_history: object representing the vAPI Endpoint
|
||||
@type import_history: deployment_client.ImportHistory
|
||||
|
||||
@return: status of the Defer History Data Import
|
||||
@rtype: Status
|
||||
"""
|
||||
result = import_history.get()
|
||||
@return: status of the Defer History Data Import
|
||||
@rtype: Status
|
||||
"""
|
||||
result = import_history.get()
|
||||
|
||||
if not result:
|
||||
print('Could not acquire status of Defer History Data Import. '
|
||||
'Aborting.')
|
||||
return Status.UNKNOWN
|
||||
if not result:
|
||||
print('Could not acquire status of Defer History Data Import. '
|
||||
'Aborting.')
|
||||
return Status.UNKNOWN
|
||||
|
||||
delimitar = '-' * 20
|
||||
print(delimitar)
|
||||
delimitar = '-' * 20
|
||||
print(delimitar)
|
||||
|
||||
status = Status.parse(result.status)
|
||||
print('Defer History Data Import Status: {0}'.format(status))
|
||||
description = get_message_as_text(result.description)
|
||||
print('Description: {0}'.format(description))
|
||||
if result.start_time:
|
||||
print('Started: {0}'.format(result.start_time))
|
||||
status = Status.parse(result.status)
|
||||
print('Defer History Data Import Status: {0}'.format(status))
|
||||
description = get_message_as_text(result.description)
|
||||
print('Description: {0}'.format(description))
|
||||
if result.start_time:
|
||||
print('Started: {0}'.format(result.start_time))
|
||||
|
||||
if result.end_time:
|
||||
print('Finished: {0}'.format(result.end_time))
|
||||
if result.end_time:
|
||||
print('Finished: {0}'.format(result.end_time))
|
||||
|
||||
# Progress is reported as completed steps out of total and
|
||||
# need to be calculated at the clients side if want to be reported
|
||||
# as percentages
|
||||
progress = result.progress
|
||||
if progress:
|
||||
print('Progress: {0}%'.format(progress.completed))
|
||||
progress_message = get_message_as_text(progress.message)
|
||||
print('Last progress message: {0}'.format(progress_message))
|
||||
# Progress is reported as completed steps out of total and
|
||||
# need to be calculated at the clients side if want to be reported
|
||||
# as percentages
|
||||
progress = result.progress
|
||||
if progress:
|
||||
print('Progress: {0}%'.format(progress.completed))
|
||||
progress_message = get_message_as_text(progress.message)
|
||||
print('Last progress message: {0}'.format(progress_message))
|
||||
|
||||
if result.error:
|
||||
print('Error: {0}'.format(get_message_as_text(result.error)))
|
||||
if result.error:
|
||||
print('Error: {0}'.format(get_message_as_text(result.error)))
|
||||
|
||||
for msg in result.result.errors:
|
||||
print('Error: {0}'.format(get_message_as_text(msg)))
|
||||
for msg in result.result.errors:
|
||||
print('Error: {0}'.format(get_message_as_text(msg)))
|
||||
|
||||
for msg in result.result.warnings:
|
||||
print('Warning: {0}'.format(get_message_as_text(msg)))
|
||||
for msg in result.result.warnings:
|
||||
print('Warning: {0}'.format(get_message_as_text(msg)))
|
||||
|
||||
for msg in result.result.info:
|
||||
print('Message: {0}'.format(get_message_as_text(msg)))
|
||||
for msg in result.result.info:
|
||||
print('Message: {0}'.format(get_message_as_text(msg)))
|
||||
|
||||
print(delimitar)
|
||||
return status
|
||||
print(delimitar)
|
||||
return status
|
||||
|
Loading…
Reference in New Issue
Block a user