从nova client的入口查看
cat /usr/bin/nova
cat /usr/bin/nova
#!/usr/bin/python
# PBR Generated from 'console_scripts'
import sys
from novaclient.shell import main
if __name__ == "__main__":
sys.exit(main())
其中导入了novaclient.shell这个文件中导入了main方法,进入novaclient.shell.py查看
def main():
try:
OpenStackComputeShell().main(map(strutils.safe_decode, sys.argv[1:]))
except Exception as e:
logger.debug(e, exc_info=1)
print("ERROR: %s" % strutils.safe_encode(six.text_type(e)),
file=sys.stderr)
sys.exit(1)
OpenStackComputeShell.main()
self.cs = client.Client(options.os_compute_api_version, os_username,
os_password, os_tenant_name, tenant_id=os_tenant_id,
auth_url=os_auth_url, insecure=insecure,
region_name=os_region_name, endpoint_type=endpoint_type,
extensions=self.extensions, service_type=service_type,
service_name=service_name, auth_system=os_auth_system,
auth_plugin=auth_plugin,
volume_service_name=volume_service_name,
timings=args.timings, bypass_url=bypass_url,
os_cache=os_cache, http_log_debug=options.debug,
cacert=cacert, timeout=timeout)
self.cs是从client中创建出的一个Client实例,进入novaclient.client.py查看这个实例的具体方法
def get_client_class(version):
version_map = {
'1.1': 'novaclient.v1_1.client.Client',
'2': 'novaclient.v1_1.client.Client',
'3': 'novaclient.v3.client.Client',
}
try:
client_path = version_map[str(version)]
except (KeyError, ValueError):
msg = "Invalid client versio