def make_tunnel_with_vpn(system_ip, password): """Build the VPN tunnel with the given node""" if not is_valid_ipv4(system_ip): return False, "Invalid system ip: %s" % str(system_ip) success, own_server_id = get_server_id_from_local() if not success: error_msg = "Error while retrieving " + \ "server_id from local: %s" % str(own_server_id) return success, error_msg success, local_ip = get_system_ip_from_local() if not success: return success, "Cannot retrieve the local ip <%s>" % str(local_ip) success, data = ansible_make_tunnel_with_vpn( system_ip=system_ip, local_server_id=get_hex_string_from_uuid(own_server_id), password=password) if not success: return success, data print "Set VPN IP on the system table" new_node_vpn_ip = data['client_end_point1'] if new_node_vpn_ip is None: return False, "Cannot retrieve the new node VPN IP" print "New Node VPN IP %s" % new_node_vpn_ip success, data = get_system_id_from_system_ip(system_ip) if success: # If the system is not on the system table is doesn't matter success, data = set_system_vpn_ip(data, new_node_vpn_ip) if not success: return False, "Cannot set the new node vpn ip on the system table" flush_cache(namespace="support_tunnel") # Restart frameworkd print "Restarting ossim-framework" success, data = ansible_restart_frameworkd(system_ip=local_ip) if not success: print "Restarting %s ossim-framework failed (%s)" % (local_ip, data) return True, "VPN node successfully connected."
def make_tunnel_with_vpn(system_ip, password): """Build the VPN tunnel with the given node""" if not is_valid_ipv4(system_ip): return False, "Invalid system ip: %s" % str(system_ip) success, own_server_id = get_server_id_from_local() if not success: error_msg = "Error while retrieving " + \ "server_id from local: %s" % str(own_server_id) return success, error_msg success, local_ip = get_system_ip_from_local() if not success: return success, "Cannot retrieve the local ip <%s>" % str(local_ip) success, data = ansible_make_tunnel_with_vpn(system_ip=system_ip, local_server_id=get_hex_string_from_uuid(own_server_id), password=password) if not success: return success, data print "Set VPN IP on the system table" new_node_vpn_ip = data['client_end_point1'] if new_node_vpn_ip is None: return False, "Cannot retrieve the new node VPN IP" print "New Node VPN IP %s" % new_node_vpn_ip success, data = get_system_id_from_system_ip(system_ip) if success: # If the system is not on the system table is doesn't matter success, data = set_system_vpn_ip(data, new_node_vpn_ip) if not success: return False, "Cannot set the new node vpn ip on the system table" flush_cache(namespace="support_tunnel") # Restart frameworkd print "Restarting ossim-framework" success, data = ansible_restart_frameworkd(system_ip=local_ip) if not success: print "Restarting %s ossim-framework failed (%s)" % (local_ip, data) return True, "VPN node successfully connected."
def make_tunnel_with_vpn(system_ip,password): """Build the VPN tunnel with the given node""" if not is_valid_ipv4(system_ip): return False, "Invalid system ip: %s" % str(system_ip) success, own_server_id = get_server_id_from_local() if not success: return success, "Error while retrieving server_id from local: %s" % str(own_server_id) success, data = ansible_make_tunnel_with_vpn(system_ip=system_ip, local_server_id= get_hex_string_from_uuid(own_server_id), password=password) if not success: return success, data print "Set VPN IP on the system table" new_node_vpn_ip = data['client_end_point1'] if new_node_vpn_ip is None: return False, "Cannot retrieve the new node VPN IP" print "New Node VPN IP %s" % new_node_vpn_ip success, data = get_system_id_from_system_ip(system_ip) if success:# If the system is not on the system table is doesn't matter success, data = set_system_vpn_ip(data, new_node_vpn_ip) if not success: return False, "Cannot set the new node vpn ip on the system table" flush_cache(namespace="system") return True, "VPN node successfully connected."