Пример #1
0
    def create_hdd(self, vmname, disksize):
        hddpath = os.path.join(config('hdd-dir'),
                               '%s.vdi' % os.path.basename(vmname))

        ctlname = 'IDE Controller'
        self._call('createhd', filename=hddpath, size=disksize)
        self._call('storagectl', vmname, name=ctlname, add='ide')
        self._call('storageattach', vmname, storagectl=ctlname,
                   type='hdd', device=0, port=0, medium=hddpath)
Пример #2
0
 def push_iso(self, f, filename):
     isopath = os.path.join(config('iso-dir'), os.path.basename(filename))
     f.save(isopath)
Пример #3
0
 def createvm(self, vmname):
     self._call('createvm', name=vmname, basefolder=config('vms-dir'),
                register=True)
Пример #4
0
    def attach_iso(self, vmname, filename):
        isopath = os.path.join(config('iso-dir'), os.path.basename(filename))

        ctlname = 'IDE Controller'
        self._call('storageattach', vmname, storagectl=ctlname,
                   type='dvddrive', port=1, device=0, medium=isopath)
Пример #5
0
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--debug', action='store_true', help='Enable debugging mode. Do *NOT* do this on production systems as it allows RCE.')
    parser.add_argument('--host', default='0.0.0.0', type=str, help='Host to listen on.')
    parser.add_argument('--port', default=9002, type=int, help='Port to listen on.')
    parser.add_argument('-s', '--settings', type=str, help='Settings file.')

    args = parser.parse_args()

    if args.debug:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    if args.settings:
        load_config(args.settings)

    required = 'iso-dir', 'hdd-dir', 'vms-dir'
    for row in required:
        if not config(row):
            log.error('The %r value is missing in your configuration! '
                      'Please provide it and run VBoxRPC again.', row)
            exit(1)

        path = config(row)
        if not os.path.isdir(path):
            log.info('Creating directory %r', path)
            os.makedirs(path)

    app = create_app(debug=args.debug)
    app.run(host=args.host, port=args.port)