Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
vmdriver
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b0297698
authored
Sep 03, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
minor testing changes
parent
8455af9c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
16 deletions
+37
-16
sample.xml
+2
-2
test.py
+31
-13
vmcelery.py
+2
-0
vmdriver.py
+2
-1
No files found.
sample.xml
View file @
b0297698
<domain
type=
'
kvm
'
xmlns:qemu=
'http://libvirt.org/schemas/domain/qemu/1.0'
>
<domain
type=
'
test
'
xmlns:qemu=
'http://libvirt.org/schemas/domain/qemu/1.0'
>
<name>
one-2273
</name>
<name>
one-2273
</name>
<vcpu>
1
</vcpu>
<vcpu>
1
</vcpu>
<cputune>
<cputune>
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
</cputune>
</cputune>
<memory>
1048576
</memory>
<memory>
1048576
</memory>
<os>
<os>
<type
arch=
'
x86_64
'
>
hvm
</type>
<type
arch=
'
i686
'
>
hvm
</type>
<boot
dev=
'hd'
/>
<boot
dev=
'hd'
/>
</os>
</os>
<devices>
<devices>
...
...
test.py
View file @
b0297698
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
vm
import
vm
import
vmdriver
import
vmdriver
import
logging
#
import logging
from
nose.tools
import
raises
from
nose.tools
import
raises
graphics
=
{
'type'
:
'vnc'
,
'listen'
:
graphics
=
{
'type'
:
'vnc'
,
'listen'
:
...
@@ -15,19 +15,37 @@ testvm = vm.VMInstance(name="Thisthename", vcpu="1",
...
@@ -15,19 +15,37 @@ testvm = vm.VMInstance(name="Thisthename", vcpu="1",
network_list
=
[
b
],
network_list
=
[
b
],
graphics
=
graphics
)
graphics
=
graphics
)
netdict
=
{
'name'
:
"vm-88"
,
'mac'
:
"02:00:00:00:00:00"
}
diskdict
=
{
'name'
:
"asd"
,
'source'
:
'/asdasd/adasds/asd'
}
vmdict
=
{
'name'
:
"Thisthename"
,
'vcpu'
:
1
,
'memory_max'
:
2048
,
'disk_list'
:
[
diskdict
],
'network_list'
:
[
netdict
],
'graphics'
:
graphics
}
print
vm
.
VMNetwork
.
deserialize
(
netdict
)
.
dump_xml
()
print
vm
.
VMDisk
.
deserialize
(
diskdict
)
.
dump_xml
()
asd
=
vm
.
VMInstance
.
deserialize
(
vmdict
)
print
asd
.
dump_xml
()
# Enable logging
# Enable logging
logging
.
basicConfig
(
filename
=
'example.log'
,
level
=
logging
.
DEBUG
)
#
logging.basicConfig(filename='example.log', level=logging.DEBUG)
print
testvm
.
dump_xml
()
#
print testvm.dump_xml()
vm_driver
=
vmdriver
.
VMDriver
()
#
vm_driver = vmdriver.VMDriver()
vm_driver
.
connect
()
#
vm_driver.connect()
vm_driver
.
vm_define
(
testvm
)
#
vm_driver.vm_define(testvm)
print
'
%(name)
s defined.'
%
{
'name'
:
testvm
.
name
}
#
print '%(name)s defined.' % {'name': testvm.name}
for
i
in
vm_driver
.
list_domains
():
#
for i in vm_driver.list_domains():
print
i
#
print i
#vm_driver.vm_start(i)
#
#vm_driver.vm_start(i)
vm_driver
.
vm_undefine
(
i
)
#
vm_driver.vm_undefine(i)
print
'
%(name)
s undefined.'
%
{
'name'
:
i
}
#
print '%(name)s undefined.' % {'name': i}
vm_driver
.
disconnect
()
#
vm_driver.disconnect()
@raises
(
AttributeError
)
@raises
(
AttributeError
)
...
...
vmcelery.py
View file @
b0297698
...
@@ -5,6 +5,8 @@ import os
...
@@ -5,6 +5,8 @@ import os
HOSTNAME
=
gethostname
()
HOSTNAME
=
gethostname
()
lib_connection
=
None
celery
=
Celery
(
'vmcelery'
,
backend
=
'amqp'
,
celery
=
Celery
(
'vmcelery'
,
backend
=
'amqp'
,
broker
=
'amqp://cloud:test@10.9.1.31/vmdriver'
,
broker
=
'amqp://cloud:test@10.9.1.31/vmdriver'
,
include
=
[
'tasks'
])
include
=
[
'tasks'
])
...
...
vmdriver.py
View file @
b0297698
...
@@ -5,7 +5,7 @@ import logging
...
@@ -5,7 +5,7 @@ import logging
import
os
import
os
import
sys
import
sys
from
decorator
import
decorator
from
decorator
import
decorator
from
vmcelery
import
celery
from
vmcelery
import
celery
,
lib_connection
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
basename
(
__file__
)))
sys
.
path
.
append
(
os
.
path
.
dirname
(
os
.
path
.
basename
(
__file__
)))
...
@@ -63,6 +63,7 @@ def connect(connection_string='qemu:///system'):
...
@@ -63,6 +63,7 @@ def connect(connection_string='qemu:///system'):
connection
=
lib_connection
connection
=
lib_connection
logging
.
debug
(
"Using celery libvirt connection connection."
)
logging
.
debug
(
"Using celery libvirt connection connection."
)
@celery.task
@celery.task
def
disconnect
():
def
disconnect
():
'''Disconnect from the active libvirt daemon connection.
'''Disconnect from the active libvirt daemon connection.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment