Example #1
0
from utils.Connection import Connection
from utils.OnceLogging import log, init
from utils.XmlConverter import XmlConverter
from time import sleep
from utils.DBHelper import VMHelper
from utils.UUIDGenerator import createString
from utils.Tools import logNotFound

init("/var/log/xen/libvirt.log", "DEBUG", log)
conn = Connection.get_libvirt_connection()
UUIDString = '27167fe7-fc9d-47d5-9cd0-717106ef67be'
Name = 'vm'

def create(_id, name, memory, vcpu, mac, diskDir, isoDir, bridgeSrc):
    '''
    Author      : LHearen
    E-mail      : [email protected]
    Time        : 2015-12-16 09 : 43
    Description : Using limited parameters to create a VM and return its UUIDString;
    '''
    uuid = _id
    if len(uuid) < 5:
        uuid = createString()
    name = name if name else uuid
    global UUIDString
    UUIDString = uuid
    global Name
    Name = name
    hvm = {"loader": "/usr/lib/xen/boot/hvmloader"}
    hvm["boot"] = "cdrom"
    hvm["device_model"] = "/usr/lib/xen/bin/qemu-system-i386"
Example #2
0
E-mail      : [email protected]
Time        : 2015-12-21 10 : 41
Description : Used to test local VM operations
            including creation, deletion, shutoff
            reboot, start and template;
'''
import sys
sys.path.append('/home/lhearen/Server')
from utils.OnceLogging import log, init
from time import sleep
from base import VM
import unittest
import xml.dom.minidom as minidom
from utils import libvirt

init("/var/log/xen/unittest.log", "DEBUG", log)

class VMTest(unittest.TestCase):
    def setUp(self):
        self.name = 'vm4test'
        pass
        try:
            self.__createVM()
            self.__startVM()
        except:
            pass

    def tearDown(self):
        pass
        # try:
            # self.__deleteVM()