def testName(self):
     server = sftpbackupstorage.SftpBackupStorageAgent()
     server.http_server.register_sync_uri('/testcallback', self.callback)
     
     server.http_server.start_in_thread()
     time.sleep(2)
     cmd = sftpbackupstorage.ConnectCmd()
     cmd.storagePath = "/tmp"
     #url = sftpbackupstorage._build_url_for_test([sftpbackupstorage.SftpBackupStorageAgent.CONNECT_PATH])
     url = 'http://localhost:7171%s' % sftpbackupstorage.SftpBackupStorageAgent.CONNECT_PATH
     print url
     rsp = http.json_dump_post(url, cmd)
     
     cmd = sftpbackupstorage.DownloadCmd()
     cmd.accountUuid = uuidhelper.uuid()
     cmd.bits = 64
     cmd.description = "Test"
     cmd.format = sftpbackupstorage.SftpBackupStorageAgent.IMAGE_TEMPLATE
     cmd.guestOsType = "rpm"
     cmd.hypervisorType = "KVM"
     cmd.imageUuid = uuidhelper.uuid()
     cmd.name = "test"
     cmd.timeout = 60
     cmd.url = "http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-6.noarch.rpm"
     cmd.urlScheme = "http"
     url = 'http://localhost:7171%s' % sftpbackupstorage.SftpBackupStorageAgent.DOWNLOAD_IMAGE_PATH
     print url
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     print "post back"
     time.sleep(20)
     
     server.http_server.stop()
Exemple #2
0
 def testName(self):
     cmd = vm_plugin.StartVmCmd()
     cmd.region = 'cn-beijing'
     cmd.access_key_id = 'LTAIrgvAPlmGRPQY'
     cmd.access_key_secret = 'oAIuo2xWVqnWOmrsoXLcLEFYvNCRr0'
     cmd.vmInstanceUuid = uuidhelper.uuid()
     cmd.name = 'test'
     cmd.image = uuidhelper.uuid()
     cmd.size = "ecs.t1.xsmall"
     cmd.auth = "Test1234"
     cmd.ex_security_group_id = "sg-2ze56hvvjveewzm12jar"
     cmd.ex_description = 'PayByTraffic'
     cmd.ex_internet_charge_type = None
     cmd.ex_internet_max_bandwidth_out = 1
     cmd.ex_internet_max_bandwidth_in = None
     cmd.ex_hostname = None
     cmd.ex_io_optimized = None
     cmd.ex_system_disk = {}
     cmd.ex_data_disks = {}
     cmd.ex_vswitch_id = None
     cmd.ex_private_ip_address = None
     cmd.ex_client_token = None
     print 'xxxxxxxxxxxxxxxxxxx %s' % cmd.name
     url = ecsagent._build_url_for_test(
         [vm_plugin.VmPlugin().ALIYUN_START_VM_PATH])
     rsp = http.json_dump_post(url,
                               cmd,
                               headers={
                                   http.TASK_UUID: uuidhelper.uuid(),
                                   http.CALLBACK_URI: self.CALLBACK_URL
                               })
     time.sleep(30)
     self.service.stop()
Exemple #3
0
 def testName(self):
     cmd = vm_plugin.StartVmCmd()
     cmd.vmName = 'test'
     cmd.vmUuid = uuidhelper.uuid()
     self.uuid = cmd.vmUuid
     cmd.cpuNum = 2
     cmd.cpuSpeed = 3000
     cmd.memory = 3221225472
     cmd.rootVolumePath = '/home/root/images/volumes/kvmubuntu.img'
     cmd.bootDev = 'hd'
     cmd.timeout = 30
     nic = vm_plugin.NicTO()
     nic.mac = 'fa:33:f8:5f:00:00'
     nic.bridgeName = 'virbr0'
     nic.deviceId = 0
     cmd.nics.append(nic)
     url = aliyunagent._build_url_for_test([vm_plugin.KVM_START_VM_PATH])
     rsp = http.json_dump_post(url,
                               cmd,
                               headers={
                                   http.TASK_UUID: uuidhelper.uuid(),
                                   http.CALLBACK_URI: self.CALLBACK_URL
                               })
     time.sleep(30)
     self.service.stop()
 def testName(self):
     url = aliyunagent._build_url_for_test([
         virtualrouter_plugin.VirtualRouterPlugin.
         VR_KVM_CREATE_BOOTSTRAP_ISO_PATH
     ])
     info = virtualrouter_plugin.BootstrapIsoInfo()
     info.managementNicGateway = "192.168.1.1"
     info.managementNicIp = "192.168.1.10"
     info.managementNicMac = "50:E5:49:C9:65:A3"
     info.managementNicNetmask = "255.255.255.0"
     cmd = virtualrouter_plugin.CreateVritualRouterBootstrapIsoCmd()
     cmd.isoInfo = info
     cmd.isoPath = '/tmp/vr.iso'
     rsp = http.json_dump_post(url,
                               cmd,
                               headers={
                                   http.TASK_UUID: uuidhelper.uuid(),
                                   http.CALLBACK_URI: self.CALLBACK_URL
                               })
     time.sleep(2)
     cmd = virtualrouter_plugin.DeleteVirtualRouterBootstrapIsoCmd()
     cmd.isoPath = '/tmp/vr.iso'
     url = aliyunagent._build_url_for_test([
         virtualrouter_plugin.VirtualRouterPlugin.
         VR_KVM_DELETE_BOOTSTRAP_ISO_PATH
     ])
     rsp = http.json_dump_post(url,
                               cmd,
                               headers={
                                   http.TASK_UUID: uuidhelper.uuid(),
                                   http.CALLBACK_URI: self.CALLBACK_URL
                               })
     time.sleep(2)
     self.service.stop()
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.CreateEmptyVolumeCmd()
     cmd.accountUuid = uuidhelper.uuid()
     cmd.hypervisorType = 'KVM'
     cmd.installUrl = '/tmp/emptyvolume.qcow2'
     cmd.name = 'testEmptyVolume'
     cmd.size = '1410400256'
     cmd.uuid = uuidhelper.uuid()
     url = kvmagent._build_url_for_test([nfs_primarystorage_plugin.CREATE_EMPTY_VOLUME_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(5)
     self.service.stop()
     linux.umount_by_url(self.NFS_URL)
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.CreateEmptyVolumeCmd()
     cmd.accountUuid = uuidhelper.uuid()
     cmd.hypervisorType = 'KVM'
     cmd.installUrl = '/tmp/emptyvolume.qcow2'
     cmd.name = 'testEmptyVolume'
     cmd.size = '1410400256'
     cmd.uuid = uuidhelper.uuid()
     url = aliyunagent._build_url_for_test([nfs_primarystorage_plugin.CREATE_EMPTY_VOLUME_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(5)
     self.service.stop()
     linux.umount_by_url(self.NFS_URL)
Exemple #7
0
        def from_file(tokens):
            file_path = tokens[1]
            file_path = os.path.abspath(file_path)
            if not os.path.exists(file_path):
                self.print_error('cannot find file %s' % file_path)
                return
            
            with open(file_path, 'r') as fd:
                text = fd.read()
                
                path, json_str = text.split('>>', 1)
                path = path.strip(' \t\n\r')
                json_str = json_str.strip(' \t\n\r')

            args = {}
            if len(tokens) > 2:
                for token in tokens[2:]:
                    k, v = token.split('=', 1)
                    args[k] = v
            
            tmp = string.Template(json_str)
            json_str = tmp.substitute(args)
            url = 'http://%s:%s/%s/' % (self.agent_ip, self.agent_port, path)
            callback_url = 'http://%s:%s/%s/' % (self.cip, 10086, 'result')
            rsp = http.json_post(url, json_str, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:callback_url})
            print rsp
    def offline_merge_snapshots(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = OfflineMergeSnapshotRsp()
        src_abs_path = translate_absolute_path_from_install_path(cmd.srcPath)
        dst_abs_path = translate_absolute_path_from_install_path(cmd.destPath)

        with lvm.RecursiveOperateLv(src_abs_path, shared=True):
            virtual_size = linux.qcow2_virtualsize(src_abs_path)
            if not lvm.lv_exists(dst_abs_path):
                lvm.create_lv_from_absolute_path(
                    dst_abs_path, virtual_size,
                    "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
            with lvm.RecursiveOperateLv(dst_abs_path, shared=False):
                if not cmd.fullRebase:
                    linux.qcow2_rebase(src_abs_path, dst_abs_path)
                else:
                    tmp_lv = 'tmp_%s' % uuidhelper.uuid()
                    tmp_abs_path = os.path.join(os.path.dirname(dst_abs_path),
                                                tmp_lv)
                    tmp_abs_path = os.path.join(os.path.dirname(dst_abs_path),
                                                tmp_lv)
                    logger.debug("creating temp lv %s" % tmp_abs_path)
                    lvm.create_lv_from_absolute_path(
                        tmp_abs_path, virtual_size,
                        "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
                    with lvm.OperateLv(tmp_abs_path,
                                       shared=False,
                                       delete_when_exception=True):
                        linux.create_template(dst_abs_path, tmp_abs_path)
                        lvm.lv_rename(tmp_abs_path,
                                      dst_abs_path,
                                      overwrite=True)

        rsp.totalCapacity, rsp.availableCapacity = lvm.get_vg_size(cmd.vgUuid)
        return jsonobject.dumps(rsp)
Exemple #9
0
        def from_file(tokens):
            file_path = tokens[1]
            file_path = os.path.abspath(file_path)
            if not os.path.exists(file_path):
                self.print_error('cannot find file %s' % file_path)
                return

            with open(file_path, 'r') as fd:
                text = fd.read()

                path, json_str = text.split('>>', 1)
                path = path.strip(' \t\n\r')
                json_str = json_str.strip(' \t\n\r')

            args = {}
            if len(tokens) > 2:
                for token in tokens[2:]:
                    k, v = token.split('=', 1)
                    args[k] = v

            tmp = string.Template(json_str)
            json_str = tmp.substitute(args)
            url = 'http://%s:%s/%s/' % (self.agent_ip, self.agent_port, path)
            callback_url = 'http://%s:%s/%s/' % (self.cip, 10086, 'result')
            rsp = http.json_post(url,
                                 json_str,
                                 headers={
                                     http.TASK_UUID: uuidhelper.uuid(),
                                     http.CALLBACK_URI: callback_url
                                 })
            print rsp
Exemple #10
0
    def testName(self):
        cmd = dnsmasq.AddDhcpEntryCmd()

        nic = DhcpInfo()
        nic.ip = "10.0.0.10"
        nic.mac = "50:e5:49:c9:65:a3"
        nic.gateway = "10.0.0.1"
        nic.netmask = "255.255.255.0"
        nic.hostname = 'host1'
        nic.dns = ['8.8.8.8', '75.75.75.75']

        nic1 = DhcpInfo()
        nic1.ip = "10.0.0.13"
        nic1.mac = "50:e5:49:c9:65:b0"
        nic1.netmask = "255.255.255.0"
        nic1.hostname = 'host2'
        nic1.dns = ['8.8.8.8', '75.75.75.75']

        nic2 = DhcpInfo()
        nic2.ip = "10.0.0.12"
        nic2.mac = "50:e5:49:c9:65:b1"
        nic2.netmask = "255.255.255.0"
        nic2.hostname = 'host3'

        cmd.dhcpEntries = [nic, nic1, nic2]
        cmd.rebuild = True

        rsp = http.json_dump_post('http://localhost:7272/adddhcp',
                                  cmd,
                                  headers={
                                      http.TASK_UUID: uuidhelper.uuid(),
                                      http.CALLBACK_URI: self.CALLBACK_URL
                                  })
        time.sleep(10)
        self.service.stop()
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.DownloadImageToCacheFromSftpBackupStorageCmd(
     )
     p = os.path.expanduser('~/.ssh/id_rsa')
     with open(p, 'r') as fd:
         sshkey = fd.read()
         cmd.installUrl = '/tmp/test.qcow2'
         cmd.sftpBackupStorageHostName = "root@localhost"
         cmd.sftpBackupStorageSshKey = sshkey
         cmd.templatePath = '/home/root/test.qcow2'
         cmd.timeout = 300
         url = aliyunagent._build_url_for_test([
             nfs_primarystorage_plugin.
             DOWNLOAD_IMAGE_FROM_SFTP_BACKUP_STORAGE_PATH
         ])
         rsp = http.json_dump_post(url,
                                   cmd,
                                   headers={
                                       http.TASK_UUID: uuidhelper.uuid(),
                                       http.CALLBACK_URI: self.CALLBACK_URL
                                   })
         time.sleep(10)
         self.service.stop()
         linux.umount_by_url(self.NFS_URL)
Exemple #12
0
    def ping(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        if cmd.uuid not in self.mount_path.keys():
            self.mount_path[cmd.uuid] = cmd.mountPath

        mount_path = self.mount_path[cmd.uuid]
        # if nfs service stop, os.path.isdir will hung
        if not linux.timeout_isdir(mount_path) or not linux.is_mounted(
                path=mount_path):
            raise Exception(
                'the mount path[%s] of the nfs primary storage[uuid:%s] is not existing'
                % (mount_path, cmd.uuid))

        test_file = os.path.join(mount_path,
                                 '%s-ping-test-file' % uuidhelper.uuid())
        touch = shell.ShellCmd('timeout 60 touch %s' % test_file)
        touch(False)
        if touch.return_code == 124:
            raise Exception(
                'unable to access the mount path[%s] of the nfs primary storage[uuid:%s] in 60s, timeout'
                % (mount_path, cmd.uuid))
        elif touch.return_code != 0:
            touch.raise_error()

        linux.rm_file_force(test_file)
        return jsonobject.dumps(NfsResponse())
    def offline_merge_snapshots(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = OfflineMergeSnapshotRsp()
        src_abs_path = translate_absolute_path_from_install_path(cmd.srcPath)
        dst_abs_path = translate_absolute_path_from_install_path(cmd.destPath)

        with lvm.RecursiveOperateLv(src_abs_path, shared=True):
            virtual_size = linux.qcow2_virtualsize(src_abs_path)
            if not lvm.lv_exists(dst_abs_path):
                lvm.create_lv_from_absolute_path(dst_abs_path, virtual_size,
                                                 "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
            with lvm.RecursiveOperateLv(dst_abs_path, shared=False):
                if not cmd.fullRebase:
                    linux.qcow2_rebase(src_abs_path, dst_abs_path)
                else:
                    tmp_lv = 'tmp_%s' % uuidhelper.uuid()
                    tmp_abs_path = os.path.join(os.path.dirname(dst_abs_path), tmp_lv)
                    tmp_abs_path = os.path.join(os.path.dirname(dst_abs_path), tmp_lv)
                    logger.debug("creating temp lv %s" % tmp_abs_path)
                    lvm.create_lv_from_absolute_path(tmp_abs_path, virtual_size,
                                                     "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
                    with lvm.OperateLv(tmp_abs_path, shared=False, delete_when_exception=True):
                        linux.create_template(dst_abs_path, tmp_abs_path)
                        lvm.lv_rename(tmp_abs_path, dst_abs_path, overwrite=True)

        rsp.totalCapacity, rsp.availableCapacity = lvm.get_vg_size(cmd.vgUuid)
        return jsonobject.dumps(rsp)
    def revert_volume_from_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotRsp()
        snapshot_abs_path = translate_absolute_path_from_install_path(
            cmd.snapshotInstallPath)
        qcow2_options = self.calc_qcow2_option(self, cmd.qcow2Options, True,
                                               cmd.provisioning)
        new_volume_path = cmd.installPath
        if new_volume_path is None or new_volume_path == "":
            new_volume_path = "/dev/%s/%s" % (cmd.vgUuid, uuidhelper.uuid())
        else:
            new_volume_path = translate_absolute_path_from_install_path(
                new_volume_path)

        with lvm.RecursiveOperateLv(snapshot_abs_path, shared=True):
            size = linux.qcow2_virtualsize(snapshot_abs_path)

            lvm.create_lv_from_cmd(
                new_volume_path, size, cmd,
                "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
            with lvm.OperateLv(new_volume_path,
                               shared=False,
                               delete_when_exception=True):
                linux.qcow2_clone_with_option(snapshot_abs_path,
                                              new_volume_path, qcow2_options)
                size = linux.qcow2_virtualsize(new_volume_path)

        rsp.newVolumeInstallPath = new_volume_path
        rsp.size = size
        return jsonobject.dumps(rsp)
 def test_mount_failure(self):
     cmd = nfs_primarystorage_plugin.MountCmd()
     cmd.url = 'this_is_a_wrong_path'
     cmd.mountPath = os.path.join('/mnt', uuidhelper.uuid())
     callurl = aliyunagent._build_url_for_test([nfs_primarystorage_plugin.MOUNT_PATH])
     ret = http.json_dump_post(callurl, cmd)
     rsp = jsonobject.loads(ret)
     self.assertFalse(rsp.success, rsp.error)
 def callback(self, req):
     rsp = jsonobject.loads(req[http.REQUEST_BODY])
     print jsonobject.dumps(rsp)
     
     cmd = vm_plugin.DestroyVmCmd()
     cmd.uuid = self.uuid
     url = kvmagent._build_url_for_test([vm_plugin.KVM_DESTROY_VM_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL2})
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.GetCapacityCmd()
     url = kvmagent._build_url_for_test([nfs_primarystorage_plugin.GET_CAPACITY_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(5)
     self.service.stop()
     linux.umount_by_url(self.NFS_URL)
 def test_mount_failure(self):
     cmd = nfs_primarystorage_plugin.MountCmd()
     cmd.url = 'this_is_a_wrong_path'
     cmd.mountPath = os.path.join('/mnt', uuidhelper.uuid())
     callurl = kvmagent._build_url_for_test([nfs_primarystorage_plugin.MOUNT_PATH])
     ret = http.json_dump_post(callurl, cmd)
     rsp = jsonobject.loads(ret)
     self.assertFalse(rsp.success, rsp.error)
Exemple #19
0
 def take_delta_snapshot_by_qemu_img_convert(previous_install_path,
                                             install_path):
     new_volume_path = os.path.join(
         os.path.dirname(install_path),
         '{0}.qcow2'.format(uuidhelper.uuid()))
     makedir_if_need(new_volume_path)
     linux.qcow2_clone(previous_install_path, new_volume_path)
     return previous_install_path, new_volume_path
 def mount(self):
     cmd = nfs_primarystorage_plugin.MountCmd()
     cmd.url = self.NFS_URL
     cmd.mountPath = os.path.join('/mnt', uuidhelper.uuid())
     callurl = kvmagent._build_url_for_test([nfs_primarystorage_plugin.MOUNT_PATH])
     ret = http.json_dump_post(callurl, cmd)
     rsp = jsonobject.loads(ret)
     self.assertTrue(rsp.success, rsp.error)
     self.assertTrue(linux.is_mounted(cmd.url, cmd.mountPath))
 def testName(self):
     url = kvmagent._build_url_for_test([virtualrouter_plugin.VirtualRouterPlugin.VR_KVM_CREATE_BOOTSTRAP_ISO_PATH])
     info = virtualrouter_plugin.BootstrapIsoInfo()
     info.managementNicGateway = "192.168.1.1"
     info.managementNicIp = "192.168.1.10"
     info.managementNicMac = "50:E5:49:C9:65:A3"
     info.managementNicNetmask = "255.255.255.0"
     cmd = virtualrouter_plugin.CreateVritualRouterBootstrapIsoCmd()
     cmd.isoInfo = info
     cmd.isoPath = '/tmp/vr.iso'
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(2)
     cmd = virtualrouter_plugin.DeleteVirtualRouterBootstrapIsoCmd()
     cmd.isoPath = '/tmp/vr.iso'
     url = kvmagent._build_url_for_test([virtualrouter_plugin.VirtualRouterPlugin.VR_KVM_DELETE_BOOTSTRAP_ISO_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(2)
     self.service.stop()
 def testName(self):
     url = kvmagent._build_url_for_test([network_plugin.KVM_REALIZE_L2NOVLAN_NETWORK_PATH])
     logger.debug('calling %s' % url)
     cmd = network_plugin.CreateBridgeCmd()
     cmd.physicalInterfaceName = 'eth0'
     cmd.bridgeName = 'br_eth0'
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(2)
     self.service.stop()
 def callback(self, req):
     rsp = jsonobject.loads(req[http.REQUEST_BODY])
     print jsonobject.dumps(rsp)
     
     cmd = vm_plugin.RebootVmCmd()
     cmd.uuid = self.uuid
     cmd.timeout = 30
     url = kvmagent._build_url_for_test([vm_plugin.KVM_REBOOT_VM_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL2})
 def callback(self, req):
     rsp = jsonobject.loads(req[http.REQUEST_BODY])
     print jsonobject.dumps(rsp)
     
     cmd = vm_plugin.StopVmCmd()
     cmd.uuid = self.uuid
     cmd.timeout = 30
     url = aliyunagent._build_url_for_test([vm_plugin.KVM_STOP_VM_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL2})
    def revert_volume_from_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotRsp()

        install_path = cmd.snapshotInstallPath
        new_volume_path = os.path.join(os.path.dirname(install_path),
                                       '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone(install_path, new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        return jsonobject.dumps(rsp)
 def testName(self):
     cmd = vm_plugin.StartVmCmd()
     cmd.vmName = 'test'
     cmd.vmUuid = uuidhelper.uuid()
     cmd.cpuNum = 2
     cmd.cpuSpeed = 3000
     cmd.memory = 3221225472
     cmd.rootVolumePath = '/home/root/images/volumes/kvmubuntu.img'
     cmd.bootDev = 'hd'
     cmd.timeout = 30
     nic = vm_plugin.NicTO()
     nic.mac = 'fa:33:f8:5f:00:00'
     nic.bridgeName = 'virbr0'
     nic.deviceId = 0
     cmd.nics.append(nic)
     print 'xxxxxxxxxxxxxxxxxxx %s' % cmd.vmUuid
     url = kvmagent._build_url_for_test([vm_plugin.KVM_START_VM_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(30)
     self.service.stop()
Exemple #27
0
    def offline_merge_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = AgentResponse()
        if not cmd.fullRebase:
            linux.qcow2_rebase(cmd.srcPath, cmd.destPath)
        else:
            tmp = os.path.join(os.path.dirname(cmd.destPath), '%s.qcow2' % uuidhelper.uuid())
            linux.qcow2_create_template(cmd.destPath, tmp)
            shell.call("mv %s %s" % (tmp, cmd.destPath))

        return jsonobject.dumps(rsp)
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.CreateRootVolumeFromTemplateCmd()
     cmd.installUrl = '/tmp/test1.qcow2'
     cmd.templatePathInCache = "/tmp/test.qcow2"
     cmd.timeout = 30
     
     url = kvmagent._build_url_for_test([nfs_primarystorage_plugin.CREATE_VOLUME_FROM_TEMPLATE_PATH])
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(10)
     self.service.stop()
     linux.umount_by_url(self.NFS_URL)
Exemple #29
0
    def reinit(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = ReInitImageRsp()

        install_path = cmd.imagePath
        new_volume_path = os.path.join(os.path.dirname(cmd.volumePath),
                                       '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone_with_cmd(install_path, new_volume_path, cmd)
        rsp.newVolumeInstallPath = new_volume_path
        rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity(
            cmd.uuid)
        return jsonobject.dumps(rsp)
Exemple #30
0
    def merge_snapshot_to_volume(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = OfflineMergeSnapshotRsp()
        if not cmd.fullRebase:
            linux.qcow2_rebase(cmd.srcPath, cmd.destPath)
        else:
            tmp = os.path.join(os.path.dirname(cmd.destPath), '%s.qcow2' % uuidhelper.uuid())
            linux.create_template(cmd.destPath, tmp)
            shell.call("mv %s %s" % (tmp, cmd.destPath))

        self._set_capacity_to_response(cmd.uuid, rsp)
        return jsonobject.dumps(rsp)
    def merge_snapshot_to_volume(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = OfflineMergeSnapshotRsp()
        if not cmd.fullRebase:
            linux.qcow2_rebase(cmd.srcPath, cmd.destPath)
        else:
            tmp = os.path.join(os.path.dirname(cmd.destPath), '%s.qcow2' % uuidhelper.uuid())
            linux.qcow2_create_template(cmd.destPath, tmp)
            shell.call("mv %s %s" % (tmp, cmd.destPath))

        self._set_capacity_to_response(cmd.uuid, rsp)
        return jsonobject.dumps(rsp)
    def offlinemerge(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = AliyunNasResponse()
        if not cmd.fullRebase:
            linux.qcow2_rebase(cmd.srcPath, cmd.destPath)
        else:
            tmp = os.path.join(os.path.dirname(cmd.destPath), '%s.qcow2' % uuidhelper.uuid())
            linux.create_template(cmd.destPath, tmp)
            shell.call("mv %s %s" % (tmp, cmd.destPath))

        rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity(cmd.uuid)
        return jsonobject.dumps(rsp)
Exemple #33
0
    def offline_merge_snapshots(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = AgentRsp()
        if not cmd.fullRebase:
            linux.qcow2_rebase(cmd.srcPath, cmd.destPath)
        else:
            tmp = os.path.join(os.path.dirname(cmd.destPath), '%s.qcow2' % uuidhelper.uuid())
            linux.create_template(cmd.destPath, tmp)
            shell.call("mv %s %s" % (tmp, cmd.destPath))

        rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity(cmd.mountPoint)
        return jsonobject.dumps(rsp)
Exemple #34
0
    def reinit_image(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = ReinitImageRsp()

        install_path = cmd.imageInstallPath
        dirname = os.path.dirname(cmd.volumeInstallPath)
        if not os.path.exists(dirname):
            os.makedirs(dirname, 0775)

        new_volume_path = os.path.join(dirname, '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone_with_cmd(install_path, new_volume_path, cmd)
        rsp.newVolumeInstallPath = new_volume_path
        return jsonobject.dumps(rsp)
Exemple #35
0
    def revert_volume_from_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotResponse()

        install_path = cmd.snapshotInstallPath
        new_volume_path = os.path.join(os.path.dirname(install_path),
                                       '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone(install_path, new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        size = linux.qcow2_virtualsize(new_volume_path)
        rsp.size = size
        self._set_capacity_to_response(cmd.uuid, rsp)
        return jsonobject.dumps(rsp)
    def reinit_image(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = ReinitImageRsp()

        install_path = cmd.imageInstallPath
        dirname = os.path.dirname(cmd.volumeInstallPath)
        if not os.path.exists(dirname):
            os.makedirs(dirname, 0775)

        new_volume_path = os.path.join(dirname, '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone_with_cmd(install_path, new_volume_path, cmd)
        rsp.newVolumeInstallPath = new_volume_path
        return jsonobject.dumps(rsp)
 def testName(self):
     server = sftpbackupstorage.SftpBackupStorageAgent()
     server.http_server.register_sync_uri('/testcallback', self.callback)
     server.http_server.start_in_thread()
     time.sleep(2)
     
     cmd = sftpbackupstorage.GetSshKeyCommand()
     url = 'http://localhost:7171%s' % sftpbackupstorage.SftpBackupStorageAgent.GET_SSHKEY_PATH
     print url
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     print "post back"
     time.sleep(5)
     
     server.http_server.stop()
    def testName(self):
        cmd = dns.SetDnsCmd()

        info = dns.DnsInfo()
        info.dnsAddress = "72.72.72.72"
        cmd.dns = [info]

        rsp = http.json_dump_post(
            "http://localhost:7272/setdns",
            cmd,
            headers={http.TASK_UUID: uuidhelper.uuid(), http.CALLBACK_URI: self.CALLBACK_URL},
        )
        time.sleep(10)
        self.service.stop()
    def reinit_image(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = ReInitImageResponse()

        install_path = cmd.imagePath
        dirname = os.path.dirname(cmd.volumePath)
        if not os.path.exists(dirname):
            os.makedirs(dirname, 0775)

        new_volume_path = os.path.join(dirname,
                                       '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone(install_path, new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        self._set_capacity_to_response(cmd.uuid, rsp)
        return jsonobject.dumps(rsp)
    def testName(self):
        cmd = dns.SetDnsCmd()

        info = dns.DnsInfo()
        info.dnsAddress = '72.72.72.72'
        cmd.dns = [info]

        rsp = http.json_dump_post('http://localhost:7272/setdns',
                                  cmd,
                                  headers={
                                      http.TASK_UUID: uuidhelper.uuid(),
                                      http.CALLBACK_URI: self.CALLBACK_URL
                                  })
        time.sleep(10)
        self.service.stop()
 def testName(self):
     self.mount()
     cmd = nfs_primarystorage_plugin.DownloadImageToCacheFromSftpBackupStorageCmd()
     p = os.path.expanduser('~/.ssh/id_rsa')
     with open(p, 'r') as fd:
         sshkey = fd.read()
         cmd.installUrl = '/tmp/test.qcow2'
         cmd.sftpBackupStorageHostName = "root@localhost"
         cmd.sftpBackupStorageSshKey = sshkey
         cmd.templatePath = '/home/root/test.qcow2'
         cmd.timeout = 300
         url = kvmagent._build_url_for_test([nfs_primarystorage_plugin.DOWNLOAD_IMAGE_FROM_SFTP_BACKUP_STORAGE_PATH])
         rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
         time.sleep(10)
         self.service.stop()
         linux.umount_by_url(self.NFS_URL)
Exemple #42
0
    def testName(self):
        cmd = snat.SetSNATCmd()

        info = snat.SnatInfo()
        info.publicIp = '192.168.0.199'
        info.nicMac = '52:54:00:03:FA:54'
        cmd.natInfo = [info]

        rsp = http.json_dump_post('http://localhost:7272/setsnat',
                                  cmd,
                                  headers={
                                      http.TASK_UUID: uuidhelper.uuid(),
                                      http.CALLBACK_URI: self.CALLBACK_URL
                                  })
        time.sleep(10)
        self.service.stop()
    def test_apply_rules(self):
        url = kvmagent._build_url_for_test([
            securitygroup_plugin.SecurityGroupPlugin.
            SECURITY_GROUP_APPLY_RULE_PATH
        ])
        sto = securitygroup_plugin.SecurityGroupRuleTO()
        sto.vmNicInternalName = 'v1.0'
        rto = securitygroup_plugin.RuleTO()
        rto.allowedCidr = '192.168.100.1/24'
        rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
        rto.endPort = 100
        rto.startPort = 20
        rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_TCP
        rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_INGRESS
        sto.rules.append(rto)

        rto = securitygroup_plugin.RuleTO()
        rto.allowedCidr = '0.0.0.0/0'
        rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
        rto.endPort = 55
        rto.startPort = 1
        rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_UDP
        rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_EGRESS
        sto.rules.append(rto)

        rto = securitygroup_plugin.RuleTO()
        rto.allowedCidr = '1.1.1.1/24'
        rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
        rto.endPort = -1
        rto.startPort = -1
        rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_ICMP
        rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_INGRESS
        sto.rules.append(rto)

        cmd = securitygroup_plugin.ApplySecurityGroupRuleCmd()
        cmd.ruleTOs.append(sto)

        logger.debug('calling %s' % url)
        rsp = http.json_dump_post(url,
                                  cmd,
                                  headers={
                                      http.TASK_UUID: uuidhelper.uuid(),
                                      http.CALLBACK_URI: self.CALLBACK_URL
                                  })
        time.sleep(1)
        self.service.stop()
    def ping(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        mount_path = self.mount_path[cmd.uuid]
        if not mount_path or not os.path.isdir(mount_path):
            raise Exception('the mount path[%s] of the nfs primary storage[uuid:%s] is not existing' % (mount_path, cmd.uuid))

        test_file = os.path.join(mount_path, '%s-ping-test-file' % uuidhelper.uuid())
        touch = shell.ShellCmd('timeout 60 touch %s' % test_file)
        touch(False)
        if touch.return_code == 124:
            raise Exception('unable to access the mount path[%s] of the nfs primary storage[uuid:%s] in 60s, timeout' %
                            (mount_path, cmd.uuid))
        elif touch.return_code != 0:
            touch.raise_error()

        shell.call('rm -f %s' % test_file)
        return jsonobject.dumps(NfsResponse())
    def testName(self):
        self.mount()
        cmd = nfs_primarystorage_plugin.CreateRootVolumeFromTemplateCmd()
        cmd.installUrl = '/tmp/test1.qcow2'
        cmd.templatePathInCache = "/tmp/test.qcow2"
        cmd.timeout = 30

        url = aliyunagent._build_url_for_test(
            [nfs_primarystorage_plugin.CREATE_VOLUME_FROM_TEMPLATE_PATH])
        rsp = http.json_dump_post(url,
                                  cmd,
                                  headers={
                                      http.TASK_UUID: uuidhelper.uuid(),
                                      http.CALLBACK_URI: self.CALLBACK_URL
                                  })
        time.sleep(10)
        self.service.stop()
        linux.umount_by_url(self.NFS_URL)
 def test_apply_rules(self):
     url = kvmagent._build_url_for_test([securitygroup_plugin.SecurityGroupPlugin.SECURITY_GROUP_APPLY_RULE_PATH])
     sto = securitygroup_plugin.SecurityGroupRuleTO()
     sto.vmNicInternalName = 'v1.0'
     rto = securitygroup_plugin.RuleTO()
     rto.allowedCidr = '192.168.100.1/24'
     rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
     rto.endPort = 100
     rto.startPort = 20
     rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_TCP
     rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_INGRESS
     sto.rules.append(rto)
     
     rto = securitygroup_plugin.RuleTO()
     rto.allowedCidr = '0.0.0.0/0'
     rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
     rto.endPort = 55
     rto.startPort = 1
     rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_UDP
     rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_EGRESS
     sto.rules.append(rto)
     
     rto = securitygroup_plugin.RuleTO()
     rto.allowedCidr = '1.1.1.1/24'
     rto.allowedInternalIpRange = ['10.1.1.1-10.1.1.10', '10.1.1.111']
     rto.endPort = -1
     rto.startPort = -1
     rto.protocol = securitygroup_plugin.SecurityGroupPlugin.PROTOCOL_ICMP
     rto.type = securitygroup_plugin.SecurityGroupPlugin.RULE_TYPE_INGRESS
     sto.rules.append(rto)
     
     cmd = securitygroup_plugin.ApplySecurityGroupRuleCmd()
     cmd.ruleTOs.append(sto)
     
     logger.debug('calling %s' % url)
     rsp = http.json_dump_post(url, cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(1)
     self.service.stop()
    def revert_volume_from_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotRsp()
        snapshot_abs_path = translate_absolute_path_from_install_path(cmd.snapshotInstallPath)
        qcow2_options = self.calc_qcow2_option(self, cmd.qcow2Options, True, cmd.provisioning)
        new_volume_path = cmd.installPath
        if new_volume_path is None or new_volume_path == "":
            new_volume_path = "/dev/%s/%s" % (cmd.vgUuid, uuidhelper.uuid())
        else:
            new_volume_path = translate_absolute_path_from_install_path(new_volume_path)

        with lvm.RecursiveOperateLv(snapshot_abs_path, shared=True):
            size = linux.qcow2_virtualsize(snapshot_abs_path)

            lvm.create_lv_from_cmd(new_volume_path, size, cmd,
                                             "%s::%s::%s" % (VOLUME_TAG, cmd.hostUuid, time.time()))
            with lvm.OperateLv(new_volume_path, shared=False, delete_when_exception=True):
                linux.qcow2_clone_with_option(snapshot_abs_path, new_volume_path, qcow2_options)
                size = linux.qcow2_virtualsize(new_volume_path)

        rsp.newVolumeInstallPath = new_volume_path
        rsp.size = size
        return jsonobject.dumps(rsp)
 def __init__(self):
     self.hostUuid = uuidhelper.uuid()
    def revert_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotRsp()

        install_path = cmd.snapshotInstallPath
        new_volume_path = os.path.join(os.path.dirname(install_path), "{0}.qcow2".format(uuidhelper.uuid()))
        linux.qcow2_clone(install_path, new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        return jsonobject.dumps(rsp)
    def reinit(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = ReInitImageRsp()

        install_path = cmd.imagePath
        new_volume_path = os.path.join(os.path.dirname(cmd.volumePath), '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone_with_cmd(install_path, new_volume_path, cmd)
        rsp.newVolumeInstallPath = new_volume_path
        rsp.totalCapacity, rsp.availableCapacity = self._get_disk_capacity(cmd.uuid)
        return jsonobject.dumps(rsp)
 def testName(self):
     cmd = snat.SetSNATCmd()
     
     info = snat.SnatInfo()
     info.publicIp = '192.168.0.199'
     info.nicMac = '52:54:00:03:FA:54'
     cmd.natInfo = [info]
     
     rsp = http.json_dump_post('http://localhost:7272/setsnat', cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(10)
     self.service.stop()
    def revert_volume_from_snapshot(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotResponse()

        install_path = cmd.snapshotInstallPath
        new_volume_path = os.path.join(os.path.dirname(install_path), '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone(install_path, new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        self._set_capacity_to_response(cmd.uuid, rsp)
        return jsonobject.dumps(rsp)
 def testName(self):
     cmd = configure_nic.ConfigureNicCmd()
     nic = NicInfo()
     nic.ip = "10.0.0.10"
     nic.mac = "50:e5:49:c9:65:11"
     nic.gateway = "10.0.0.1"
     nic.netmask = "255.255.255.0"
     nic.isDefaultRoute = False
     cmd.nics = [nic]
     
     rsp = http.json_dump_post('http://localhost:7272/configurenic', cmd, headers={http.TASK_UUID:uuidhelper.uuid(), http.CALLBACK_URI:self.CALLBACK_URL})
     time.sleep(10)
     self.service.stop()
    def revertvolume(self, req):
        cmd = jsonobject.loads(req[http.REQUEST_BODY])
        rsp = RevertVolumeFromSnapshotRsp()

        install_path = cmd.snapshotInstallPath
        new_volume_path = os.path.join(os.path.dirname(install_path), '{0}.qcow2'.format(uuidhelper.uuid()))
        linux.qcow2_clone_with_cmd(install_path, new_volume_path, cmd)
        size = linux.qcow2_virtualsize(new_volume_path)
        rsp.newVolumeInstallPath = new_volume_path
        rsp.size = size
        return jsonobject.dumps(rsp)
 def testName(self):
     dc = deployer.DataCenterPlan()
     zone = deployer.ZonePlan()
     zone.name = "Zone1"
     zone.description = "Zone1"
     dc.add_zone(zone)
     
     cluster = deployer.ClusterPlan()
     cluster.name = "Cluster1"
     cluster.description = "Cluster1"
     cluster.hypervisorType = inventory.HYPERVISOR_TYPE_SIMULATOR
     cluster.type = inventory.ZSTACK_CLUSTER_TYPE
     zone.add_cluster(cluster)
     
     host = deployer.SimulatorHostPlan()
     host.cpuCapacity = 2600 * 4
     host.hypervisorType = inventory.HYPERVISOR_TYPE_SIMULATOR
     host.description = "Host1"
     host.name = "Host1"
     host.managementIp = "10.1.1.11"
     host.hostTags = ['large', 'test']
     host.memoryCapacity = sizeunit.GigaByte.toByte(36)
     cluster.add_host(host)
     
     primary_storage = deployer.PrimaryStoragePlan()
     primary_storage.name = "primaryStorage1"
     primary_storage.description = "primaryStorage1"
     primary_storage.totalCapacity = sizeunit.GigaByte.toByte(500)
     primary_storage.usedCapacity = 0
     primary_storage.url = "nfs://test.primary.storage/nfs/%s" % uuidhelper.uuid()
     primary_storage.type = inventory.PRIMARY_STORAGE_TYPE_SIMULATORPRIMARYSTORAGE
     primary_storage.add_cluster(cluster)
     dc.add_primary_storage(primary_storage)
     
     backup_storage = deployer.BackupStoragePlan()
     backup_storage.name = "backupstorage"
     backup_storage.description = "backup_storage"
     backup_storage.totalCapacity = sizeunit.GigaByte.toByte(1000)
     backup_storage.usedCapacity = 0
     backup_storage.url = "nfs://test.backup.storage/nfs/%s" % uuidhelper.uuid()
     backup_storage.type = inventory.BACKUP_STORAGE_TYPE_SIMULATORBACKUPSTORAGE
     backup_storage.add_zone(zone)
     
     image = deployer.ImagePlan()
     image.accountUuid = inventory.INITIAL_SYSTEM_ADMIN_UUID
     image.bits = 64
     image.description = "image"
     #TODO: auto generated from java
     image.format = "template"
     image.hypervisorType = inventory.HYPERVISOR_TYPE_SIMULATOR
     image.type = inventory.ZSTACK_IMAGE_TYPE
     image.guestOsType = "Linux"
     image.url = "http://download.zstack.org/download/test.qcow2"
     image.add_backup_storage(backup_storage)
     
     l2network = deployer.L2NetworkPlan()
     l2network.name = "l2network"
     l2network.description = "l2network"
     l2network.physicalInterface = "eth0"
     l2network.type = inventory.L2_NO_VLAN_NETWORK_TYPE
     l2network.add_cluster(cluster)
     zone.add_l2network(l2network)
     
     l3network = deployer.L3NetworkPlan()
     l3network.name = "l3network"
     l3network.description = "l3network"
     l3network.type = inventory.L3_BASIC_NETWORK_TYPE
     l2network.add_l3network(l3network)
     
     iprange = inventory.IpRangeInventory()
     iprange.name = "iprange"
     iprange.startIp = "10.1.1.100"
     iprange.endIp = "10.1.1.150"
     iprange.gateway = "10.1.1.1"
     iprange.netmask = "255.255.255.0"
     #TODO: auto generated iprange type from java
     iprange.type = "Guest"
     l3network.add_iprange(iprange)
     
     dns = deployer.DnsPlan()
     dns.name = "dns"
     dns.description = "dns"
     dns.address = "10.1.1.254"
     dns.add_l3network(l3network)
     dc.add_dns(dns)
     
     dc.deploy()