示例#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
        })

        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)
示例#2
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
示例#3
0
文件: utils.py 项目: pavelpromin/mmc
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
示例#4
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)
示例#5
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
示例#6
0
    def test08_is_not_ipv4_format(self):
        """ test of ipv4 format"""
        ip = "150.150.154.aaa"
        result = NetUtils.is_ipv4_format(ip)

        self.assertFalse(result)
示例#7
0
    def test07_is_ipv4_format(self):
        """ test of ipv4 format"""
        ip = "192.168.1.25"
        result = NetUtils.is_ipv4_format(ip)

        self.assertTrue(result)
示例#8
0
    def test08_is_not_ipv4_format(self):
        """ test of ipv4 format"""
        ip = "150.150.154.aaa"
        result = NetUtils.is_ipv4_format(ip)

        self.assertFalse(result)
示例#9
0
    def test07_is_ipv4_format(self):
        """ test of ipv4 format"""
        ip = "192.168.1.25"
        result = NetUtils.is_ipv4_format(ip)

        self.assertTrue(result)