Skip to content
Snippets Groups Projects
Commit 64773773 authored by kasar's avatar kasar Committed by garciadeblas
Browse files

Moving vmware ovf converter tool from RO to Devops


Signed-off-by: default avatarkasar <pkasar@vmware.com>
parent 04976e09
No related branches found
No related tags found
No related merge requests found
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
---
SATA Controller:
ResourceType: 20
ResourceSubTypes: ["vmware.sata.ahci"]
IDE Controller:
ResourceType: 5
SCSI Controller:
ResourceType: 6
ResourceSubTypes: ["VirtualSCSI", "lsilogic", "buslogic", "lsilogicsas"]
\ No newline at end of file
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
---
'0': Unknown
'1': Other (32-bit)
'2': MACOS
'3': ATTUNIX
'4': DGUX
'5': DECNT
'6': Tru64 UNIX
'7': OpenVMS
'8': HPUX
'9': AIX
'10': MVS
'11': OS400
'12': OS/2
'13': JavaVM
'14': MSDOS
'15': WIN3x
'16': WIN95
'17': WIN98
'18': WINNT
'19': WINCE
'20': NCR3000
'21': NetWare
'22': OSF
'23': DC/OS
'24': Reliant UNIX
'25': SCO UnixWare
'26': SCO OpenServer
'27': Sequent
'28': IRIX
'29': Solaris
'30': SunOS
'31': U6000
'32': ASERIES
'33': HP NonStop OS
'34': HP NonStop OSS
'35': BS2000
'36': LINUX
'37': Lynx
'38': XENIX
'39': VM
'40': Interactive UNIX
'41': BSDUNIX
'42': FreeBSD
'43': NetBSD
'44': GNU Hurd
'45': OS9
'46': MACH Kernel
'47': Inferno
'48': QNX
'49': EPOC
'50': IxWorks
'51': VxWorks
'52': MiNT
'53': BeOS
'54': HP MPE
'55': NextStep
'56': PalmPilot
'57': Rhapsody
'58': Windows 2000
'59': Dedicated
'60': OS/390
'61': VSE
'62': TPF
'63': Windows (R) Me
'64': Caldera Open UNIX
'65': OpenBSD
'66': Not Applicable
'67': Windows XP
'68': z/OS
'69': Microsoft Windows Server 2003
'70': Microsoft Windows Server 2003 64-Bit
'71': Windows XP 64-Bit
'72': Windows XP Embedded
'73': Windows Vista
'74': Windows Vista 64-Bit
'75': Windows Embedded for Point of Service
'76': Microsoft Windows Server 2008
'77': Microsoft Windows Server 2008 64-Bit
'78': FreeBSD 64-Bit
'79': RedHat Enterprise Linux
'80': RedHat Enterprise Linux 64-Bit
'81': Solaris 64-Bit
'82': SUSE
'83': SUSE 64-Bit
'84': SLES
'85': SLES 64-Bit
'86': Novell OES
'87': Novell Linux Desktop
'88': Sun Java Desktop System
'89': Mandriva
'90': Mandriva 64-Bit
'91': TurboLinux
'92': TurboLinux 64-Bit
'93': Ubuntu
'94': Ubuntu 64-Bit
'95': Debian
'96': Debian 64-Bit
'97': Linux 2.4.x
'98': Linux 2.4.x 64-Bit
'99': Linux 2.6.x
'100': Linux 2.6.x 64-Bit
'101': Linux 64-Bit
'102': Other 64-Bit
'103': Microsoft Windows Server 2008 R2
'104': VMware ESXi
'105': Microsoft Windows 7
'106': CentOS 32-bit
'107': CentOS 64-bit
'108': Oracle Linux 32-bit
'109': Oracle Linux 64-bit
'110': eComStation 32-bitx
'111': Microsoft Windows Server 2011
'113': Microsoft Windows Server 2012
'114': Microsoft Windows 8
'115': Microsoft Windows 8 64-bit
'116': Microsoft Windows Server 2012 R2
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
import threading
import sys
class RepeatingTimer(threading._Timer):
""" Class to run thread parally """
def run(self):
""" Method to run thread """
while True:
self.finished.wait(self.interval)
if self.finished.is_set():
return
else:
self.function(*self.args, **self.kwargs)
class CommandProgressbar(object):
""" Class to show progressbar while waiting fro command output """
def __init__(self):
self.timer = None
def __show_progressbar(self):
"""
Private method to show progressbar while waiting for command to complete
Args : None
Return : None
"""
print '\b.',
sys.stdout.flush()
def start_progressbar(self):
"""
Method to start progressbar thread
Args : None
Return : None
"""
self.timer = RepeatingTimer(1.0, self.__show_progressbar)
self.timer.daemon = True # Allows program to exit if only the thread is alive
self.timer.start()
def stop_progressbar(self):
"""
Method to stop progressbar thread
Args : None
Return : None
"""
self.timer.cancel()
This diff is collapsed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
import argparse
from converter import OVFConverter , get_version
def execute_cli():
"""
Method to parse CLI arguments and execute commands accordingly
Args : None
Return : None
"""
parser = argparse.ArgumentParser(description='OVF converter to convert .qcow2 or raw image into OVF')
parser.add_argument("-v","--version", action="version", version=str(get_version()),
help="shows version of OVF Converter tool")
parser.add_argument("path", action="store",
help=" absolute path to source image which will get convert into ovf")
parser.add_argument("-o", "--output_location", action="store",
help="location where created OVF will be kept. This location "\
"should have write access. If not given file will get "\
"created at source location (optional)")
parser.add_argument("-n","--ovf_name", action="store",
help="name of output ovf file. If not given source image name will "\
" be used (optional)")
parser.add_argument("-m","--memory", action="store",
help="required memory for VM in MB (default 1 GB)(optional)")
parser.add_argument("-c","--cpu", action="store",
help="required number of virtual cpus for VM (default 1 cpu) (optional)")
parser.add_argument("-d","--disk", action="store",
help="required size of disk for VM in GB "\
"(default as in source disk img) (optional)")
parser.add_argument("-s","--osType", action="store",
help="required operating system type as specified "\
"in user document (default os type other 32 bit) (optional)")
parser.add_argument("-dc","--disk_Controller", action="store",
help="required disk controller type "\
" (default controller SCSI with lsilogicsas) "\
"(SATA, IDE, Paravirtual, Buslogic, Lsilogic, Lsilogicsas) (optional)")
args = parser.parse_args()
if args.path:
con = OVFConverter(args.path,
output_location=args.output_location,
output_ovf_name=args.ovf_name,
memory=args.memory,
cpu=args.cpu,
disk=args.disk,
os_type=args.osType,
disk_controller=args.disk_Controller,
)
print("#### Start OVF conversion ####")
con.create_ovf()
print("#### Completed OVF conversion ####")
if __name__ == "__main__":
execute_cli()
#!/usr/bin/env bash
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
echo '
#################################################################
##### Installing Require Packages #####
#################################################################'
# Paths to copy application files
Install_dir="/usr/local/bin"
App_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
App_CLI_path="${App_dir}/format_converter/ovf_converter_cli.py"
Install_CLI_path="${Install_dir}/OVF_converter/format_converter/ovf_converter_cli.py"
Logs_Folder="${Install_dir}/OVF_converter/logs"
Log_Path="${Install_dir}/OVF_converter/logs/ovf_converter.log"
#Function to install packages using apt-get
function install_packages(){
[ -x /usr/bin/apt-get ] && apt-get install -y $*
#check properly installed
for PACKAGE in $*
do
PACKAGE_INSTALLED="no"
[ -x /usr/bin/apt-get ] && dpkg -l $PACKAGE &>> /dev/null && PACKAGE_INSTALLED="yes"
if [ "$PACKAGE_INSTALLED" = "no" ]
then
echo "failed to install package '$PACKAGE'. Revise network connectivity and try again" >&2
exit 1
fi
done
}
apt-get update # To get the latest package lists
install_packages "libxml2-dev libxslt-dev python-dev python-pip python-lxml python-yaml"
install_packages "qemu-utils"
#apt-get install <package name> -y
#Move OVF Converter to usr/bin
cp -R "${App_dir}" "${Install_dir}"
#Create logs folder and file
mkdir "${Logs_Folder}"
touch "${Log_Path}"
#Change permission
chmod -R 777 $Install_CLI_path
chmod -R 777 $Log_Path
touch "${Install_dir}/ovf_converter"
echo "#!/bin/sh" > "${Install_dir}/ovf_converter"
echo "python ${Install_CLI_path} \"\$@\"" >> "${Install_dir}/ovf_converter"
chmod a+x "${Install_dir}/ovf_converter"
echo '
#################################################################
##### Done #####
#################################################################'
<?xml version="1.0" encoding="UTF-8"?>
<Envelope xmlns="http://schemas.dmtf.org/ovf/envelope/1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vmw="http://www.vmware.com/schema/ovf" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<References>
<File ovf:href="disk_img_filename.vmdk" ovf:id="file1" />
</References>
<DiskSection>
<Info>Virtual disk information</Info>
<Disk ovf:capacity="1" ovf:capacityAllocationUnits="byte" ovf:diskId="vmdisk1" ovf:fileRef="file1" ovf:format="http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized" ovf:populatedSize="0"/>
</DiskSection>
<NetworkSection>
<Info>List of logical networks used in the package</Info>
</NetworkSection>
<VirtualSystem ovf:id="vm">
<Info>A virtual machine</Info>
<Name>Virtual machine name</Name>
<OperatingSystemSection ovf:id="1">
<Info>The kind of installed guest operating system</Info>
<Description>Other (32-bit)</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
<System>
<vssd:ElementName>Virtual Hardware Family</vssd:ElementName>
<vssd:InstanceID>0</vssd:InstanceID>
<vssd:VirtualSystemIdentifier>Test1</vssd:VirtualSystemIdentifier>
<vssd:VirtualSystemType>vmx-7</vssd:VirtualSystemType>
</System>
<Item>
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>1 virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>1</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>1GB of memory</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>1024</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Description>SCSI Controller</rasd:Description>
<rasd:ElementName>scsiController0</rasd:ElementName>
<rasd:InstanceID>3</rasd:InstanceID>
<rasd:ResourceSubType>lsilogicsas</rasd:ResourceSubType>
<rasd:ResourceType>6</rasd:ResourceType>
</Item>
<Item>
<rasd:AddressOnParent>0</rasd:AddressOnParent>
<rasd:ElementName>disk0</rasd:ElementName>
<rasd:HostResource>ovf:/disk/vmdisk1</rasd:HostResource>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:Parent>3</rasd:Parent>
<rasd:ResourceType>17</rasd:ResourceType>
</Item>
<Item ovf:required="false">
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>video</rasd:ElementName>
<rasd:InstanceID>5</rasd:InstanceID>
<rasd:ResourceType>24</rasd:ResourceType>
</Item>
<Item ovf:required="false">
<rasd:AutomaticAllocation>false</rasd:AutomaticAllocation>
<rasd:ElementName>vmci</rasd:ElementName>
<rasd:InstanceID>6</rasd:InstanceID>
<rasd:ResourceSubType>vmware.vmci</rasd:ResourceSubType>
<rasd:ResourceType>1</rasd:ResourceType>
</Item>
<vmw:Config ovf:required="false" vmw:key="cpuHotAddEnabled" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.powerOffType" vmw:value="soft"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.resetType" vmw:value="soft"/>
<vmw:Config ovf:required="false" vmw:key="powerOpInfo.suspendType" vmw:value="soft"/>
<vmw:Config ovf:required="false" vmw:key="tools.syncTimeWithHost" vmw:value="true"/>
<vmw:Config ovf:required="false" vmw:key="tools.toolsUpgradePolicy" vmw:value="upgradeAtPowerCycle"/>
</VirtualHardwareSection>
</VirtualSystem>
</Envelope>
\ No newline at end of file
##
# Copyright 2016-2017 VMware Inc.
# This file is part of ETSI OSM
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
# For those usages not covered by the Apache License, Version 2.0 please
# contact: osslegalrouting@vmware.com
##
This README file explains how to use OVF Converter Tool to generate OVF file from .qcow2, .img (raw) disk images.
CONTENTS OF THIS FILE
=====================
This readme file contains the following sections:
o Introduction
o Tool Requirements
o Installation
o Usage
o Trouble shooting
o Release History
Introduction
==================
OVF Converter Tool is a Command Line Interface (CLI) basically designed to generate OVF files from disk image such as .qcow2, and .img (raw format) which are other than .vmdk.
Given a path to .qcow2 image this tool can generate .vmdk and .ovf files.
User can optionally specify name and location of ovf file. Also, one can use command line options to give disk size (GB), memory (MB), number of cpus, OS type, disk controller required for VM which will get deployed using generated OVF.
Generated OVF file can be used to deploy VM in Vmware vSphere or vCloud Director.
Note- Currently this tool supports only Ubuntu platform.
Tool Requirements
==================
This tool requires the following software package:
o apt-get package manager
o qemu-utils
o python 2.7
o python-lxml
o libxml2-dev
o libxslt-dev
o python-dev
o python-pip
Install.sh script in this folder will install all of these
software packages.
Installation
==================
User needs root privileges to install OVF Generator Tool.
Follow below setups for installation of OVF Converter Tool.
1. Make install.sh script in this folder executable by running below command
chmod a+x install.sh
2. Run install.sh script as:
./install.sh
Sample output -
#################################################################
##### Installing Require Packages #####
#################################################################
Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 1s (286 kB/s)
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
libxslt1-dev is already the newest version (1.1.28-2.1).
python-dev is already the newest version (2.7.11-1).
python-lxml is already the newest version (3.5.0-1build1).
libxml2-dev is already the newest version (2.9.3+dfsg1-1ubuntu0.1).
t version (1:2.5+dfsg-5ubuntu10.6).
0 upgraded, 0 newly installed, 0 to remove and 72 not upgraded.
#################################################################
##### Done #####
#################################################################
root@ubuntu:/home/vmware/OVF_converter#
root@ubuntu:/home/vmware/OVF_converter#
3. Now tool is installed at /usr/local/bin and available for all users
4. User can access commands of OVF Generator Tool as:
ovf_converter path [output location] [ovf name][memory][cpu][disk][ostype][disk_controller]
Usage
===================
o Get version of tool as:
Command - ovf_converter -v
Sample output -
root@ubuntu:/home/vmware/OVF_converter# ovf_converter -v
1.0 - Initial Realse
root@ubuntu:/home/vmware/OVF_converter#
o See all command line options of tool as:
Command - ovf_converter -h
Sample output -
root@ubuntu:/home/vmware/OVF_converter#
root@ubuntu:/home/vmware/OVF_converter# ovf_converter -h
Usage: ovf_converter_cli.py [-h] [-v] [-o OUTPUT_LOCATION] [-n OVF_NAME]
[-m MEMORY] [-c CPU] [-d DISK] [-s OSTYPE]
[-dc DISK_CONTROLLER]
path
OVF converter to convert .qcow2 or raw image into OVF
positional arguments:
path absolute path to source image which will get convert
into ovf
optional arguments:
-h, --help show this help message and exit
-v, --version shows version of OVF Converter tool
-o OUTPUT_LOCATION, --output_location OUTPUT_LOCATION
location where created OVF will be kept. This location
should have write access. If not given file will get
created at source location (optional)
-n OVF_NAME, --ovf_name OVF_NAME
name of output ovf file. If not given source image
name will be used (optional)
-m MEMORY, --memory MEMORY
required memory for VM in MB (default 1 GB)(optional)
-c CPU, --cpu CPU required number of virtual cpus for VM (default 1 cpu)
(optional)
-d DISK, --disk DISK required size of disk for VM in GB (default as
in source disk img) (optional)
-s OSTYPE, --osType OSTYPE
required operating system type as specified in user
document (default os type other 32 bit) (optional)
-dc DISK_CONTROLLER, --disk_Controller DISK_CONTROLLER
required disk controller type (default controller SCSI
with lsilogicsas) (SATA, IDE, Paravirtual, Buslogic,
lsilogic, lsilogicsas) (optional)
o Create OVF file from qcow2 or raw disk image as:
Command - ovf_converter /home/vmware/centos_ovf/CentOS-7-x86_64-GenericCloud-1503.qcow2 -n centos_qcow2.ovf -m 2048 -c 4 -d 10 -s "Centos 32-bit" -dc "SATA"
Sample output -
root@ubuntu:/home/vmware/OVF_converter# ovf_converter /home/vmware/centos_ovf/CentOS-7-x86_64-GenericCloud-1503.qcow2 -n centos_qcow2.ovf -m 2048 -c 4 -d 10
#### Start OVF conversion ####
Getting source image information
Converting source disk image to .vmdk
.....................................................
Creating OVF
Output OVF is at: /home/vmware/centos_ovf/centos_qcow2.ovf
#### Completed OVF conversion ####
Trouble shooting
==================
After installation of tool logs will get created at /usr/local/bin/OVF_converter/logs/ovf_converter.log file.
User can use these logs for debugging or trouble shooting.
Release History
===============
Version 1.0
-------------
Initial release
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment