示例#1
0
    def do_config(self):
        # check status
        start_time = time.time()
        LOG.info("check vpn status, vpn: %s" % self.host_ip)
        commonutils.check_host_status(self.host_ip,
                                      self.user,
                                      self.password,
                                      retry_time=500,
                                      interval=1)

        LOG.info("vpn is ready, vpn: %s" % self.host_ip)
        LOG.info("start config vpn, vpn: %s, add_conns: %s" %
                 (self.host_ip, self.add_conns))
        # add_conn
        vpn = VPN(public_ip=self.host_ip,
                  user=self.user,
                  pass_word=self.password)

        for conn in self.add_conns:
            try:
                vpn.add_tunnel(tunnel_name=conn["tunnel_name"],
                               left=conn["left_public_ip"],
                               left_subnet=conn["left_subnet"],
                               right=conn["right_public_ip"],
                               right_subnet=conn["right_subnet"])
            except Exception as e:
                LOG.error("add conn error, vpn: %s, conn: %s, error: %s" %
                          (self.host_ip, conn, e.message))
        LOG.info("add conns success, vpn: %s, conns: %s" %
                 (self.host_ip, self.add_conns))

        # delete conns
        for conn in self.delete_conns:
            try:
                vpn.remove_tunnel(conn)
            except Exception as e:
                LOG.error("delete conn error, vpn: %s, conn: %s, error: %s" %
                          (self.host_ip, conn, e.message))
        LOG.info("delete conns success, vpn: %s, conns: %s" %
                 (self.host_ip, self.delete_conns))

        try:
            vpn.restart_ipsec_service()
        except Exception as e:
            LOG.error("restart ipsec error, vpn: %s, error: %s" %
                      (self.host_ip, e.message))

        cost_time = time.time() - start_time
        LOG.info("config vpn success, vpn: %s, cost time: %d" %
                 (self.host_ip, cost_time))
示例#2
0
    def do_config(self):
        # check status
        start_time = time.time()
        LOG.info("check vpn status, vpn: %s" % self.host_ip)
        commonutils.check_host_status(self.host_ip, self.user, self.password,
                                      retry_time=500, interval=1)

        LOG.info("vpn is ready, vpn: %s" % self.host_ip)
        LOG.info("start config vpn, vpn: %s, add_conns: %s"
                    % (self.host_ip, self.add_conns))
        # add_conn
        vpn = VPN(public_ip=self.host_ip, user=self.user,
                  pass_word=self.password)

        for conn in self.add_conns:
            try:
                vpn.add_tunnel(tunnel_name=conn["tunnel_name"],
                               left=conn["left_public_ip"],
                               left_subnet=conn["left_subnet"],
                               right=conn["right_public_ip"],
                               right_subnet=conn["right_subnet"])
            except Exception as e:
                LOG.error("add conn error, vpn: %s, conn: %s, error: %s"
                             % (self.host_ip, conn, e.message))
        LOG.info("add conns success, vpn: %s, conns: %s"
                    % (self.host_ip, self.add_conns))

        # delete conns
        for conn in self.delete_conns:
            try:
                vpn.remove_tunnel(conn)
            except Exception as e:
                LOG.error("delete conn error, vpn: %s, conn: %s, error: %s"
                             % (self.host_ip, conn, e.message))
        LOG.info("delete conns success, vpn: %s, conns: %s"
                    % (self.host_ip, self.delete_conns))

        try:
            vpn.restart_ipsec_service()
        except Exception as e:
            LOG.error("restart ipsec error, vpn: %s, error: %s"
                         % (self.host_ip, e.message))

        cost_time = time.time() - start_time
        LOG.info("config vpn success, vpn: %s, cost time: %d"
                    % (self.host_ip, cost_time))
示例#3
0
    def do_config(self):
        start_time = time.time()

        LOG.info("start config cascaded, cascaded: %s" % self.domain)
        # wait cascaded tunnel can visit
        commonutils.check_host_status(host=self.tunnel_ip,
                                      user=self.user,
                                      password=self.password,
                                      retry_time=500,
                                      interval=1)

        # config cascaded host
        self._config_az_cascaded()

        time.sleep(20)

        self._config_az_cascaded()

        cost_time = time.time() - start_time
        LOG.info("first config success,  cascaded: %s, cost time: %d" %
                 (self.domain, cost_time))

        # check config result
        for i in range(3):
            try:
                # check 90s
                commonutils.check_host_status(
                    host=self.api_ip,
                    user=constant.Cascaded.ROOT,
                    password=constant.Cascaded.ROOT_PWD,
                    retry_time=15,
                    interval=1)
                LOG.info("cascaded api is ready..")
                break
            except exception.CheckHostStatusFailure:
                if i == 2:
                    LOG.error("check cascaded api failed ...")
                    break
                LOG.error("check cascaded api error, "
                          "retry config cascaded ...")
                self._config_az_cascaded()

        cost_time = time.time() - start_time
        LOG.info("config cascaded success, cascaded: %s, cost_time: %d" %
                 (self.domain, cost_time))
示例#4
0
    def do_config(self):
        start_time = time.time()
         
        LOG.info("start config cascaded, cascaded: %s" % self.domain)
        # wait cascaded tunnel can visit
        commonutils.check_host_status(host=self.tunnel_ip,
                                      user=self.user,
                                      password=self.password,
                                      retry_time=500, interval=1)

        # config cascaded host
        self._config_az_cascaded()

        time.sleep(20)

        self._config_az_cascaded()

        cost_time = time.time() - start_time
        LOG.info("first config success,  cascaded: %s, cost time: %d"
                    % (self.domain, cost_time))

        # check config result
        for i in range(3):
            try:
                # check 90s
                commonutils.check_host_status(
                    host=self.api_ip,
                    user=constant.Cascaded.ROOT,
                    password=constant.Cascaded.ROOT_PWD,
                    retry_time=15,
                    interval=1)
                LOG.info("cascaded api is ready..")
                break
            except exception.CheckHostStatusFailure:
                if i == 2:
                    LOG.error("check cascaded api failed ...")
                    break
                LOG.error("check cascaded api error, "
                             "retry config cascaded ...")
                self._config_az_cascaded()

        cost_time = time.time() - start_time
        LOG.info("config cascaded success, cascaded: %s, cost_time: %d"
                    % (self.domain, cost_time))