<s> from __future__ import print_function <EOL> import atexit <EOL> import argparse <EOL> import getpass <EOL> from pyVim import connect <EOL> def get_args ( ) : <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = True , <EOL> action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = False , <EOL> action = '<STR_LIT:store>' , <EOL> help = "<STR_LIT>" , default = <NUM_LIT> ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = True , <EOL> action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = False , <EOL> action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = False , <EOL> action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT>' , <EOL> required = False , <EOL> action = '<STR_LIT:store>' , <EOL> help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> password = None <EOL> if args . password is None : <EOL> password = getpass . getpass ( <EOL> prompt = '<STR_LIT>' % <EOL> ( args . host , args . user ) ) <EOL> args = parser . parse_args ( ) <EOL> if password : <EOL> args . password = password <EOL> return args <EOL> args = get_args ( ) <EOL> si = connect . SmartConnect ( host = args . host , user = args . user , pwd = args . password , <EOL> port = args . port ) <EOL> atexit . register ( connect . Disconnect , si ) <EOL> search_index = si . content . searchIndex <EOL> vm = None <EOL> if args . uuid : <EOL> vm = search_index . FindByUuid ( None , args . uuid , True , True ) <EOL> elif args . ip : <EOL> vm = search_index . FindByIp ( None , args . ip , True ) <EOL> if not vm : <EOL> print ( "<STR_LIT>" ) <EOL> exit ( <NUM_LIT:1> ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> details = { '<STR_LIT:name>' : vm . summary . config . name , <EOL> '<STR_LIT>' : vm . summary . config . instanceUuid , <EOL> '<STR_LIT>' : vm . summary . config . uuid , <EOL> '<STR_LIT>' : vm . summary . config . vmPathName , <EOL> '<STR_LIT>' : vm . summary . config . guestId , <EOL> '<STR_LIT>' : vm . summary . config . guestFullName , <EOL> '<STR_LIT>' : vm . runtime . host . name , <EOL> '<STR_LIT>' : vm . runtime . bootTime } <EOL> for name , value in details . items ( ) : <EOL> print ( "<STR_LIT>" . format ( name , value , width = <NUM_LIT> , base = '<STR_LIT:s>' ) ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> for device in vm . config . hardware . device : <EOL> dev_details = { '<STR_LIT:key>' : device . key , <EOL> '<STR_LIT>' : device . deviceInfo . summary , <EOL> '<STR_LIT>' : type ( device ) . __name__ , <EOL> '<STR_LIT>' : type ( device . backing ) . __name__ } <EOL> print ( "<STR_LIT>" . format ( device . deviceInfo . label ) ) <EOL> print ( "<STR_LIT>" ) <EOL> for name , value in dev_details . items ( ) : <EOL> print ( "<STR_LIT>" . format ( name , value , <EOL> width = <NUM_LIT:15> , base = '<STR_LIT:s>' ) ) <EOL> if device . backing is None : <EOL> continue <EOL> if hasattr ( device . backing , '<STR_LIT>' ) : <EOL> datastore = device . backing . datastore <EOL> if datastore : <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" . format ( datastore . name ) ) <EOL> for host_mount in datastore . host : <EOL> host_system = host_mount . key <EOL> print ( "<STR_LIT>" . format ( host_system . name ) ) <EOL> print ( "<STR_LIT>" ) <EOL> summary = { '<STR_LIT>' : datastore . summary . capacity , <EOL> '<STR_LIT>' : datastore . summary . freeSpace , <EOL> '<STR_LIT>' : datastore . summary . type , <EOL> '<STR_LIT:url>' : datastore . summary . url } <EOL> for key , val in summary . items ( ) : <EOL> print ( "<STR_LIT>" . format ( key , val ) ) <EOL> print ( "<STR_LIT>" . format ( device . backing . fileName ) ) <EOL> print ( "<STR_LIT>" . format ( device . backing . backingObjectId ) ) <EOL> print ( "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" ) <EOL> exit ( ) </s>
