if get_arg('server[second_network]'): if not use_first_network: network = get_arg('server[second_network]') # Version version = get_arg('server[version]') if not version: version = '8' # Base directory base = os.path.dirname(os.path.realpath(__file__)) # Template with open(path(base, 'template')) as file: template = file.read() data = {'ethernet0.networkName': network, 'virtualHw.version': version, 'guestOs': os_guest} # CPU cores cpu_cores = get_arg('plan[cpu_core]') if cpu_cores: data.update({'numvcpus': cpu_cores}) # CPU MHZ cpu_mhz = get_arg('plan[cpu_mhz]') if cpu_mhz: data.update({'sched.cpu.max': cpu_mhz})
except: response(False) if online: try: machine.power_off() except: response(False) try: machine.set_extra_config(settings) except: response(False) try: machine.power_on() except: response(False) # VNC address vnc_address = append(server_address, ':', first) try: os.system( space('bash', path(base, '..', '..', '..', 'web/console/utils/launch.sh'), '--vnc', vnc_address, '--listen', port, '> /dev/null 2>&1 &')) except: response(False) response(True, {'password': password})
if get_arg('server[second_network]'): if not use_first_network: network = get_arg('server[second_network]') # Version version = get_arg('server[version]') if not version: version = '8' # Base directory base = os.path.dirname(os.path.realpath(__file__)) # Template with open(path(base, 'template')) as file: template = file.read() data = { 'ethernet0.networkName': network, 'virtualHw.version': version, 'guestOs': os_guest } # CPU cores cpu_cores = get_arg('plan[cpu_core]') if cpu_cores: data.update({'numvcpus': cpu_cores}) # CPU MHZ
import os from server import path, get_arg, response machine = get_arg('vps[id]') if not machine: response(False) first = path(os.path.dirname(os.path.realpath(__file__)), 'runtime', machine, 'status') if not os.path.exists(first): response(False) lines = [] with open(first) as file: lines = file.readlines() status = lines.pop() if not status: response(False) step, percent = status.strip().split(':') if not step or not percent: response(False) data = {'step': step, 'percent': percent}