Esempio n. 1
0
    def configure_server(self, **kwargs):
        """
        Write a configuration file containing the general GridFTP configuration
        items from the configuration file: IncomingPortRange,
        OutgoingPortRange, DataInterface, and RestrictPaths
        """
        self.logger.debug("ENTER: configure_server()")
        server = self.conf.get_gridftp_server()
        conf_file_name = os.path.join(
                self.var_gridftp_d, "globus-connect-server")
        conf_link_name = os.path.join(
                self.etc_gridftp_d, "globus-connect-server")

        if os.path.lexists(conf_link_name):
            os.remove(conf_link_name)

        self.logger.debug("Creating gridftp configuration")

        conf_file = file(conf_file_name, "w")
        try:
            version = pkgutil.get_data(
                "globus.connect.server",
                "version")
            if version:
                conf_file.write("version_tag GCS-%s" % (version))
                conf_file.write("usage_stats_id GCS-%s" % (version))
            if ":" in server:
                port = int(server.split(":")[1])
                conf_file.write("port %d\n" % port)
                self.logger.warn(
"""
******************************************************************************
WARNING: You configured your GridFTP server with a custom port.  In order
to override the default GridFTP server port, it may be necessary to edit
the global GridFTP server configuration file at /etc/gridftp.conf, and
comment out the "port" argument.
Change:
port 2811
to
#port 2811

Restart the globus-gridftp-server service if changes are made.
******************************************************************************
""")
            incoming_range = self.conf.get_gridftp_incoming_port_range()
            if incoming_range is not None:
                conf_file.write(
                    "port_range %d,%d\n" \
                    % (incoming_range[0], incoming_range[1]))
            outgoing_range = self.conf.get_gridftp_outgoing_port_range()
            if outgoing_range is not None:
                conf_file.write("$GLOBUS_TCP_SOURCE_RANGE %d,%d\n" \
                    % (outgoing_range[0], outgoing_range[1]))
            data_interface = self.conf.get_gridftp_data_interface()

            if data_interface is None:
                if gcmu.is_ec2():
                    data_interface = gcmu.public_ip()
                elif self.conf.get_gridftp_server_behind_nat():
                    data_interface = server
                    if ":" in data_interface:
                        data_interface = data_interface.split(":")[0]
                    if gcmu.is_private_ip(data_interface):
                        self.logger.warn(
"""
******************************************************************************
WARNING: Your GridFTP server is behind a NAT, but the Server name resolves
to a private IP address. This probably won't work correctly with Globus Online.
To remedy, set the DataInterface option in the [GridFTP] section of the
globus-connect-server.conf file to the public IP address of this GridFTP
server
******************************************************************************
""")

            if data_interface is not None:
                conf_file.write("data_interface %s\n" \
                    % (data_interface))

            rp = self.conf.get_gridftp_restrict_paths()
            if rp is not None:
                conf_file.write("restrict_paths %s\n" % rp)

            if self.conf.get_gridftp_udt():
               conf_file.write("allow_udt 1\n")
               conf_file.write("threads 1\n")

            os.symlink(conf_file_name, conf_link_name)
        finally:
            conf_file.close()
        self.logger.debug("EXIT: IO.configure_server()")
Esempio n. 2
0
    def configure_server(self, **kwargs):
        """
        Write a configuration file containing the general GridFTP configuration
        items from the configuration file: IncomingPortRange,
        OutgoingPortRange, DataInterface, and RestrictPaths
        """
        self.logger.debug("ENTER: configure_server()")
        server = self.conf.get_gridftp_server()
        conf_file_name = os.path.join(self.var_gridftp_d, "globus-connect-server")
        conf_link_name = os.path.join(self.etc_gridftp_d, "globus-connect-server")

        if os.path.lexists(conf_link_name):
            os.remove(conf_link_name)

        self.logger.debug("Creating gridftp configuration")

        conf_file = file(conf_file_name, "w")
        try:
            version = pkgutil.get_data("globus.connect.server", "version")
            if version:
                conf_file.write("version_tag GCS-%s" % (version))
                conf_file.write("usage_stats_id GCS-%s" % (version))
            if ":" in server:
                port = int(server.split(":")[1])
                conf_file.write("port %d\n" % port)
                self.logger.warn(
                    """
******************************************************************************
WARNING: You configured your GridFTP server with a custom port.  In order
to override the default GridFTP server port, it may be necessary to edit
the global GridFTP server configuration file at /etc/gridftp.conf, and
comment out the "port" argument.
Change:
port 2811
to
#port 2811

Restart the globus-gridftp-server service if changes are made.
******************************************************************************
"""
                )
            incoming_range = self.conf.get_gridftp_incoming_port_range()
            if incoming_range is not None:
                conf_file.write("port_range %d,%d\n" % (incoming_range[0], incoming_range[1]))
            outgoing_range = self.conf.get_gridftp_outgoing_port_range()
            if outgoing_range is not None:
                conf_file.write("$GLOBUS_TCP_SOURCE_RANGE %d,%d\n" % (outgoing_range[0], outgoing_range[1]))
            data_interface = self.conf.get_gridftp_data_interface()

            if data_interface is None:
                if gcmu.is_ec2():
                    data_interface = gcmu.public_ip()
                elif self.conf.get_gridftp_server_behind_nat():
                    data_interface = server
                    if ":" in data_interface:
                        data_interface = data_interface.split(":")[0]
                    if gcmu.is_private_ip(data_interface):
                        self.logger.warn(
                            """
******************************************************************************
WARNING: Your GridFTP server is behind a NAT, but the Server name resolves
to a private IP address. This probably won't work correctly with Globus Online.
To remedy, set the DataInterface option in the [GridFTP] section of the
globus-connect-server.conf file to the public IP address of this GridFTP
server
******************************************************************************
"""
                        )

            if data_interface is not None:
                conf_file.write("data_interface %s\n" % (data_interface))

            rp = self.conf.get_gridftp_restrict_paths()
            if rp is not None:
                conf_file.write("restrict_paths %s\n" % rp)

            if self.conf.get_gridftp_udt():
                conf_file.write("allow_udt 1\n")
                conf_file.write("threads 1\n")

            os.symlink(conf_file_name, conf_link_name)
        finally:
            conf_file.close()
        self.logger.debug("EXIT: IO.configure_server()")