def __init__(self, db, docker, fullname, created_at = None): self.db = db self.docker = docker self.rename(fullname) self.last_created_at = created_at self.last_top_layer_id = None self.mount_path = None self.mounted = False self.server_ip = get_server_ip() self.filesystem = Filesystem(FS_CMD_PATTERN % dict(image = self.fullname)) self.task_label = None
def start_vnode(self, node): if not os.path.exists('/etc/qemu/bridge.conf'): failsafe_makedirs('/etc/qemu') with open('/etc/qemu/bridge.conf', 'w') as f: f.write('allow walt-net\n') cmd = CMD_START_VNODE % dict(mac=node.mac, ip=node.ip, model=node.model, name=node.name, server_ip=get_server_ip()) print(cmd) subprocess.Popen(shlex.split(cmd))
def __init__(self, db, docker, fullname, created_at=None): self.db = db self.docker = docker self.rename(fullname) self.last_created_at = created_at self.last_top_layer_id = None self.mount_path = None self.mounted = False self.server_ip = get_server_ip() self.filesystem = Filesystem(FS_CMD_PATTERN % dict(image=self.fullname)) self.task_label = None
def start_vnode(self, node): if not os.path.exists('/etc/qemu/bridge.conf'): failsafe_makedirs('/etc/qemu') with open('/etc/qemu/bridge.conf', 'w') as f: f.write('allow walt-net\n') cmd = CMD_START_VNODE % dict( mac = node.mac, ip = node.ip, model = node.model, name = node.name, server_ip = get_server_ip() ) print(cmd) subprocess.Popen(shlex.split(cmd))
def parse_device_set(self, requester, device_set, allow_empty=False): if ',' in device_set: devices = [] for subset in device_set.split(','): subset_devices = self.parse_device_set(requester, subset, True) if subset_devices is None: return None devices += subset_devices return devices elif device_set == 'server': server_mac = get_mac_address(const.WALT_INTF) # register the server in the device list, if missing self.add_or_update(mac=server_mac, ip=str(get_server_ip()), type='server') return [self.get_complete_device_info(server_mac)] else: username = requester.get_username() if not username: return None # client already disconnected, give up # check keywords sql = None if device_set is None or device_set == 'my-nodes': sql = MY_NODES_QUERY % username elif device_set in DEVICE_SET_QUERIES: sql = DEVICE_SET_QUERIES[device_set] if sql is not None: # retrieve devices from database device_macs = [record[0] for record in self.db.execute(sql)] else: # otherwise a specific device is requested by name dev_name = device_set dev_info = self.get_device_info(requester, dev_name) if dev_info is None: return None device_macs = [dev_info.mac] # get complete devices info devices = [ self.get_complete_device_info(mac) for mac in device_macs ] if len(devices) == 0 and not allow_empty: requester.stderr.write( 'No matching devices found! (tip: walt help show node-terminology)\n' ) return None return sorted(devices)
def parse_device_set(self, requester, device_set): if ',' in device_set: devices = [] for subset in device_set.split(','): subset_devices = self.parse_device_set(requester, subset) if subset_devices is None: return None devices += subset_devices return devices elif device_set == 'server': server_mac = get_mac_address(const.WALT_INTF) # register the server in the device list, if missing self.add_or_update( mac = server_mac, ip = str(get_server_ip()), type = 'server') return [self.get_complete_device_info(server_mac)] else: username = requester.get_username() if not username: return None # client already disconnected, give up # check keywords sql = None if device_set is None or device_set == 'my-nodes': sql = MY_NODES_QUERY % username elif device_set in DEVICE_SET_QUERIES: sql = DEVICE_SET_QUERIES[device_set] if sql is not None: # retrieve devices from database device_macs = [record[0] for record in self.db.execute(sql)] else: # otherwise a specific device is requested by name dev_name = device_set dev_info = self.get_device_info(requester, dev_name) if dev_info is None: return None device_macs = [ dev_info.mac ] # get complete devices info devices = [self.get_complete_device_info(mac) for mac in device_macs] if len(devices) == 0: requester.stderr.write('No matching devices found! (tip: walt help show node-terminology)\n') return None return sorted(devices)
def start_vnode(self, node): if not os.path.exists('/etc/qemu/bridge.conf'): failsafe_makedirs('/etc/qemu') with open('/etc/qemu/bridge.conf', 'w') as f: f.write('allow walt-net\n') # in case a screen session already exists for this vnode # (e.g. walt server process was killed), kill it self.try_kill_vnode(node.mac) # start vnode VNODE_LOG_DIR.mkdir(parents=True, exist_ok=True) hypmac = node.mac.replace(':', '-') cmd = CMD_START_VNODE % dict( mac = node.mac, hypmac = hypmac, ip = node.ip, model = node.model, name = node.name, server_ip = get_server_ip(), cpu_cores = node.conf.get('cpu.cores', VNODE_DEFAULT_CPU_CORES), ram = node.conf.get('ram', VNODE_DEFAULT_RAM), ttyrec_file = VNODE_LOG_DIR / (hypmac + str(int(time())) + '.tty') ) print(cmd) subprocess.Popen(shlex.split(cmd))
def __init__(self, db): self.db = db self.server_ip = get_server_ip() self.netmask = str(get_walt_subnet().netmask)
def __init__(self, db): self.db = db self.server_ip = get_server_ip() self.netmask = str(get_walt_subnet().netmask)
'walt-log-echo': False, 'walt-log-cat': False, 'walt-log-tee': False, 'walt-echo': False, 'walt-cat': False, 'walt-tee': False, 'walt-rpc': True, 'walt-clock-sync': False, 'walt-notify-bootup': False, 'walt-init': False, 'walt-nfs-watchdog': False, 'walt-net-service': True} TEMPLATE_ENV = dict( server_mac = get_mac_address(WALT_INTF), server_ip = str(get_server_ip()), walt_server_rpc_port = WALT_SERVER_DAEMON_PORT, walt_server_logs_port = WALT_SERVER_TCP_PORT, walt_node_net_service_port = WALT_NODE_NET_SERVICE_PORT ) # when using walt, nodes often get new operating system # images, and usually each of these images has a new # authentication key. # this causes annoyance when using ssh to connect from the # server to a node. # we do not really need to secure access to nodes, since # they are very temporary environments, and since the walt # network is in a dedicated, separated vlan. # thus, when mounting an image, we will overwrite its # authentication key with the following one, which will
'walt-log-echo': False, 'walt-log-cat': False, 'walt-log-tee': False, 'walt-echo': False, 'walt-cat': False, 'walt-tee': False, 'walt-rpc': True, 'walt-clock-sync': False, 'walt-notify-bootup': False, 'walt-init': False, 'walt-nfs-watchdog': False, 'walt-net-service': True} TEMPLATE_ENV = dict( server_mac = get_mac_address(WALT_INTF), server_ip = str(get_server_ip()), walt_server_rpc_port = WALT_SERVER_DAEMON_PORT, walt_server_logs_port = WALT_SERVER_TCP_PORT, walt_node_net_service_port = WALT_NODE_NET_SERVICE_PORT ) # when using walt, nodes often get new operating system # images, and usually each of these images has a new # authentication key. # this causes annoyance when using ssh to connect from the # server to a node. # we do not really need to secure access to nodes, since # they are very temporary environments, and since the walt # network is in a dedicated, separated vlan. # thus, when mounting an image, we will overwrite its # authentication key with the following one, which will