コード例 #1
0
ファイル: test_agent.py プロジェクト: RicoVZ/vmcloak
class TestAgent(object):
    def setup(self):
        self.a = Agent("localhost", 8000)

    def test_upload(self):
        def none(*args, **kwargs):
            pass

        self.a.postfile = none
        self.a.upload("/tmp/hello", "contents")
        self.a.upload("/tmp/hello", u"contents")
コード例 #2
0
ファイル: test_agent.py プロジェクト: waldow90/vmcloak
class TestAgent(object):
    def setup(self):
        self.a = Agent("localhost", 8000)

    def test_upload(self):
        def none(*args, **kwargs):
            pass

        self.a.postfile = none
        self.a.upload("/tmp/hello", "contents")
        self.a.upload("/tmp/hello", u"contents")
コード例 #3
0
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus, hostname,
                adapter, vm_visible, vrde, vrde_port, interactive):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    if vrde:
        m.vrde(port=vrde_port)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    if interactive:
        a.upload(
            "C:\\vmcloak\\interactive.txt",
            "Please make your final changes to this VM. When you're"
            "done, close this window and we'll create a snapshot.")

        log.info("You've started the snapshot creation in interactive mode!")
        log.info("Please make your last changes to the VM.")
        log.info(
            "When you're done close the spawned notepad process in the VM to take the final snapshot."
        )
        a.execute("notepad.exe C:\\vmcloak\\interactive.txt", async=False)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)
    m.snapshot("vmcloak", "Snapshot created by VMCloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id,
                        vmname=vmname,
                        ipaddr=ipaddr,
                        port=image.port,
                        hostname=hostname)
    return snapshot
コード例 #4
0
ファイル: main.py プロジェクト: jbremer/vmcloak
def do_snapshot(image, vmname, ipaddr, resolution, ramsize, cpus,
                hostname, adapter, vm_visible, vrde, vrde_port, interactive):
    m, h = initvm(image, name=vmname, multi=True, ramsize=ramsize, cpus=cpus)

    if vrde:
        m.vrde(port=vrde_port)

    m.start_vm(visible=vm_visible)

    wait_for_host(image.ipaddr, image.port)
    a = Agent(image.ipaddr, image.port)
    a.ping()

    # Assign a new hostname.
    a.hostname(hostname)
    a.reboot()
    a.kill()

    # Wait for the reboot to kick in.
    time.sleep(10)
    wait_for_host(image.ipaddr, image.port)
    a.ping()

    if resolution:
        width, height = resolution.split("x")
        a.resolution(width, height)

    if interactive:
        a.upload("C:\\vmcloak\\interactive.txt",
                 "Please make your final changes to this VM. When you're"
                 "done, close this window and we'll create a snapshot.")

        log.info("You've started the snapshot creation in interactive mode!")
        log.info("Please make your last changes to the VM.")
        log.info("When you're done close the spawned notepad process in the VM to take the final snapshot.")
        a.execute("notepad.exe C:\\vmcloak\\interactive.txt", async=False)

    a.remove("C:\\vmcloak")
    a.static_ip(ipaddr, image.netmask, image.gateway, h.interface)
    m.snapshot("vmcloak", "Snapshot created by VMCloak.")
    m.stopvm()

    # Create a database entry for this snapshot.
    snapshot = Snapshot(image_id=image.id, vmname=vmname, ipaddr=ipaddr,
                        port=image.port, hostname=hostname)
    return snapshot