Example #1
0
    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)
Example #2
0
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)
Example #3
0
    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)
Example #4
0
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)
Example #5
0
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)
Example #6
0
    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
Example #7
0
    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
Example #8
0
    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)
Example #9
0
    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)
Example #10
0
    def get_client(self, announce):
        client_group = ""
        if self.host :

            for pref_net_ip, pref_netmask in self.config.preferred_network :
                if NetUtils.on_same_network(self.host, pref_net_ip, pref_netmask):

                    client_group = pref_net_ip
                    break
        else :
            if len(self.config.preferred_network) > 0 :
                (pref_net_ip, pref_netmask) = self.config.preferred_network[0] 
                client_group = pref_net_ip 
            

        return {'host': self.host, 
                'uuid': self.target.getUUID(), 
                'maxbw': self.cmd.maxbw, 
                'protocol': 'ssh', 
                'client_check': getClientCheck(self.target), 
                'server_check': getServerCheck(self.target), 
                'action': getAnnounceCheck(announce), 
                'group': client_group
               }
Example #11
0
    def get_client(self, announce):
        client_group = ""
        if self.host :

            for pref_net_ip, pref_netmask in self.config.preferred_network :
                if NetUtils.on_same_network(self.host, pref_net_ip, pref_netmask):

                    client_group = pref_net_ip
                    break
        else :
            if len(self.config.preferred_network) > 0 :
                (pref_net_ip, pref_netmask) = self.config.preferred_network[0]
                client_group = pref_net_ip


        return {'host': self.host,
                'uuid': self.target.getUUID(),
                'maxbw': self.cmd.maxbw,
                'protocol': 'ssh',
                'client_check': getClientCheck(self.target),
                'server_check': getServerCheck(self.target),
                'action': getAnnounceCheck(announce),
                'group': client_group
               }
Example #12
0
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)
Example #13
0
    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
Example #14
0
    def _runProxyClientPhase(self, client):
        # fulfill protocol
        client['protocol'] = 'rsyncproxy'

        proxyCoH = CoHQuery(self.coh.getUsedProxy())
        # get informations about our proxy
        if proxyCoH == None:
            return defer.fail(Exception("Cant access to CoH")).addErrback(self.parsePushError, decrement_attempts_left = True).addErrback(self.got_error_in_error)

        #proxy = self.get_client("transfert")
        
        proxy = {'host': chooseClientInfo(proxyCoH.target), 
                 'uuid': proxyCoH.target.getUUID(), 
                 'maxbw': proxyCoH.cmd.maxbw, 
                 'client_check': getClientCheck(proxyCoH.target), 
                 'server_check': getServerCheck(proxyCoH.target), 
                 'action': getAnnounceCheck('transfert'), 
                 #'group': getClientGroup(proxyCoH.target)} # TODO - get correct network address
                 'group': ""} # TODO - get from launchers select
                  
 
        if not proxy['host']: # We couldn't get an IP address for the target host
            return defer.fail(Exception("Can't get proxy IP address")).addErrback(self.parsePushError, decrement_attempts_left = True).addErrback(self.got_error_in_error)
        # and fill struct
        # only proxy['host'] used until now
        client['proxy'] = {'command_id': self.coh.getUsedProxy(),
                           'host': proxy['host'],
                           'uuid': proxy['uuid']
        }

        # build file list
        files_list = []
        for file in self.cmd.files.split("\n"):
            fname = file.split('##')[1]
            if re_abs_path.search(fname):
                fname = re_basename.search(fname).group(1) # keeps last compontent of path
            files_list.append(fname)

        # prepare deffereds
        if self.config.mode == 'sync':
            self.update_history_in_progress()
            mydeffered = self.launchers_provider.sync_remote_pull(self.coh.getId(),
                                                             client,
                                                             files_list,
                                                             self.config.max_upload_time
                                                            )
            mydeffered.\
                addCallback(self.parsePushResult).\
                addErrback(self.parsePushError).\
                addErrback(self.got_error_in_error)
        elif self.config.mode == 'async':
            # 'server_check': {'IP': '192.168.0.16', 'MAC': 'abbcd'}
            mydeffered = self.launchers_provider.async_remote_pull(self.coh.getId(),
                                                              client,
                                                              files_list,
                                                              self.config.max_upload_time
                                                             )

            mydeffered.\
                addCallback(self.parsePushOrder).\
                addErrback(self.parsePushError).\
                addErrback(self.got_error_in_error)
        else:
            mydeffered = None

        return mydeffered
Example #15
0
    def _runProxyClientPhase(self, client):
        # fulfill protocol
        client['protocol'] = 'rsyncproxy'

        proxyCoH = CoHQuery(self.coh.getUsedProxy())
        # get informations about our proxy
        if proxyCoH == None:
            return defer.fail(Exception("Cant access to CoH")).addErrback(self.parsePushError).addErrback(self.got_error_in_error)

        #proxy = self.get_client("transfert")

        proxy = {'host': chooseClientInfo(proxyCoH.target),
                 'uuid': proxyCoH.target.getUUID(),
                 'maxbw': proxyCoH.cmd.maxbw,
                 'client_check': getClientCheck(proxyCoH.target),
                 'server_check': getServerCheck(proxyCoH.target),
                 'action': getAnnounceCheck('transfert'),
                 #'group': getClientGroup(proxyCoH.target)} # TODO - get correct network address
                 'group': ""} # TODO - get from launchers select


        if not proxy['host']: # We couldn't get an IP address for the target host
            return defer.fail(Exception("Can't get proxy IP address")).addErrback(self.parsePushError).addErrback(self.got_error_in_error)
        # and fill struct
        # only proxy['host'] used until now
        client['proxy'] = {'command_id': self.coh.getUsedProxy(),
                           'host': proxy['host'],
                           'uuid': proxy['uuid']
        }

        # build file list
        files_list = []
        for file in self.cmd.files.split("\n"):
            fname = file.split('##')[1]
            if re_abs_path.search(fname):
                fname = re_basename.search(fname).group(1) # keeps last compontent of path
            files_list.append(fname)

        # prepare deffereds
        if self.config.mode == 'sync':
            self.update_history_in_progress()
            mydeffered = self.launchers_provider.sync_remote_pull(self.coh.getId(),
                                                             client,
                                                             files_list,
                                                             self.config.max_upload_time
                                                            )
            mydeffered.\
                addCallback(self.parsePushResult).\
                addErrback(self.parsePushError).\
                addErrback(self.got_error_in_error)
        elif self.config.mode == 'async':
            # 'server_check': {'IP': '192.168.0.16', 'MAC': 'abbcd'}
            mydeffered = self.launchers_provider.async_remote_pull(self.coh.getId(),
                                                              client,
                                                              files_list,
                                                              self.config.max_upload_time
                                                             )

            mydeffered.\
                addCallback(self.parsePushOrder).\
                addErrback(self.parsePushError).\
                addErrback(self.got_error_in_error)
        else:
            mydeffered = None

        return mydeffered