Modified vcd unit tests as per latest pyvcloud changes
[osm/RO.git] / osm_ro / vmware_utils / OVF_converter / format_converter / ovf_converter_cli.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 ##
5 # Copyright 2016-2017 VMware Inc.
6 # This file is part of ETSI OSM
7 # All Rights Reserved.
8 #
9 # Licensed under the Apache License, Version 2.0 (the "License"); you may
10 # not use this file except in compliance with the License. You may obtain
11 # a copy of the License at
12 #
13 # http://www.apache.org/licenses/LICENSE-2.0
14 #
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18 # License for the specific language governing permissions and limitations
19 # under the License.
20 #
21 # For those usages not covered by the Apache License, Version 2.0 please
22 # contact: osslegalrouting@vmware.com
23 ##
24
25 import argparse
26 from converter import OVFConverter , get_version
27
28 def execute_cli():
29
30 """
31 Method to parse CLI arguments and execute commands accordingly
32 Args : None
33 Return : None
34 """
35 parser = argparse.ArgumentParser(description='OVF converter to convert .qcow2 or raw image into OVF')
36
37 parser.add_argument("-v","--version", action="version", version=str(get_version()),
38 help="shows version of OVF Converter tool")
39
40 parser.add_argument("path", action="store",
41 help=" absolute path to source image which will get convert into ovf")
42
43 parser.add_argument("-o", "--output_location", action="store",
44 help="location where created OVF will be kept. This location "\
45 "should have write access. If not given file will get "\
46 "created at source location (optional)")
47
48 parser.add_argument("-n","--ovf_name", action="store",
49 help="name of output ovf file. If not given source image name will "\
50 " be used (optional)")
51
52 parser.add_argument("-m","--memory", action="store",
53 help="required memory for VM in MB (default 1 GB)(optional)")
54
55 parser.add_argument("-c","--cpu", action="store",
56 help="required number of virtual cpus for VM (default 1 cpu) (optional)")
57
58 parser.add_argument("-d","--disk", action="store",
59 help="required size of disk for VM in GB "\
60 "(default as in source disk img) (optional)")
61
62 parser.add_argument("-s","--osType", action="store",
63 help="required operating system type as specified "\
64 "in user document (default os type other 32 bit) (optional)")
65
66 parser.add_argument("-dc","--disk_Controller", action="store",
67 help="required disk controller type "\
68 " (default controller SCSI with lsilogicsas) "\
69 "(SATA, IDE, Paravirtual, Buslogic, Lsilogic, Lsilogicsas) (optional)")
70
71 args = parser.parse_args()
72
73 if args.path:
74 con = OVFConverter(args.path,
75 output_location=args.output_location,
76 output_ovf_name=args.ovf_name,
77 memory=args.memory,
78 cpu=args.cpu,
79 disk=args.disk,
80 os_type=args.osType,
81 disk_controller=args.disk_Controller,
82 )
83
84 print("#### Start OVF conversion ####")
85 con.create_ovf()
86 print("#### Completed OVF conversion ####")
87
88
89 if __name__ == "__main__":
90 execute_cli()
91