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):
|
def get_message_as_text(msg):
|
||||||
"""
|
"""
|
||||||
Creates displayable message in correct form from a message of
|
Creates displayable message in correct form from a message of
|
||||||
the API. There will be no translations.
|
the API. There will be no translations.
|
||||||
|
|
||||||
@param msg: Message returned by the API
|
@param msg: Message returned by the API
|
||||||
@type msg: LocalizableMessage
|
@type msg: LocalizableMessage
|
||||||
"""
|
"""
|
||||||
if not msg:
|
if not msg:
|
||||||
return None
|
return None
|
||||||
return msg.default_message % msg.args
|
return msg.default_message % msg.args
|
||||||
|
|
||||||
|
|
||||||
def get_defer_history_import_status(import_history):
|
def get_defer_history_import_status(import_history):
|
||||||
"""
|
"""
|
||||||
Gets the status of the Defer History Data Import and print it to
|
Gets the status of the Defer History Data Import and print it to
|
||||||
the stdout. It does not do exception handling.
|
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
|
Defer History Data Import Status: Running
|
||||||
Description: vCenter Server history import
|
Description: vCenter Server history import
|
||||||
Started: 2017-10-24 14:30:50.752000
|
Started: 2017-10-24 14:30:50.752000
|
||||||
Progress: 10%
|
Progress: 10%
|
||||||
Last progress message: Importing historical data...
|
Last progress message: Importing historical data...
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
@param import_history: object representing the vAPI Endpoint
|
@param import_history: object representing the vAPI Endpoint
|
||||||
@type import_history: deployment_client.ImportHistory
|
@type import_history: deployment_client.ImportHistory
|
||||||
|
|
||||||
@return: status of the Defer History Data Import
|
@return: status of the Defer History Data Import
|
||||||
@rtype: Status
|
@rtype: Status
|
||||||
"""
|
"""
|
||||||
result = import_history.get()
|
result = import_history.get()
|
||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
print('Could not acquire status of Defer History Data Import. '
|
print('Could not acquire status of Defer History Data Import. '
|
||||||
'Aborting.')
|
'Aborting.')
|
||||||
return Status.UNKNOWN
|
return Status.UNKNOWN
|
||||||
|
|
||||||
delimitar = '-' * 20
|
delimitar = '-' * 20
|
||||||
print(delimitar)
|
print(delimitar)
|
||||||
|
|
||||||
status = Status.parse(result.status)
|
status = Status.parse(result.status)
|
||||||
print('Defer History Data Import Status: {0}'.format(status))
|
print('Defer History Data Import Status: {0}'.format(status))
|
||||||
description = get_message_as_text(result.description)
|
description = get_message_as_text(result.description)
|
||||||
print('Description: {0}'.format(description))
|
print('Description: {0}'.format(description))
|
||||||
if result.start_time:
|
if result.start_time:
|
||||||
print('Started: {0}'.format(result.start_time))
|
print('Started: {0}'.format(result.start_time))
|
||||||
|
|
||||||
if result.end_time:
|
if result.end_time:
|
||||||
print('Finished: {0}'.format(result.end_time))
|
print('Finished: {0}'.format(result.end_time))
|
||||||
|
|
||||||
# Progress is reported as completed steps out of total and
|
# Progress is reported as completed steps out of total and
|
||||||
# need to be calculated at the clients side if want to be reported
|
# need to be calculated at the clients side if want to be reported
|
||||||
# as percentages
|
# as percentages
|
||||||
progress = result.progress
|
progress = result.progress
|
||||||
if progress:
|
if progress:
|
||||||
print('Progress: {0}%'.format(progress.completed))
|
print('Progress: {0}%'.format(progress.completed))
|
||||||
progress_message = get_message_as_text(progress.message)
|
progress_message = get_message_as_text(progress.message)
|
||||||
print('Last progress message: {0}'.format(progress_message))
|
print('Last progress message: {0}'.format(progress_message))
|
||||||
|
|
||||||
if result.error:
|
if result.error:
|
||||||
print('Error: {0}'.format(get_message_as_text(result.error)))
|
print('Error: {0}'.format(get_message_as_text(result.error)))
|
||||||
|
|
||||||
for msg in result.result.errors:
|
for msg in result.result.errors:
|
||||||
print('Error: {0}'.format(get_message_as_text(msg)))
|
print('Error: {0}'.format(get_message_as_text(msg)))
|
||||||
|
|
||||||
for msg in result.result.warnings:
|
for msg in result.result.warnings:
|
||||||
print('Warning: {0}'.format(get_message_as_text(msg)))
|
print('Warning: {0}'.format(get_message_as_text(msg)))
|
||||||
|
|
||||||
for msg in result.result.info:
|
for msg in result.result.info:
|
||||||
print('Message: {0}'.format(get_message_as_text(msg)))
|
print('Message: {0}'.format(get_message_as_text(msg)))
|
||||||
|
|
||||||
print(delimitar)
|
print(delimitar)
|
||||||
return status
|
return status
|
||||||
|
Loading…
Reference in New Issue
Block a user