Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
dfd79bde
Commit
dfd79bde
authored
11 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Add OperatingSystemSection to OVF template
should facilitate importing 64-bit image
parent
317d6482
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
util/vm/build.py
+33
-10
33 additions, 10 deletions
util/vm/build.py
with
33 additions
and
10 deletions
util/vm/build.py
+
33
−
10
View file @
dfd79bde
...
@@ -91,6 +91,18 @@ def OSVersion( flavor ):
...
@@ -91,6 +91,18 @@ def OSVersion( flavor ):
urlbase
=
path
.
basename
(
isoURLs
.
get
(
flavor
,
'
unknown
'
)
)
urlbase
=
path
.
basename
(
isoURLs
.
get
(
flavor
,
'
unknown
'
)
)
return
path
.
splitext
(
urlbase
)[
0
]
return
path
.
splitext
(
urlbase
)[
0
]
def
OVFOSNameID
(
flavor
):
"
Return OVF-specified ( OS Name, ID ) for flavor
"
version
=
OSVersion
(
flavor
)
arch
=
archFor
(
flavor
)
if
'
ubuntu
'
in
version
:
map
=
{
'
i386
'
:
(
'
Ubuntu
'
,
93
),
'
x86_64
'
:
(
'
Ubuntu 64-bit
'
,
94
)
}
else
:
map
=
{
'
i386
'
:
(
'
Linux
'
,
36
),
'
x86_64
'
:
(
'
Linux 64-bit
'
,
101
)
}
osname
,
osid
=
map
[
arch
]
return
osname
,
osid
LogStartTime
=
time
()
LogStartTime
=
time
()
LogFile
=
None
LogFile
=
None
...
@@ -588,11 +600,11 @@ def convert( cow, basename ):
...
@@ -588,11 +600,11 @@ def convert( cow, basename ):
xmlns:vssd=
"
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData
"
xmlns:vssd=
"
http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData
"
xmlns:xsi=
"
http://www.w3.org/2001/XMLSchema-instance
"
>
xmlns:xsi=
"
http://www.w3.org/2001/XMLSchema-instance
"
>
<References>
<References>
<File ovf:href=
"
%s
"
ovf:id=
"
file1
"
ovf:size=
"
%d
"
/>
<File ovf:href=
"
%
(diskname)
s
"
ovf:id=
"
file1
"
ovf:size=
"
%
(filesize)
d
"
/>
</References>
</References>
<DiskSection>
<DiskSection>
<Info>Virtual disk information</Info>
<Info>Virtual disk information</Info>
<Disk ovf:capacity=
"
%d
"
ovf:capacityAllocationUnits=
"
byte
"
<Disk ovf:capacity=
"
%
(disksize)
d
"
ovf:capacityAllocationUnits=
"
byte
"
ovf:diskId=
"
vmdisk1
"
ovf:fileRef=
"
file1
"
ovf:diskId=
"
vmdisk1
"
ovf:fileRef=
"
file1
"
ovf:format=
"
http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized
"
/>
ovf:format=
"
http://www.vmware.com/interfaces/specifications/vmdk.html#streamOptimized
"
/>
</DiskSection>
</DiskSection>
...
@@ -603,8 +615,12 @@ def convert( cow, basename ):
...
@@ -603,8 +615,12 @@ def convert( cow, basename ):
</Network>
</Network>
</NetworkSection>
</NetworkSection>
<VirtualSystem ovf:id=
"
Mininet-VM
"
>
<VirtualSystem ovf:id=
"
Mininet-VM
"
>
<Info>A Mininet Virtual Machine (%s)</Info>
<Info>A Mininet Virtual Machine (%
(name)
s)</Info>
<Name>mininet-vm</Name>
<Name>mininet-vm</Name>
<OperatingSystemSection ovf:id=
"
%(osid)d
"
>
<Info>The kind of installed guest operating system</Info>
<Description>%(osname)s</Description>
</OperatingSystemSection>
<VirtualHardwareSection>
<VirtualHardwareSection>
<Info>Virtual hardware requirements</Info>
<Info>Virtual hardware requirements</Info>
<Item>
<Item>
...
@@ -618,10 +634,10 @@ def convert( cow, basename ):
...
@@ -618,10 +634,10 @@ def convert( cow, basename ):
<Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
<rasd:Description>Memory Size</rasd:Description>
<rasd:Description>Memory Size</rasd:Description>
<rasd:ElementName>%dMB of memory</rasd:ElementName>
<rasd:ElementName>%
(mem)
dMB of memory</rasd:ElementName>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:InstanceID>2</rasd:InstanceID>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:ResourceType>4</rasd:ResourceType>
<rasd:VirtualQuantity>%d</rasd:VirtualQuantity>
<rasd:VirtualQuantity>%
(mem)
d</rasd:VirtualQuantity>
</Item>
</Item>
<Item>
<Item>
<rasd:Address>0</rasd:Address>
<rasd:Address>0</rasd:Address>
...
@@ -664,16 +680,20 @@ def convert( cow, basename ):
...
@@ -664,16 +680,20 @@ def convert( cow, basename ):
"""
"""
def
generateOVF
(
name
,
diskname
,
disksize
,
mem
=
1024
):
def
generateOVF
(
name
,
osname
,
osid
,
diskname
,
disksize
,
mem
=
1024
):
"""
Generate (and return) OVF file
"
name.ovf
"
"""
Generate (and return) OVF file
"
name.ovf
"
name: root name of OVF file to generate
name: root name of OVF file to generate
osname: OS name for OVF (Ubuntu | Ubuntu 64-bit)
osid: OS ID for OVF (93 | 94 )
diskname: name of disk file
diskname: name of disk file
disksize: size of virtual disk in bytes
disksize: size of virtual disk in bytes
mem: VM memory size in MB
"""
mem: VM memory size in MB
"""
ovf
=
name
+
'
.ovf
'
ovf
=
name
+
'
.ovf
'
filesize
=
stat
(
diskname
)[
ST_SIZE
]
filesize
=
stat
(
diskname
)[
ST_SIZE
]
# OVFTemplate uses the memory size twice in a row
params
=
dict
(
osname
=
osname
,
osid
=
osid
,
diskname
=
diskname
,
xmltext
=
OVFTemplate
%
(
diskname
,
filesize
,
disksize
,
name
,
mem
,
mem
)
filesize
=
filesize
,
disksize
=
disksize
,
name
=
name
,
mem
=
mem
)
xmltext
=
OVFTemplate
%
params
with
open
(
ovf
,
'
w+
'
)
as
f
:
with
open
(
ovf
,
'
w+
'
)
as
f
:
f
.
write
(
xmltext
)
f
.
write
(
xmltext
)
return
ovf
return
ovf
...
@@ -723,13 +743,16 @@ def build( flavor='raring32server', tests=None, pre='', post='', memory=1024 ):
...
@@ -723,13 +743,16 @@ def build( flavor='raring32server', tests=None, pre='', post='', memory=1024 ):
vm
=
boot
(
volume
,
kernel
,
initrd
,
logfile
,
memory
=
memory
)
vm
=
boot
(
volume
,
kernel
,
initrd
,
logfile
,
memory
=
memory
)
version
=
interact
(
vm
,
tests
=
tests
,
pre
=
pre
,
post
=
post
)
version
=
interact
(
vm
,
tests
=
tests
,
pre
=
pre
,
post
=
post
)
size
=
qcow2size
(
volume
)
size
=
qcow2size
(
volume
)
vmdk
=
convert
(
volume
,
basename
=
'
mininet-vm-
'
+
archFor
(
flavor
)
)
arch
=
archFor
(
flavor
)
vmdk
=
convert
(
volume
,
basename
=
'
mininet-vm-
'
+
arch
)
if
not
SaveQCOW2
:
if
not
SaveQCOW2
:
log
(
'
* Removing qcow2 volume
'
,
volume
)
log
(
'
* Removing qcow2 volume
'
,
volume
)
os
.
remove
(
volume
)
os
.
remove
(
volume
)
log
(
'
* Converted VM image stored as
'
,
abspath
(
vmdk
)
)
log
(
'
* Converted VM image stored as
'
,
abspath
(
vmdk
)
)
ovfname
=
'
mininet-%s-%s-%s
'
%
(
version
,
ovfdate
,
OSVersion
(
flavor
)
)
ovfname
=
'
mininet-%s-%s-%s
'
%
(
version
,
ovfdate
,
OSVersion
(
flavor
)
)
ovf
=
generateOVF
(
diskname
=
vmdk
,
disksize
=
size
,
name
=
ovfname
)
osname
,
osid
=
OVFOSNameID
(
flavor
)
ovf
=
generateOVF
(
name
=
ovfname
,
osname
=
osname
,
osid
=
osid
,
diskname
=
vmdk
,
disksize
=
size
)
log
(
'
* Generated OVF descriptor file
'
,
ovf
)
log
(
'
* Generated OVF descriptor file
'
,
ovf
)
if
Zip
:
if
Zip
:
log
(
'
* Generating .zip file
'
)
log
(
'
* Generating .zip file
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment