Ejemplo n.º 1
0
 def _config_az_cascaded(self):
     LOG.info("start config cascaded host, host: %s" % self.tunnel_ip)
      
     gateway = _get_gateway(self.api_ip)
     for i in range(30):
         try:
             commonutils.execute_cmd_without_stdout(
                 host=self.tunnel_ip,
                 user=constant.Cascaded.ROOT,
                 password=constant.Cascaded.ROOT_PWD,
                 cmd='cd %(dir)s; python %(script)s '
                     '%(cascading_domain)s %(cascading_api_ip)s '
                     '%(cascaded_domain)s %(cascaded_ip)s '
                     '%(gateway)s'
                     % {"dir": constant.Cascaded.REMOTE_SCRIPTS_DIR,
                        "script":
                            constant.Cascaded.MODIFY_CASCADED_SCRIPT_PY,
                        "cascading_domain": self.cascading_domain,
                        "cascading_api_ip": self.cascading_api_ip,
                        "cascaded_domain": self.domain,
                        "cascaded_ip": self.api_ip,
                        "gateway": gateway})
             break
         except exception.SSHCommandFailure as e:
             LOG.error("modify cascaded domain error: %s"
                          % e.message)
             time.sleep(5)
     return True
Ejemplo n.º 2
0
    def _config_az_cascaded(self):
        LOG.info("start config cascaded host, host: %s" % self.tunnel_ip)

        gateway = _get_gateway(self.api_ip)
        for i in range(30):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.tunnel_ip,
                    user=constant.Cascaded.ROOT,
                    password=constant.Cascaded.ROOT_PWD,
                    cmd='cd %(dir)s; python %(script)s '
                    '%(cascading_domain)s %(cascading_api_ip)s '
                    '%(cascaded_domain)s %(cascaded_ip)s '
                    '%(gateway)s' % {
                        "dir": constant.Cascaded.REMOTE_SCRIPTS_DIR,
                        "script": constant.Cascaded.MODIFY_CASCADED_SCRIPT_PY,
                        "cascading_domain": self.cascading_domain,
                        "cascading_api_ip": self.cascading_api_ip,
                        "cascaded_domain": self.domain,
                        "cascaded_ip": self.api_ip,
                        "gateway": gateway
                    })
                break
            except exception.SSHCommandFailure as e:
                LOG.error("modify cascaded domain error: %s" % e.message)
                time.sleep(5)
        return True
Ejemplo n.º 3
0
    def do_config(self):
        start_time = time.time()
        LOG.info("start config cascading, cascading: %s" % self.cascading_ip)

        # modify dns server address
        address = "/%(cascaded_domain)s/%(cascaded_ip)s" \
                  % {"cascaded_domain": self.cascaded_domain,
                     "cascaded_ip": self.cascaded_ip}

        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s; sh %(script)s add %(address)s' % {
                        "dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                        "script":
                        constant.PublicConstant.MODIFY_DNS_SERVER_ADDRESS,
                        "address": address
                    })
                break
            except exception.SSHCommandFailure as e:
                LOG.error("modify cascading dns address error, cascaded: "
                          "%s, error: %s" %
                          (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info("config cascading dns address success, cascading: %s" %
                 self.cascading_ip)

        # config keystone
        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s;'
                    'sh %(script)s %(cascaded_domain)s' % {
                        "dir": constant.RemoveConstant.REMOTE_SCRIPTS_DIR,
                        "script":
                        constant.RemoveConstant.REMOVE_KEYSTONE_SCRIPT,
                        "cascaded_domain": self.cascaded_domain
                    })

                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s;'
                    'sh %(script)s %(cascaded_domain)s %(v2v_gw)s' % {
                        "dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                        "script": constant.Cascading.KEYSTONE_ENDPOINT_SCRIPT,
                        "cascaded_domain": self.cascaded_domain,
                        "v2v_gw": self.v2v_gw
                    })
                break
            except exception.SSHCommandFailure as e:
                LOG.error(
                    "create keystone endpoint error, cascaded: %s, error: %s" %
                    (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info("config cascading keystone success, cascading: %s" %
                 self.cascading_ip)

        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s; sh %(script)s %(cascaded_domain)s' % {
                        "dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                        "script": constant.Cascading.ENABLE_OPENSTACK_SERVICE,
                        "cascaded_domain": self.cascaded_domain
                    })
                break
            except exception.SSHCommandFailure as e:
                LOG.error(
                    "enable openstack service error, cascaded: %s, error: %s" %
                    (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info("enable openstack service success, cascading: %s" %
                 self.cascading_ip)
        cost_time = time.time() - start_time
        LOG.info("config cascading success, cascading: %s, cost time: %d" %
                 (self.cascading_ip, cost_time))
Ejemplo n.º 4
0
    def do_config(self):
        start_time = time.time()
        LOG.info("start config cascading, cascading: %s" % self.cascading_ip)

        # modify dns server address
        address = "/%(cascaded_domain)s/%(cascaded_ip)s" \
                  % {"cascaded_domain": self.cascaded_domain,
                     "cascaded_ip": self.cascaded_ip}

        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s; sh %(script)s add %(address)s'
                        % {"dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                           "script": constant.PublicConstant.
                               MODIFY_DNS_SERVER_ADDRESS,
                           "address": address})
                break
            except exception.SSHCommandFailure as e:
                LOG.error("modify cascading dns address error, cascaded: "
                             "%s, error: %s"
                             % (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info(
            "config cascading dns address success, cascading: %s"
            % self.cascading_ip)

        # config keystone
        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s;'
                        'sh %(script)s %(cascaded_domain)s'
                        % {"dir": constant.RemoveConstant.REMOTE_SCRIPTS_DIR,
                           "script":
                               constant.RemoveConstant.REMOVE_KEYSTONE_SCRIPT,
                           "cascaded_domain": self.cascaded_domain})

                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s;'
                        'sh %(script)s %(cascaded_domain)s %(v2v_gw)s'
                        % {"dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                           "script":
                               constant.Cascading.KEYSTONE_ENDPOINT_SCRIPT,
                           "cascaded_domain": self.cascaded_domain,
                           "v2v_gw": self.v2v_gw})
                break
            except exception.SSHCommandFailure as e:
                LOG.error(
                    "create keystone endpoint error, cascaded: %s, error: %s"
                    % (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info("config cascading keystone success, cascading: %s"
                    % self.cascading_ip)

        for i in range(3):
            try:
                commonutils.execute_cmd_without_stdout(
                    host=self.cascading_ip,
                    user=self.user,
                    password=self.password,
                    cmd='cd %(dir)s; sh %(script)s %(cascaded_domain)s'
                        % {"dir": constant.Cascading.REMOTE_SCRIPTS_DIR,
                           "script":
                               constant.Cascading.ENABLE_OPENSTACK_SERVICE,
                           "cascaded_domain": self.cascaded_domain})
                break
            except exception.SSHCommandFailure as e:
                LOG.error(
                    "enable openstack service error, cascaded: %s, error: %s"
                    % (self.cascaded_domain, e.format_message()))
                time.sleep(1)

        LOG.info("enable openstack service success, cascading: %s"
                    % self.cascading_ip)
        cost_time = time.time() - start_time
        LOG.info("config cascading success, cascading: %s, cost time: %d"
                    % (self.cascading_ip, cost_time))