Fixes OVF converter and upload
[osm/devops.git] / tools / OVF_converter / ovf_uploader_cli.py
1 ##
2 # Copyright 2019 VMware Inc.
3 # This file is part of ETSI OSM
4 # All Rights Reserved.
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # For those usages not covered by the Apache License, Version 2.0 please
19 # contact: osslegalrouting@vmware.com
20 ##
21
22 import argparse
23 from uploader import OVFUploader, get_version
24
25
26 def execute_cli():
27
28 """
29 Method to parse CLI arguments and execute commands accordingly
30 Args : None
31 Return : None
32 """
33 parser = argparse.ArgumentParser(description='Utility to upload an OVF package to vCD')
34
35 parser.add_argument("-v", "--version", action="version", version=str(get_version()),
36 help="shows version of vCD Uploader tool")
37
38 parser.add_argument("ovf_file", action="store",
39 help="filename of OVF file to upload to vCD")
40
41 parser.add_argument("-l", "--vcd_url", action="store",
42 required=True,
43 help="URL for vCD login (ie: https://vcd.local/")
44
45 parser.add_argument("-u", "--username", action="store",
46 required=True,
47 help="Username for vCD login")
48
49 parser.add_argument("-p", "--password", action="store",
50 required=True,
51 help="Password for vCD login")
52
53 parser.add_argument("-o", "--orgname", action="store",
54 required=True,
55 help="Organization name for vCD login")
56
57 args = parser.parse_args()
58
59 if args.ovf_file:
60 try:
61 uploader = OVFUploader(args.ovf_file,
62 vcd_url=args.vcd_url,
63 username=args.username,
64 password=args.password,
65 orgname=args.orgname)
66 uploader.make_catalog()
67 uploader.upload_ovf()
68 uploader.wait_for_task_completion()
69 except Exception as exp:
70 print(exp)
71 exit(1)
72
73
74 if __name__ == "__main__":
75 execute_cli()