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
e49c9d26
Commit
e49c9d26
authored
10 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
build.py: making ovf generation more generic
parent
8b215af8
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
+16
-12
16 additions, 12 deletions
util/vm/build.py
with
16 additions
and
12 deletions
util/vm/build.py
+
16
−
12
View file @
e49c9d26
...
...
@@ -158,7 +158,7 @@ def depend():
run
(
'
sudo apt-get -y update
'
)
run
(
'
sudo apt-get install -y
'
'
kvm cloud-utils genisoimage qemu-kvm qemu-utils
'
'
e2fsprogs dnsmasq
'
'
e2fsprogs dnsmasq
curl
'
'
python-setuptools mtools zip
'
)
run
(
'
sudo easy_install pexpect
'
)
...
...
@@ -457,16 +457,16 @@ def boot( cow, kernel, initrd, logfile, memory=1024 ):
return
vm
def
login
(
vm
):
def
login
(
vm
,
user
=
'
mininet
'
,
password
=
'
mininet
'
):
"
Log in to vm (pexpect object)
"
log
(
'
* Waiting for login prompt
'
)
vm
.
expect
(
'
login:
'
)
log
(
'
* Logging in
'
)
vm
.
sendline
(
'
mininet
'
)
vm
.
sendline
(
user
)
log
(
'
* Waiting for password prompt
'
)
vm
.
expect
(
'
Password:
'
)
log
(
'
* Sending password
'
)
vm
.
sendline
(
'
mininet
'
)
vm
.
sendline
(
password
)
log
(
'
* Waiting for login...
'
)
...
...
@@ -628,9 +628,9 @@ def convert( cow, basename ):
<Description>The nat network</Description>
</Network>
</NetworkSection>
<VirtualSystem ovf:id=
"
Mininet-VM
"
>
<Info>
A Mininet Virtual Machine
(%(name)s)</Info>
<Name>
mininet-vm
</Name>
<VirtualSystem ovf:id=
"
%(vmname)s
"
>
<Info>
%(vminfo)s
(%(name)s)</Info>
<Name>
%(vmname)s
</Name>
<OperatingSystemSection ovf:id=
"
%(osid)d
"
>
<Info>The kind of installed guest operating system</Info>
<Description>%(osname)s</Description>
...
...
@@ -640,10 +640,10 @@ def convert( cow, basename ):
<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:ElementName>
%(cpus)s
virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>1</rasd:InstanceID>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>
1
</rasd:VirtualQuantity>
<rasd:VirtualQuantity>
%(cpus)s
</rasd:VirtualQuantity>
</Item>
<Item>
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
...
...
@@ -694,19 +694,23 @@ def convert( cow, basename ):
"""
def
generateOVF
(
name
,
osname
,
osid
,
diskname
,
disksize
,
mem
=
1024
):
def
generateOVF
(
name
,
osname
,
osid
,
diskname
,
disksize
,
mem
=
1024
,
cpus
=
1
,
vmname
=
'
Mininet-VM
'
,
vminfo
=
'
A Mininet Virtual Machine
'
):
"""
Generate (and return) OVF file
"
name.ovf
"
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
disksize: size of virtual disk in bytes
mem: VM memory size in MB
"""
mem: VM memory size in MB
cpus: # of virtual CPUs
vmname: Name for VM (default name when importing)
vmimfo: Brief description of VM for OVF
"""
ovf
=
name
+
'
.ovf
'
filesize
=
stat
(
diskname
)[
ST_SIZE
]
params
=
dict
(
osname
=
osname
,
osid
=
osid
,
diskname
=
diskname
,
filesize
=
filesize
,
disksize
=
disksize
,
name
=
name
,
mem
=
mem
)
mem
=
mem
,
cpus
=
cpus
,
vmname
=
vmname
,
vminfo
=
vminfo
)
xmltext
=
OVFTemplate
%
params
with
open
(
ovf
,
'
w+
'
)
as
f
:
f
.
write
(
xmltext
)
...
...
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