def downloadFile(self, uuid, fqdn, shortname, ips, macs, netmasks, path, bwlimit): # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) if not ip or not NetUtils.is_ipv4_format(ip): logging.getLogger().warn("Ivalid IP address format: '%s'" % str(ip)) return fail(False) client = { 'host': ip, 'chosen_ip': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'ssh' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('download') return self.call_method('download_file', client, path, bwlimit)
def downloadFile(self, uuid, fqdn, shortname, ips, macs, netmasks, path, bwlimit): # choose a way to perform the operation ip = chooseClientIP({'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) client = {'host': ip, 'chosen_ip': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'ssh' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('download') return self.call_method('download_file', client, path, bwlimit)
def establishProxy(uuid, fqdn, shortname, ips, macs, requestor_ip, requested_port): def _finalize(result): if type(result) == list: # got expected struct (launcher, host, port) = result if host == '': host = SchedulerConfig().launchers[launcher]['host'] return (host, port) else: return False # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs }) client = { 'host': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'tcpsproxy' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('vnc') return callOnBestLauncher(None, 'tcp_sproxy', False, client, requestor_ip, requested_port).\ addCallback(_finalize).\ addErrback(lambda reason: reason)
def downloadFile(uuid, fqdn, shortname, ips, macs, path, bwlimit): # choose a way to perform the operation # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs }) client = { 'host': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'ssh' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('download') return callOnBestLauncher(None, 'download_file', False, client, path, bwlimit)
def downloadFile(uuid, fqdn, shortname, ips, macs, netmasks, path, bwlimit): # choose a way to perform the operation # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) client = { 'host': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'ssh' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('download') return callOnBestLauncher(None, 'download_file', False, client, path, bwlimit)
def establish_proxy(self, uuid, fqdn, shortname, ips, macs, netmasks, requestor_ip, requested_port): def _finalize(result): if type(result) == list: # got expected struct (launcher, host, port, key) = result if key == '-': # Key not provided => TCP Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new TCP Proxy to "%s:%s"' % (launcher, host, str(port))) else: # Key provided => Websocket Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new WebSocket Proxy to "%s:%s" with key "%s"' % (str(launcher), str(host), str(port), str(key))) if host == '': host = SchedulerConfig().launchers[launcher]['host'] return (host, port, key) else: return False # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) if not ip or not NetUtils.is_ipv4_format(ip): logging.getLogger().warn("Ivalid IP address format: '%s'" % str(ip)) return fail(False) client = { 'host': ip, 'chosen_ip': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'tcpsproxy' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('vnc') d = self.call_method('tcp_sproxy', client, requestor_ip, requested_port) d.addCallback(_finalize) @d.addErrback def _eb(failure): logging.getLogger().warn("VNC proxy open failed: %s" % str(failure)) return d
def chooseClientNetwork(target): return chooseClientIP({'uuid': target.getUUID(), 'fqdn': target.getFQDN(), 'shortname': target.getShortName(), 'ips': target.getIps(), 'macs': target.getMacs(), 'netmasks': target.getNetmasks() })
def pingClient(uuid, fqdn, shortname, ips, macs): # choose a way to perform the operation client = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs }) return callOnBestLauncher(None, 'icmp', False, client)
def chooseClientInfo(target): host_dict = {'uuid': target.getUUID(), 'fqdn': target.getFQDN(), 'shortname': target.getShortName(), 'ips': target.getIps(), 'macs': target.getMacs(), 'netmasks': target.getNetmasks() } return chooseClientIP(host_dict)
def probeClient(uuid, fqdn, shortname, ips, macs): # choose a way to perform the operation client = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs }) return callOnBestLauncher(None, 'probe', 'Unknown', client)
def probeClient(uuid, fqdn, shortname, ips, macs, netmasks): # choose a way to perform the operation client = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) return callOnBestLauncher(None, 'probe', 'Unknown', client)
def chooseClientNetwork(target): return chooseClientIP( { "uuid": target.getUUID(), "fqdn": target.getFQDN(), "shortname": target.getShortName(), "ips": target.getIps(), "macs": target.getMacs(), "netmasks": target.getNetmasks(), } )
def establish_proxy(self, uuid, fqdn, shortname, ips, macs, netmasks, requestor_ip, requested_port): def _finalize(result): if type(result) == list: # got expected struct (launcher, host, port, key) = result if key == '-': # Key not provided => TCP Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new TCP Proxy to "%s:%s"' % (launcher, host, str(port))) else: # Key provided => Websocket Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new WebSocket Proxy to "%s:%s" with key "%s"' % (str(launcher), str(host), str(port), str(key))) if host == '': host = SchedulerConfig().launchers[launcher]['host'] return (host, port, key) else: return False # choose a way to perform the operation ip = chooseClientIP({'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) client = {'host': ip, 'chosen_ip': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'tcpsproxy' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('vnc') d = self.call_method('tcp_sproxy', client, requestor_ip, requested_port) d.addCallback(_finalize) d.addErrback(lambda reason: reason) return d
def ping_client(self, uuid, fqdn, shortname, ips, macs, netmasks): client = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) if client : return MscDispatcher().launchers_provider.ping_client(client) else : return self._nok()
def downloadFile(self, uuid, fqdn, shortname, ips, macs, netmasks, path, bwlimit): # choose a way to perform the operation ip = chooseClientIP( {"uuid": uuid, "fqdn": fqdn, "shortname": shortname, "ips": ips, "macs": macs, "netmasks": netmasks} ) client = {"host": ip, "uuid": uuid, "shortname": shortname, "ip": ips, "macs": macs, "protocol": "ssh"} client["client_check"] = getClientCheck(client) client["server_check"] = getServerCheck(client) client["action"] = getAnnounceCheck("download") return self.call_method("download_file", client, path, bwlimit)
def ping_client(self, uuid, fqdn, shortname, ips, macs, netmasks): client = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) if client: return MscDispatcher().launchers_provider.ping_client(client) else: return self._nok()
def chooseClientInfo(target): ips = target.getIps() if len(ips) > 0: # if at least one element from list of IPs is IP format if any([NetUtils.is_ipv4_format(ip) for ip in ips]): host_dict = { "uuid": target.getUUID(), "fqdn": target.getFQDN(), "shortname": target.getShortName(), "ips": ips, "macs": target.getMacs(), "netmasks": target.getNetmasks(), } return chooseClientIP(host_dict) return None
def establish_proxy(self, uuid, fqdn, shortname, ips, macs, netmasks, requestor_ip, requested_port): def _finalize(result): if type(result) == list: # got expected struct (launcher, host, port, key) = result if key == "-": # Key not provided => TCP Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new TCP Proxy to "%s:%s"' % (launcher, host, str(port)) ) else: # Key provided => Websocket Proxy logging.getLogger().info( 'VNC Proxy: launcher "%s" created new WebSocket Proxy to "%s:%s" with key "%s"' % (str(launcher), str(host), str(port), str(key)) ) if host == "": host = SchedulerConfig().launchers[launcher]["host"] return (host, port, key) else: return False # choose a way to perform the operation ip = chooseClientIP( {"uuid": uuid, "fqdn": fqdn, "shortname": shortname, "ips": ips, "macs": macs, "netmasks": netmasks} ) client = {"host": ip, "uuid": uuid, "shortname": shortname, "ip": ips, "macs": macs, "protocol": "tcpsproxy"} client["client_check"] = getClientCheck(client) client["server_check"] = getServerCheck(client) client["action"] = getAnnounceCheck("vnc") d = self.call_method("tcp_sproxy", client, requestor_ip, requested_port) d.addCallback(_finalize) d.addErrback(lambda reason: reason) return d
def downloadFile(self, uuid, fqdn, shortname, ips, macs, netmasks, path, bwlimit): # choose a way to perform the operation ip = chooseClientIP({'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) if not ip or not NetUtils.is_ipv4_format(ip): logging.getLogger().warn("Ivalid IP address format: '%s'" % str(ip)) return fail(False) client = {'host': ip, 'chosen_ip': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'ssh' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('download') return self.call_method('download_file', client, path, bwlimit)
def establishProxy(uuid, fqdn, shortname, ips, macs, netmasks, requestor_ip, requested_port): def _finalize(result): if type(result) == list: # got expected struct (launcher, host, port) = result if host == '': host = SchedulerConfig().launchers[launcher]['host'] return (host, port) else: return False # choose a way to perform the operation ip = chooseClientIP({ 'uuid': uuid, 'fqdn': fqdn, 'shortname': shortname, 'ips': ips, 'macs': macs, 'netmasks': netmasks }) client = { 'host': ip, 'uuid': uuid, 'shortname': shortname, 'ip': ips, 'macs': macs, 'protocol': 'tcpsproxy' } client['client_check'] = getClientCheck(client) client['server_check'] = getServerCheck(client) client['action'] = getAnnounceCheck('vnc') return callOnBestLauncher(None, 'tcp_sproxy', False, client, requestor_ip, requested_port).\ addCallback(_finalize).\ addErrback(lambda reason: reason)
def choose_client_ip(self, interfaces): return chooseClientIP(interfaces)