Ejemplo n.º 1
0
    def deploy_landscape(self):
        self.multi_installer.tasker.start_task("Preparing Landscape")
        utils.apt_install('openstack-landscape')
        self.display_controller.status_info_message(
            "Running")
        # FIXME: not sure if deployer is failing to access the juju
        # environment but I get random connection refused when
        # running juju-deployer (adam.stokes)
        time.sleep(10)

        # Set remaining permissions
        self.set_perms()

        try:
            self.display_controller.status_info_message(
                "Downloading latest Landscape Autopilot bundle")
            utils.download_url(self.BUNDLE_URL, self.lscape_yaml_path)
        except Exception as e:
            utils.pollinate(self.session_id, 'EL')
            log.exception(e)
            raise e

        self.multi_installer.tasker.start_task("Deploying Landscape")
        self.run_deployer()

        self.multi_installer.tasker.start_task("Registering against Landscape")
        hostname = self.run_configure_script()

        self.multi_installer.tasker.stop_current_task()
        self.display_controller.clear_status()

        msg = []
        msg.append("To continue with OpenStack installation visit:\n\n")
        msg.append("http://{0}/account/standalone/openstack ".format(hostname))
        msg.append("\n\nLandscape Login Credentials:\n")
        msg.append(" Email: {}\n".format(
            self.config.getopt('landscapecreds')['admin_email']))
        msg.append(
            " Password: {}".format(self.config.getopt('openstack_password')))
        self.display_controller.show_step_info(msg)
Ejemplo n.º 2
0
    def deploy_landscape(self):
        self.multi_installer.tasker.start_task("Preparing Landscape")
        utils.apt_install('openstack-landscape')
        self.display_controller.status_info_message(
            "Running")
        # FIXME: not sure if deployer is failing to access the juju
        # environment but I get random connection refused when
        # running juju-deployer (adam.stokes)
        time.sleep(10)

        # Set remaining permissions
        self.set_perms()

        try:
            self.display_controller.status_info_message(
                "Downloading latest Landscape Autopilot bundle")
            utils.download_url(self.BUNDLE_URL, self.lscape_yaml_path)
        except Exception as e:
            utils.pollinate(self.session_id, 'EL')
            log.exception(e)
            raise e

        self.multi_installer.tasker.start_task("Deploying Landscape")
        self.run_deployer()

        self.multi_installer.tasker.start_task("Registering against Landscape")
        hostname = self.run_configure_script()

        self.multi_installer.tasker.stop_current_task()
        self.display_controller.clear_status()

        msg = []
        msg.append("To continue with OpenStack installation visit:\n\n")
        msg.append("http://{0}/account/standalone/openstack ".format(hostname))
        msg.append("\n\nLandscape Login Credentials:\n")
        msg.append(" Email: {}\n".format(
            self.config.getopt('landscapecreds')['admin_email']))
        msg.append(
            " Password: {}".format(self.config.getopt('openstack_password')))
        self.display_controller.show_step_info(msg)
Ejemplo n.º 3
0
    def do_install(self):
        # Install package deps
        utils.apt_install('openstack-multi')
        self.tasker.start_task("Bootstrapping Juju")
        self.config.setopt('current_state', InstallState.RUNNING.value)

        maas_creds = self.config.getopt('maascreds')
        maas_env = utils.load_template('juju-env/maas.yaml')

        render_parts = {
            'openstack_password': self.config.getopt('openstack_password'),
            'maas_server': maas_creds['api_host'],
            'maas_apikey': maas_creds['api_key'],
            'ubuntu_series': self.config.getopt('ubuntu_series')
        }

        for opt in [
                'http_proxy', 'https_proxy', 'no_proxy', 'apt_proxy',
                'image_metadata_url', 'tools_metadata_url'
        ]:
            val = self.config.getopt(opt)
            if val:
                render_parts[opt] = val

        maas_env_modified = maas_env.render(render_parts)

        check_output(['mkdir', '-p', self.config.juju_path()])
        utils.spew(self.config.juju_environments_path, maas_env_modified)

        utils.render_charm_config(self.config)

        utils.ssh_genkey()

        # Set remaining permissions
        self.set_perms()

        # Starts the party
        self.display_controller.status_info_message("Bootstrapping Juju")

        dbgflags = ""
        if os.getenv("DEBUG_JUJU_BOOTSTRAP"):
            dbgflags = "--debug"

        bsflags = ""

        bstarget = os.getenv("JUJU_BOOTSTRAP_TO")
        if bstarget:
            bsflags += " --to {}".format(bstarget)

        cons = self.config.getopt('constraints')
        if cons:
            bsflags += " --constraints \"{}\"".format(cons)

        cmd = ("{0} juju {1} bootstrap {2}".format(self.config.juju_home(),
                                                   dbgflags, bsflags))

        log.debug("Bootstrapping Juju: {}".format(cmd))

        out = utils.get_command_output(cmd, timeout=None, user_sudo=True)
        if out['status'] != 0:
            log.debug("Problem during bootstrap: '{}'".format(out))
            raise Exception("Problem with juju bootstrap.")

        # workaround to avoid connection failure at beginning of
        # openstack-status
        out = utils.get_command_output("{0} juju status".format(
            self.config.juju_home()),
                                       timeout=None,
                                       user_sudo=True)
        if out['status'] != 0:
            log.debug("failure to get initial juju status: '{}'".format(out))
            raise Exception("Problem with juju status poke.")

        self.add_bootstrap_to_no_proxy()

        self.tasker.stop_current_task()

        if self.config.getopt('install_only'):
            log.info("Done installing, stopping here per --install-only.")
            self.config.setopt('install_only', True)
            self.loop.exit(0)

        # Return control back to landscape_install if need be
        if not self.config.is_landscape():
            args = ['openstack-status']
            if self.config.getopt('edit_placement'):
                args.append('--edit-placement')

            self.drop_privileges()
            os.execvp('openstack-status', args)
        else:
            log.debug("Finished MAAS step, now deploying Landscape.")
            return LandscapeInstallFinal(self, self.display_controller,
                                         self.config, self.loop).run()
Ejemplo n.º 4
0
    def do_install(self):
        # Install package deps
        utils.apt_install('openstack-multi')
        self.tasker.start_task("Bootstrapping Juju")
        self.config.setopt('current_state', InstallState.RUNNING.value)

        maas_creds = self.config.getopt('maascreds')
        maas_env = utils.load_template('juju-env/maas.yaml')

        render_parts = {'openstack_password':
                        self.config.getopt('openstack_password'),
                        'maas_server': maas_creds['api_host'],
                        'maas_apikey': maas_creds['api_key'],
                        'ubuntu_series':
                        self.config.getopt('ubuntu_series')}

        for opt in ['http_proxy', 'https_proxy', 'no_proxy',
                    'image_metadata_url', 'tools_metadata_url']:
            val = self.config.getopt(opt)
            if val:
                render_parts[opt] = val

        maas_env_modified = maas_env.render(render_parts)

        check_output(['mkdir', '-p', self.config.juju_path()])
        utils.spew(self.config.juju_environments_path,
                   maas_env_modified)

        utils.render_charm_config(self.config)

        utils.ssh_genkey()

        # Set remaining permissions
        self.set_perms()

        # Starts the party
        self.display_controller.status_info_message("Bootstrapping Juju")

        dbgflags = ""
        if os.getenv("DEBUG_JUJU_BOOTSTRAP"):
            dbgflags = "--debug"

        bsflags = ""

        bstarget = os.getenv("JUJU_BOOTSTRAP_TO")
        if bstarget:
            bsflags += " --to {}".format(bstarget)

        cons = self.config.getopt('constraints')
        if cons:
            bsflags += " --constraints \"{}\"".format(cons)

        cmd = ("{0} juju {1} bootstrap {2}".format(
            self.config.juju_home(), dbgflags, bsflags))

        log.debug("Bootstrapping Juju: {}".format(cmd))

        out = utils.get_command_output(cmd,
                                       timeout=None,
                                       user_sudo=True)
        if out['status'] != 0:
            log.debug("Problem during bootstrap: '{}'".format(out))
            raise Exception("Problem with juju bootstrap.")

        # workaround to avoid connection failure at beginning of
        # openstack-status
        out = utils.get_command_output(
            "{0} juju status".format(
                self.config.juju_home()),
            timeout=None,
            user_sudo=True)
        if out['status'] != 0:
            log.debug("failure to get initial juju status: '{}'".format(out))
            raise Exception("Problem with juju status poke.")

        self.add_bootstrap_to_no_proxy()

        self.tasker.stop_current_task()

        if self.config.getopt('install_only'):
            log.info("Done installing, stopping here per --install-only.")
            self.config.setopt('install_only', True)
            self.loop.exit(0)

        # Return control back to landscape_install if need be
        if not self.config.is_landscape():
            args = ['openstack-status']
            if self.config.getopt('edit_placement'):
                args.append('--edit-placement')

            self.drop_privileges()
            os.execvp('openstack-status', args)
        else:
            log.debug("Finished MAAS step, now deploying Landscape.")
            return LandscapeInstallFinal(self,
                                         self.display_controller,
                                         self.config,
                                         self.loop).run()
Ejemplo n.º 5
0
    def continue_with_interface(self):
        self.display_controller.ui.hide_widget_on_top()
        self.start_task("Installing MAAS")

        check_output('mkdir -p /etc/openstack', shell=True)
        check_output(['cp', '/etc/network/interfaces',
                      '/etc/openstack/interfaces.cloud.bak'])
        check_output(['cp', '-r', '/etc/network/interfaces.d',
                      '/etc/openstack/interfaces.cloud.d.bak'])

        utils.spew('/etc/openstack/interface', self.target_iface)

        utils.apt_install('openstack-multi')

        self.start_task("Configuring MAAS")
        self.create_superuser()
        self.apikey = self.get_apikey()

        self.login_to_maas(self.apikey)

        try:
            utils.chown(os.path.join(utils.install_home(), '.maascli.db'),
                        utils.install_user(),
                        utils.install_user())
        except:
            raise MaasInstallError("Unable to set permissions on {}".format(
                os.path.join(utils.install_home(), '.maascli.db')))

        self.start_task("Waiting for MAAS cluster registration")
        cluster_uuid = self.wait_for_registration()
        self.create_maas_bridge(self.target_iface)

        self.prompt_for_bridge()

        self.start_task("Configuring MAAS networks")
        self.configure_maas_networking(cluster_uuid,
                                       'br0',
                                       self.gateway,
                                       self.dhcp_range,
                                       self.static_range)

        self.configure_dns()

        self.config.save_maas_creds(self.gateway,
                                    self.apikey)

        if "MAAS_HTTP_PROXY" in os.environ:
            pv = os.environ['MAAS_HTTP_PROXY']
            out = utils.get_command_output('maas maas maas set-config '
                                           'name=http_proxy '
                                           'value={}'.format(pv))
            if out['status'] != 0:
                log.debug("Error setting maas proxy config: {}".format(out))
                raise MaasInstallError("Error setting proxy config")

        self.display_controller.info_message("Importing MAAS boot images")
        self.start_task("Importing MAAS boot images")
        out = utils.get_command_output('maas maas boot-resources import')
        if out['status'] != 0:
            log.debug("Error starting boot images import: {}".format(out))
            raise MaasInstallError("Error setting proxy config")

        def pred(out):
            return out['output'] != '[]'

        ok = utils.poll_until_true('maas maas boot-images read '
                                   ' {}'.format(cluster_uuid),
                                   pred, 15, timeout=7200)
        if not ok:
            log.debug("poll timed out for getting boot images")
            raise MaasInstallError("Downloading boot images timed out")

        self.display_controller.info_message("Done importing boot images")

        self.stop_current_task()
        msg = "Waiting for sufficient resources in MAAS"
        self.display_controller.info_message(msg)
        self.display_controller.current_installer = self
        self.display_controller.current_state = InstallState.NODE_WAIT
Ejemplo n.º 6
0
    def continue_with_interface(self):
        self.display_controller.hide_widget_on_top()
        self.tasker.start_task("Installing MAAS")

        check_output('mkdir -p /etc/openstack', shell=True)
        check_output([
            'cp', '/etc/network/interfaces',
            '/etc/openstack/interfaces.cloud.bak'
        ])
        check_output([
            'cp', '-r', '/etc/network/interfaces.d',
            '/etc/openstack/interfaces.cloud.d.bak'
        ])

        utils.spew('/etc/openstack/interface', self.target_iface)

        utils.apt_install('openstack-multi')

        self.tasker.start_task("Configuring MAAS")
        self.create_superuser()
        self.apikey = self.get_apikey()

        self.login_to_maas(self.apikey)

        try:
            utils.chown(os.path.join(utils.install_home(), '.maascli.db'),
                        utils.install_user(), utils.install_user())
        except:
            raise MaasInstallError("Unable to set permissions on {}".format(
                os.path.join(utils.install_home(), '.maascli.db')))

        self.tasker.start_task("Waiting for MAAS cluster registration")
        cluster_uuid = self.wait_for_registration()
        self.create_maas_bridge(self.target_iface)

        self.prompt_for_bridge()

        self.tasker.start_task("Configuring MAAS networks")
        self.configure_maas_networking(cluster_uuid, 'br0', self.gateway,
                                       self.dhcp_range, self.static_range)

        self.configure_dns()

        self.config.setopt('maascreds',
                           dict(api_host=self.gateway, api_key=self.apikey))

        if "MAAS_HTTP_PROXY" in os.environ:
            pv = os.environ['MAAS_HTTP_PROXY']
            out = utils.get_command_output('maas maas maas set-config '
                                           'name=http_proxy '
                                           'value={}'.format(pv))
            if out['status'] != 0:
                log.debug("Error setting maas proxy config: {}".format(out))
                raise MaasInstallError("Error setting proxy config")

        self.display_controller.status_info_message(
            "Importing MAAS boot images")
        self.tasker.start_task("Importing MAAS boot images")
        out = utils.get_command_output('maas maas boot-resources import')
        if out['status'] != 0:
            log.debug("Error starting boot images import: {}".format(out))
            raise MaasInstallError("Error setting proxy config")

        def pred(out):
            return out['output'] != '[]'

        ok = utils.poll_until_true('maas maas boot-images read '
                                   ' {}'.format(cluster_uuid),
                                   pred,
                                   15,
                                   timeout=7200)
        if not ok:
            log.debug("poll timed out for getting boot images")
            raise MaasInstallError("Downloading boot images timed out")

        self.display_controller.status_info_message(
            "Done importing boot images")

        self.tasker.stop_current_task()
        msg = "Waiting for sufficient resources in MAAS"
        self.display_controller.status_info_message(msg)
        self.display_controller.current_installer = self
        self.display_controller.current_state = InstallState.NODE_WAIT