def test_ip4addr_list(self): try: test_ip_list = helper.ip4_addresses() assert test_ip_list str_result = run_command('hostname -I', True, subprocess.PIPE, subprocess.PIPE)[1] host_ip = str_result.split() # remove IPV6 addresses from host ip list host_ip = [ip for ip in host_ip if ":" not in ip] # Verify IP address, except 127.0.0.1, both lists share # same set of ip address hit = True for ip in host_ip: hit = False for test_ip in test_ip_list: if ip == test_ip: hit = True break assert hit except Exception as e: print e assert False
def start(self, node_name): try: if Workspace.check_workspace_exists(node_name): node_info = Workspace.get_node_info_in_workspace(node_name) else: node_info = nm.get_item_info(node_name) node = model.CNode(node_info) self._node_preinit(node) except InfraSimError as e: print e.value logger_cmd.error("cmd res: {}".format(e.value)) return node.start() vnc_port = node_info["compute"].get("vnc_display", 1) + 5900 # get IP address print "Infrasim service started.\n" \ "Node {} graphic interface accessible via: \n" \ "VNC port: {} \n" \ "Either host IP: {} \n" \ "depending on host in which network VNC viewer is running \n"\ "Node log folder: {}". \ format(node.get_node_name(), vnc_port, helper.ip4_addresses(netns=node_info.get("namespace")), infrasim_log.get_log_path(node_name)) logger_cmd.info("cmd res: start node {} OK".format(node_name))
def test_ip4addr_list(self): try: test_ip_list = helper.ip4_addresses() assert test_ip_list str_result = run_command( 'hostname -I', True, subprocess.PIPE, subprocess.PIPE)[1] host_ip = str_result.split() # remove IPV6 addresses from host ip list host_ip = [ip for ip in host_ip if ":" not in ip] # Verify IP address, except 127.0.0.1, both lists share # same set of ip address hit = True for ip in host_ip: hit = False for test_ip in test_ip_list: if ip == test_ip: hit = True break assert hit except Exception as e: print e assert False
class NodeCommands(object): def _node_preinit(self, node, ignore_check=False): node.init() if ignore_check: return node.precheck() @args("node_name", nargs='?', default="default", help="Specify node name to start") def start(self, node_name): try: if Workspace.check_workspace_exists(node_name): node_info = Workspace.get_node_info_in_workspace(node_name) else: node_info = nm.get_node_info(node_name) node = model.CNode(node_info) self._node_preinit(node) except InfraSimError, e: print e.value logger_cmd.error("cmd res: {}".format(e.value)) return node.start() vnc_port = node_info["compute"].get("vnc_display", 1) + 5900 # get IP address print "Infrasim service started.\n" \ "Node {} graphic interface accessible via: \n" \ "VNC port: {} \n" \ "Either host IP: {} \n" \ "depending on host in which network VNC viewer is running \n"\ "Node log folder: {}". \ format(node.get_node_name(), vnc_port, helper.ip4_addresses(netns=node_info.get("namespace")), infrasim_log.get_log_path(node_name)) logger_cmd.info("cmd res: start node {} OK".format(node_name))