예제 #1
0
파일: bcli.py 프로젝트: elstevi/bcli
def list(tablefmt):
    """ Lists all virtual machines and their status """
    all_vms = listdir(VM_DIR)
    vms = []
    i = 0
    for vm_name in all_vms:
        thisvm = VM(vm_name)
        vms.append(
            OrderedDict([
                ('name', thisvm.name),
                ('status', thisvm.status()),
                ('ncpus', thisvm.ncpus),
                ('memory', thisvm.memory),
            ]))
        i = i + 1
    click.echo(tabulate(vms, headers='keys', tablefmt=tablefmt))
예제 #2
0
파일: test_vm.py 프로젝트: elstevi/libbhyve
def test_vm_stop_non_graceful_fail(monkeypatch):
    # We want to catch the VM
    fp = abspath('tests/freebsd.conf')
    test_freebsd_vm = VM(fp)
    if test_freebsd_vm.status() == "Stopped":
        test_freebsd_vm.start()

    def mockfalse():
        return 111

    monkeypatch.setattr(test_freebsd_vm, 'get_pid', mockfalse)
    with pytest.raises(OSError,
                       match="VM did not die when it was supposed to"):
        test_freebsd_vm.stop()
    monkeypatch.undo()
예제 #3
0
파일: bcli.py 프로젝트: elstevi/bcli
def status(vm_name):
    """ Status a VM """
    myvm = VM(vm_name)
    click.echo(myvm.status())
예제 #4
0
파일: bcli.py 프로젝트: elstevi/bcli
def stop(vm_name):
    """ Stop a VM """
    myvm = VM(vm_name)
    myvm.stop()
예제 #5
0
파일: bcli.py 프로젝트: elstevi/bcli
def start(vm_name):
    """ Start a VM """
    myvm = VM(vm_name)
    myvm.start()
예제 #6
0
파일: bcli.py 프로젝트: elstevi/bcli
def restart(vm_name):
    """ Restart a VM """
    myvm = VM(vm_name)
    myvm.restart()
예제 #7
0
파일: bcli.py 프로젝트: elstevi/bcli
def destroy(vm_name):
    """ Destroys a VM """
    myvm = VM(vm_name)
    myvm.delete()
예제 #8
0
파일: bcli.py 프로젝트: elstevi/bcli
def create(name, onboot, com1, com2, disk, iso, memory, ncpus, network):
    """ Creates a VM """
    myvm = VM(None)
    myvm.name = name
    myvm.auto_start = onboot
    myvm.com1 = com1
    myvm.com2 = com2
    myvm.iso = iso
    myvm.memory = memory
    myvm.ncpus = ncpus
    for disc in disk:
        myvm.disk.append(Disk(disc, 'ahci-hd'))
    for nic in network:
        myvm.network.append(Nic(nic, 'virtio-net'))
    myvm.save()
    click.echo("VM Created")
예제 #9
0
파일: test_vm.py 프로젝트: elstevi/libbhyve
def test_bad_vm():
    with pytest.raises(OSError, match="does not exist"):
        myvm = VM('blahalsdjf')