2 # -*- coding: utf-8 -*-
5 # Copyright 2016-2017 VMware Inc.
6 # This file is part of ETSI OSM
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
13 # http://www.apache.org/licenses/LICENSE-2.0
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
21 # For those usages not covered by the Apache License, Version 2.0 please
22 # contact: osslegalrouting@vmware.com
28 from converter
import OVFConverter
, get_version
, OS_INFO_FILE_PATH
34 Method to parse CLI arguments and execute commands accordingly
39 with
open(OS_INFO_FILE_PATH
) as data_file
:
40 os_info
= yaml
.load(data_file
, Loader
=yaml
.SafeLoader
)
42 valid_os_strings
= "Valid values for osType are:\n"
43 for os_name
in os_info
.values():
44 valid_os_strings
+= os_name
+ ", "
46 valid_os_strings
= valid_os_strings
[:-2]
48 parser
= argparse
.ArgumentParser(description
='OVF converter to convert .qcow2 or raw image into OVF')
50 parser
.add_argument("-v", "--version", action
="version", version
=str(get_version()),
51 help="shows version of OVF Converter tool")
53 parser
.add_argument("path", action
="store",
54 help="absolute path to source image which will get converted into ovf")
56 parser
.add_argument("-o", "--output_location", action
="store",
57 help="location where created OVF will be kept. This location "
58 "should have write access. If not given file will get "
59 "created at source location (optional)")
61 parser
.add_argument("-n", "--ovf_name", action
="store",
62 help="name of output ovf file. If not given source image name will "
63 " be used (optional)")
65 parser
.add_argument("-m", "--memory", action
="store",
66 help="required memory for VM in MB (default 1 GB)(optional)")
68 parser
.add_argument("-c", "--cpu", action
="store",
69 help="required number of virtual cpus for VM (default 1 cpu) (optional)")
71 parser
.add_argument("-d", "--disk", action
="store",
72 help="required size of disk for VM in GB "
73 "(default as in source disk img) (optional)")
75 parser
.add_argument("-s", "--osType", action
="store",
76 help="required operating system type as specified "
77 "in user document (default os type other 32 bit) (optional) " + valid_os_strings
)
79 parser
.add_argument("-dc", "--disk_Controller", action
="store",
80 help="required disk controller type "
81 "(default controller SCSI with lsilogicsas) "
82 "(SATA, IDE, Paravirtual, Buslogic, Lsilogic, Lsilogicsas) (optional)")
84 parser
.add_argument("--cdrom", action
="store_true", default
=False,
85 help="whether to include a cd/dvd device (optional)")
87 parser
.add_argument("-hw", "--hwversion", action
="store", default
=14,
88 help="Virtual hardware version (default 14)")
90 args
= parser
.parse_args()
93 con
= OVFConverter(args
.path
,
94 output_location
=args
.output_location
,
95 output_ovf_name
=args
.ovf_name
,
100 disk_controller
=args
.disk_Controller
,
102 hwversion
=args
.hwversion
,
108 if __name__
== "__main__":