Exemplo n.º 1
0
    def _config_cascaded_vpn(self):
        LOG.info("config vcloud vpn thread")
        vpn_conn_name = self.install_info["vpn_conn_name"]
        cloud_vpn_cf = VpnConfiger(
            host_ip=self.install_info["cascaded_vpn_info"]["public_ip"],
            user=constant.VpnConstant.VPN_ROOT,
            password=constant.VpnConstant.VPN_ROOT_PWD)

        cloud_vpn_cf.register_add_conns(
            tunnel_name=vpn_conn_name["api_conn_name"],
            left_public_ip=self.install_info['cascaded_vpn_info']['public_ip'],
            left_subnet=self.install_info["cascaded_subnets_info"]
            ["external_api"],
            right_public_ip=self.install_info['cascading_vpn_info']
            ['public_ip'],
            right_subnet=self.install_info['cascading_subnets_info']
            ['external_api'])

        cloud_vpn_cf.register_add_conns(
            tunnel_name=vpn_conn_name["tunnel_conn_name"],
            left_public_ip=self.install_info['cascaded_vpn_info']['public_ip'],
            left_subnet=self.install_info['cascaded_subnets_info']
            ['tunnel_bearing'],
            right_public_ip=self.install_info['cascading_vpn_info']
            ['public_ip'],
            right_subnet=self.install_info['cascading_subnets_info']
            ['tunnel_bearing'])
        cloud_vpn_cf.do_config()
Exemplo n.º 2
0
    def disable_cross_network(self):
        cloud_id = self.install_info["cloud_id"]
        for other_cloud_id in self.cloud_info_handler.list_all_cloud_id():
            if other_cloud_id == cloud_id:
                continue

            other_cloud = \
                self.cloud_info_handler.get_cloud_info_with_id(other_cloud_id)
            if not other_cloud["access"]:
                continue

            other_vpn_cfg = VpnConfiger(
                host_ip=other_cloud["cascaded_vpn_info"]["public_ip"],
                user=constant.VpnConstant.VPN_ROOT,
                password=constant.VpnConstant.VPN_ROOT_PWD)

            LOG.info("remove conn on tunnel vpns...")
            tunnel_conn_name = "%s-tunnel-%s" % (cloud_id, other_cloud_id)

            other_vpn_cfg.register_remove_conns(conn_name=tunnel_conn_name)
            other_vpn_cfg.do_config()

            LOG.info("remove route on cascadeds...")
            execute_cmd_without_stdout(
                host=other_cloud["cascaded_info"]["public_ip"],
                user=constant.HwsConstant.ROOT,
                password=constant.HwsConstant.ROOT_PWD,
                cmd='cd %(dir)s; sh %(script)s %(subnet)s' % {
                    "dir":
                    constant.RemoveConstant.REMOTE_SCRIPTS_DIR,
                    "script":
                    constant.RemoveConstant.REMOVE_ROUTE_SCRIPT,
                    "subnet":
                    self.install_info["cascaded_subnets_info"]
                    ["tunnel_bearing"]
                })

            add_route_file = "add_vpn_route_" + self.install_info[
                "azname"] + ".sh"
            execute_cmd_without_stdout(
                host=other_cloud["cascaded_info"]["public_ip"],
                user=constant.HwsConstant.ROOT,
                password=constant.HwsConstant.ROOT_PWD,
                cmd='cd %(dir)s; rm %(script)s ' % {
                    "dir":
                    constant.AfterRebootConstant.REMOTE_ROUTE_SCRIPTS_DIR,
                    "script": add_route_file
                })

            # del cloud-sg
            LOG.info("del security group...")
            #TODO
        return True
        pass
Exemplo n.º 3
0
    def config_vpn_only(self):
        LOG.info("config vcloud vpn only")
        cloud_vpn_cf = VpnConfiger(
                    host_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    user=constant.VpnConstant.VCLOUD_VPN_ROOT,
                    password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

        cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["api_conn_name"],
                    left_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascaded_subnets_info"]["external_api"],
                    right_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascading_subnets_info"]["external_api"])

        cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["tunnel_conn_name"],
                    left_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"],
                    right_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascading_subnets_info"]["tunnel_bearing"])
        cloud_vpn_cf.do_config()
Exemplo n.º 4
0
    def config_vpn_only(self):
        LOG.info("config cloud vpn only")
        cloud_vpn_cf = VpnConfiger(
            host_ip=self.instal_info["vpn"]["public_ip_vpn"],
            user=constant.VpnConstant.VCLOUD_VPN_ROOT,
            password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

        cloud_vpn_cf.register_add_conns(
            tunnel_name=self.vpn_conn_name["api_conn_name"],
            left_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
            left_subnet=self.instal_info["vdc_network"]["api_subnet_cidr"],
            right_public_ip=self.installer.local_vpn_public_gw,
            right_subnet=self.installer.local_api_subnet)

        cloud_vpn_cf.register_add_conns(
            tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
            left_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
            left_subnet=self.instal_info["vdc_network"]["tunnel_subnet_cidr"],
            right_public_ip=self.installer.local_vpn_public_gw,
            right_subnet=self.installer.local_tunnel_subnet)
        cloud_vpn_cf.do_config()
Exemplo n.º 5
0
    def config_vpn_only(self):
        LOG.info("config cloud vpn only")
        cloud_vpn_cf = VpnConfiger(
                    host_ip=self.instal_info["vpn"]["public_ip_vpn"],
                    user=constant.VpnConstant.VCLOUD_VPN_ROOT,
                    password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

        cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["api_conn_name"],
                    left_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                    left_subnet=self.instal_info["vdc_network"]["api_subnet_cidr"],
                    right_public_ip=self.installer.local_vpn_public_gw,
                    right_subnet=self.installer.local_api_subnet)

        cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                    left_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                    left_subnet=self.instal_info["vdc_network"]["tunnel_subnet_cidr"],
                    right_public_ip=self.installer.local_vpn_public_gw,
                    right_subnet=self.installer.local_tunnel_subnet)
        cloud_vpn_cf.do_config()
Exemplo n.º 6
0
    def config_vpn(self):
        if self.cloud_params['localmode'] == True :
            LOG.info("config local vpn")
            local_vpn_cf = VpnConfiger(
                    host_ip=self.installer.local_vpn_ip,
                    user=constant.VpnConstant.VPN_ROOT,
                    password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                    left_public_ip=self.installer.local_vpn_public_gw,
                    left_subnet=self.installer.local_tunnel_subnet,
                    right_public_ip=self.instal_info["vpn"]["public_ip_vpn"],
                    right_subnet=self.instal_info["vdc_network"]["tunnel_subnet_cidr"])
            local_vpn_cf.do_config()

            LOG.info("config vcloud vpn thread")
            cloud_vpn_cf = VpnConfiger(
                    host_ip=self.instal_info["vpn"]["public_ip_vpn"],
                    user=constant.VpnConstant.VCLOUD_VPN_ROOT,
                    password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

            cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                    left_public_ip=self.instal_info["vpn"]["public_ip_vpn"],
                    left_subnet=self.instal_info["vdc_network"]["tunnel_subnet_cidr"],
                   right_public_ip=self.installer.local_vpn_public_gw,
                   right_subnet=self.installer.local_tunnel_subnet)
            cloud_vpn_cf.do_config()
        else :
            LOG.info("config local vpn")
            local_vpn_cf = VpnConfiger(
                    host_ip=self.installer.local_vpn_ip,
                    user=constant.VpnConstant.VPN_ROOT,
                    password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["api_conn_name"],
                    left_public_ip=self.installer.local_vpn_public_gw,
                    left_subnet=self.installer.local_api_subnet,
                    right_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                    right_subnet=self.instal_info["vdc_network"]["api_subnet_cidr"])

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                    left_public_ip=self.installer.local_vpn_public_gw,
                    left_subnet=self.installer.local_tunnel_subnet,
                    right_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                    right_subnet=self.instal_info["vdc_network"]["tunnel_subnet_cidr"])
            local_vpn_cf.do_config()
Exemplo n.º 7
0
    def config_vpn(self):
        if self.cloud_params['project_info']['LocalMode'] == True :
            LOG.info("config cascading vpn")
            local_vpn_cf = VpnConfiger(
                    host_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    user=constant.VpnConstant.VPN_ROOT,
                    password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["tunnel_conn_name"],
                    left_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascading_subnets_info"]["tunnel_bearing"],
                    right_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"])
            local_vpn_cf.do_config()

            LOG.info("config vcloud vpn thread")
            cloud_vpn_cf = VpnConfiger(
                    host_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    user=constant.VpnConstant.VCLOUD_VPN_ROOT,
                    password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

            cloud_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["tunnel_conn_name"],
                    left_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"],
                    right_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascading_subnets_info"]["tunnel_bearing"])
            cloud_vpn_cf.do_config()
        else :
            LOG.info("config cascading vpn")
            local_vpn_cf = VpnConfiger(
                    host_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    user=constant.VpnConstant.VPN_ROOT,
                    password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["api_conn_name"],
                    left_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascading_subnets_info"]["external_api"],
                    right_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascaded_subnets_info"]["external_api"])

            local_vpn_cf.register_add_conns(
                    tunnel_name=self.cloud_info["vpn_conn_name"]["tunnel_conn_name"],
                    left_public_ip=self.cloud_info["cascading_vpn_info"]["public_ip"],
                    left_subnet=self.cloud_info["cascading_subnets_info"]["tunnel_bearing"],
                    right_public_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                    right_subnet=self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"])
            local_vpn_cf.do_config()
Exemplo n.º 8
0
    def _enable_network_cross(self):
        cloud_id = self.cloud_info["cloud_id"]

        vpn_cfg = VpnConfiger(
                host_ip=self.cloud_info["cascaded_vpn_info"]["public_ip"],
                user=constant.VpnConstant.VPN_ROOT,
                password=constant.VpnConstant.VPN_ROOT_PWD)

        for other_cloud_id in self.cloud_info_handler.list_all_cloud_id():
            if other_cloud_id == cloud_id:
                continue

            other_cloud = \
                self.cloud_info_handler.get_cloud_info_with_id(other_cloud_id)
            if not other_cloud["access"]:
                continue

            other_vpn_cfg = VpnConfiger(host_ip=other_cloud["cascaded_vpn_info"]["public_ip"],
                            user=constant.VpnConstant.VPN_ROOT,
                            password=constant.VpnConstant.VPN_ROOT_PWD)

            LOG.info("add conn on tunnel vpns...")
            tunnel_conn_name = "%s-tunnel-%s" % (cloud_id, other_cloud_id)
            vpn_cfg.register_add_conns(
                tunnel_name=tunnel_conn_name,
                left_public_ip=self.cloud_info[" "]["public_ip"],
                left_subnet=self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"],
                right_public_ip=other_cloud["cascaded_vpn_info"]["public_ip"],
                right_subnet=other_cloud["cascaded_subnets_info"]["tunnel_bearing"])

            other_vpn_cfg.register_add_conns(
                tunnel_name=tunnel_conn_name,
                left_public_ip=other_cloud["cascaded_vpn_info"]["public_ip"],
                left_subnet=other_cloud["cascaded_subnets_info"]["tunnel_bearing"],
                right_public_ip=self.cloud_info['cascaded_vpn_info']['public_ip'],
                right_subnet=self.cloud_info['cascaded_subnets_info']['tunnel_bearing'])
            vpn_cfg.do_config()
            other_vpn_cfg.do_config()

            LOG.info("add route on cascadeds...")
            execute_cmd_without_stdout(
                host=self.cloud_info["cascaded_info"]["public_ip"],
                user=constant.HwsConstant.ROOT,
                password=constant.HwsConstant.ROOT_PWD,
                cmd='cd %(dir)s; sh %(script)s %(subnet)s %(gw)s'
                    % {"dir": constant.Cascaded.REMOTE_HWS_SCRIPTS_DIR,
                       "script": constant.Cascaded.ADD_API_ROUTE_SCRIPT,
                       "subnet": other_cloud["cascaded_subnets_info"]["tunnel_bearing"],
                       "gw": self.cloud_info["cascaded_vpn_info"]['tunnel_bearing_ip']})

            execute_cmd_without_stdout(
                host=other_cloud["cascaded_info"]["public_ip"],
                user=constant.HwsConstant.ROOT,
                password=constant.HwsConstant.ROOT_PWD,
                cmd='cd %(dir)s; sh %(script)s %(subnet)s %(gw)s'
                    % {"dir": constant.Cascaded.REMOTE_HWS_SCRIPTS_DIR,
                       "script": constant.Cascaded.ADD_API_ROUTE_SCRIPT,
                       "subnet": self.cloud_info["cascaded_subnets_info"]["tunnel_bearing"],
                       "gw": other_cloud["cascaded_vpn_info"]['tunnel_bearing_ip']})

            # add cloud-sg
            LOG.info("add security group...")
            #TODO
        return True
Exemplo n.º 9
0
    def config_vpn(self):
        if self.cloud_params['localmode'] == True:
            LOG.info("config local vpn")
            local_vpn_cf = VpnConfiger(
                host_ip=self.installer.local_vpn_ip,
                user=constant.VpnConstant.VPN_ROOT,
                password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                left_public_ip=self.installer.local_vpn_public_gw,
                left_subnet=self.installer.local_tunnel_subnet,
                right_public_ip=self.instal_info["vpn"]["public_ip_vpn"],
                right_subnet=self.instal_info["vdc_network"]
                ["tunnel_subnet_cidr"])
            local_vpn_cf.do_config()

            LOG.info("config vcloud vpn thread")
            cloud_vpn_cf = VpnConfiger(
                host_ip=self.instal_info["vpn"]["public_ip_vpn"],
                user=constant.VpnConstant.VCLOUD_VPN_ROOT,
                password=constant.VpnConstant.VCLOUD_VPN_ROOT_PWD)

            cloud_vpn_cf.register_add_conns(
                tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                left_public_ip=self.instal_info["vpn"]["public_ip_vpn"],
                left_subnet=self.instal_info["vdc_network"]
                ["tunnel_subnet_cidr"],
                right_public_ip=self.installer.local_vpn_public_gw,
                right_subnet=self.installer.local_tunnel_subnet)
            cloud_vpn_cf.do_config()
        else:
            LOG.info("config local vpn")
            local_vpn_cf = VpnConfiger(
                host_ip=self.installer.local_vpn_ip,
                user=constant.VpnConstant.VPN_ROOT,
                password=constant.VpnConstant.VPN_ROOT_PWD)

            local_vpn_cf.register_add_conns(
                tunnel_name=self.vpn_conn_name["api_conn_name"],
                left_public_ip=self.installer.local_vpn_public_gw,
                left_subnet=self.installer.local_api_subnet,
                right_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                right_subnet=self.instal_info["vdc_network"]
                ["api_subnet_cidr"])

            local_vpn_cf.register_add_conns(
                tunnel_name=self.vpn_conn_name["tunnel_conn_name"],
                left_public_ip=self.installer.local_vpn_public_gw,
                left_subnet=self.installer.local_tunnel_subnet,
                right_public_ip=self.instal_info["vpn"]["ext_net_publicip"],
                right_subnet=self.instal_info["vdc_network"]
                ["tunnel_subnet_cidr"])
            local_vpn_cf.do_config()