Skip to content
This repository has been archived by the owner on Nov 9, 2020. It is now read-only.

Commit

Permalink
Made CLI return proper code to shell
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Sterin committed Jun 27, 2017
1 parent 76ebd29 commit 070ac37
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions esx_service/cli/vmdkops_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,24 @@
VOL_SIZE = 'size'
VOL_ALLOC = 'allocated'

# Return this to shell
# note: "1" is returned if a string is passed to sys.exit
CLI_ERR_ARGS_PARSE = 3
CLI_ERR_OPERATION_FAILURE = 2
CLI_SUCCESS = 0

def main():
'Main function for Admin CLI'
log_config.configure()
kv.init()
if not vmdk_ops.is_service_available():
sys.exit('Unable to connect to the host-agent on this host, ensure the ESXi host agent is running before retrying.')
sys.exit('Unable to connect to the host-agent on this host, ensure the ESXi host agent is running before retrying.')
args = parse_args()
if args:
args.func(args)
if not args:
sys.exit(CLI_ERR_ARGS_PARSE)
if args.func(args) != None:
sys.exit(CLI_ERR_OPERATION_FAILURE)
sys.exit(CLI_SUCCESS) # not really needed, putting here as an eye candy


def commands():
Expand Down

0 comments on commit 070ac37

Please sign in to comment.