예제 #1
0
def operation(op, name, options=None):
    if options is None:
        options = {}
    if name:
        vmx = utils.locate_vmx(name)
        if vmx:
            mechfile = utils.load_mechfile(name)
            m = Mech()
            m.vmx = vmx
            m.user = mechfile['user']
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            method()
        else:
            puts(colored.red("Couldn't find a VMX in the specified directory"))
    else:
        mechfile = utils.load_mechfile()
        vmx = mechfile.get('vmx')
        if vmx:
            m = Mech()
            m.vmx = vmx
            m.user = mechfile.get('user')
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            method()
        else:
            puts(colored.red("Couldn't find a VMX in the mechfile"))
예제 #2
0
파일: __main__.py 프로젝트: ColdHeat/mech
def operation(op, name, options=None):
    if options is None:
        options = {}
    if name:
        vmx = utils.locate_vmx(name)
        if vmx:
            mechfile = utils.load_mechfile(name)
            m = Mech()
            m.vmx = vmx
            m.user = mechfile['user']
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            method()
        else:
            puts(colored.red("Couldn't find a VMX in the specified directory"))
    else:
        mechfile = utils.load_mechfile()
        vmx = mechfile.get('vmx')
        if vmx:
            m = Mech()
            m.vmx = vmx
            m.user = mechfile.get('user')
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            method()
        else:
            puts(colored.red("Couldn't find a VMX in the mechfile"))
예제 #3
0
def operation(op, name, options=None, kwargs=None):
    if options is None:
        options = {}
    if name:
        vmx = utils.locate_vmx(name)
        if vmx:
            mechfile = utils.load_mechfile(name)
            m = Mech()
            m.vmx = vmx
            m.user = mechfile['user']
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            if kwargs:
                method(**kwargs)
            else:
                method()
        else:
            puts(colored.red("Couldn't find a VMX in the specified directory"))
            return
    else:
        mechfile = utils.load_mechfile()
        if mechfile is None:
            puts(
                colored.red(
                    "Couldn't find a mechfile in the current directory any deeper directories"
                ))
            puts(
                colored.red(
                    "You can specify the name of the VM you'd like to start with mech up <name>"
                ))
            puts(
                colored.red(
                    "Or run mech init to setup a tarball of your VM or download the VM"
                ))
            return
        vmx = mechfile.get('vmx')
        if vmx:
            m = Mech()
            m.vmx = vmx
            m.user = mechfile.get('user')
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            if kwargs:
                method(**kwargs)
            else:
                method()
        else:
            puts(colored.red("Couldn't find a VMX in the mechfile"))
            return
예제 #4
0
파일: __main__.py 프로젝트: merlinWiz/mech
def operation(op, name, options=None, kwargs=None):
    if options is None:
        options = {}
    if name:
        vmx = utils.locate_vmx(name)
        if vmx:
            mechfile = utils.load_mechfile(name)
            m = Mech()
            m.vmx = vmx
            m.user = mechfile['user']
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            if kwargs:
                method(**kwargs)
            else:
                method()
        else:
            puts(colored.red("Couldn't find a VMX in the specified directory"))
            return
    else:
        mechfile = utils.load_mechfile()
        if mechfile is None:
            puts(colored.red("Couldn't find a mechfile in the current directory any deeper directories"))
            puts(colored.red("You can specify the name of the VM you'd like to start with mech up <name>"))
            puts(colored.red("Or run mech init to setup a tarball of your VM or download the VM"))
            return
        vmx = mechfile.get('vmx')
        if vmx:
            m = Mech()
            m.vmx = vmx
            m.user = mechfile.get('user')
            for key, value in options.iteritems():
                setattr(m, key, value)
            method = getattr(m, op)
            if kwargs:
                method(**kwargs)
            else:
                method()
        else:
            puts(colored.red("Couldn't find a VMX in the mechfile"))
            return