Exemplo n.º 1
0
 def _do_test_multiplier(self, is_single, mockspew, expected=None):
     self.config.is_single = is_single
     render_charm_config(self.config, MagicMock(openstack_release='klaxon'))
     (fake_path, generated_yaml), kwargs = mockspew.call_args
     d = yaml.load(generated_yaml)
     wmul = d['nova-cloud-controller'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
     # glance should either have the key or not be there at all:
     gexpected = {'worker-multiplier': expected} if expected else None
     wmul = d.get('glance', None)
     self.assertEqual(wmul, gexpected)
     wmul = d['keystone'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
    def _do_test_osrel(self, series, optsvalue, expected, mockspew):
        "check that opts.openstack_release is rendered correctly"
        self.config.setopt("openstack_release", optsvalue)
        self.config.setopt("ubuntu_series", series)

        render_charm_config(self.config)
        (fake_path, generated_yaml), kwargs = mockspew.call_args
        d = yaml.load(generated_yaml)
        print(d)
        for oscharmname in ["nova-cloud-controller", "glance", "openstack-dashboard", "keystone", "swift-proxy"]:
            if expected is None:
                self.assertTrue(oscharmname not in d or "openstack-origin" not in d[oscharmname])
            else:
                self.assertEqual(d[oscharmname]["openstack-origin"], expected)
Exemplo n.º 3
0
 def _do_test_multiplier(self, is_single, mockspew, expected=None):
     if is_single:
         self.config.setopt('install_type', 'Single')
     else:
         self.config.setopt('install_type', 'Multi')
     self.config.setopt('openstack_release', 'klaxon')
     render_charm_config(self.config)
     (fake_path, generated_yaml), kwargs = mockspew.call_args
     d = yaml.load(generated_yaml)
     wmul = d['nova-cloud-controller'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
     wmul = d['glance'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
     wmul = d['keystone'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
Exemplo n.º 4
0
 def _do_test_multiplier(self, is_single, mockspew, expected=None):
     if is_single:
         self.config.setopt('install_type', 'Single')
     else:
         self.config.setopt('install_type', 'Multi')
     self.config.setopt('openstack_release', 'klaxon')
     render_charm_config(self.config)
     (fake_path, generated_yaml), kwargs = mockspew.call_args
     d = yaml.load(generated_yaml)
     wmul = d['nova-cloud-controller'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
     wmul = d['glance'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
     wmul = d['keystone'].get('worker-multiplier', None)
     self.assertEqual(wmul, expected)
Exemplo n.º 5
0
    def _do_test_osrel(self, optsvalue, expected, mockspew):
        "check that opts.openstack_release is rendered correctly"
        self.config.setopt('openstack_release', optsvalue)

        render_charm_config(self.config)
        (fake_path, generated_yaml), kwargs = mockspew.call_args
        d = yaml.load(generated_yaml)
        print(d)
        for oscharmname in ['nova-cloud-controller', 'glance',
                            'openstack-dashboard', 'keystone', 'swift-proxy']:
            if expected is None:
                self.assertTrue(oscharmname not in d or
                                'openstack-origin' not in d[oscharmname])
            else:
                self.assertEqual(d[oscharmname]['openstack-origin'], expected)
 def _do_test_multiplier(self, is_single, mockspew, expected=None):
     if is_single:
         self.config.setopt("install_type", "Single")
     else:
         self.config.setopt("install_type", "Multi")
     self.config.setopt("openstack_release", "klaxon")
     render_charm_config(self.config)
     (fake_path, generated_yaml), kwargs = mockspew.call_args
     d = yaml.load(generated_yaml)
     wmul = d["nova-cloud-controller"].get("worker-multiplier", None)
     self.assertEqual(wmul, expected)
     wmul = d["glance"].get("worker-multiplier", None)
     self.assertEqual(wmul, expected)
     wmul = d["keystone"].get("worker-multiplier", None)
     self.assertEqual(wmul, expected)
Exemplo n.º 7
0
    def _do_test_osrel(self, series, optsvalue, expected, mockspew):
        "check that opts.openstack_release is rendered correctly"
        self.config.setopt('openstack_release', optsvalue)
        self.config.setopt('ubuntu_series', series)

        render_charm_config(self.config)
        (fake_path, generated_yaml), kwargs = mockspew.call_args
        d = yaml.load(generated_yaml)
        print(d)
        for oscharmname in ['nova-cloud-controller', 'glance',
                            'openstack-dashboard', 'keystone', 'swift-proxy']:
            if expected is None:
                self.assertTrue(oscharmname not in d or
                                'openstack-origin' not in d[oscharmname])
            else:
                self.assertEqual(d[oscharmname]['openstack-origin'], expected)
Exemplo n.º 8
0
    def do_install(self):
        self.display_controller.info_message("Building environment")
        if os.path.exists(self.container_abspath):
            # Container exists, handle return code in installer
            raise Exception("Container exists, please uninstall or kill "
                            "existing cloud before proceeding.")

        utils.ssh_genkey()

        # Preparations
        self.prep_userdata()

        # setup charm configurations
        utils.render_charm_config(self.config, self.opts)

        self.prep_juju()

        # Set permissions
        self.set_perms()

        # Start container
        self.create_container_and_wait()

        # Install local copy of openstack installer if provided
        if self.opts.upstream_deb and os.path.isfile(self.opts.upstream_deb):
            shutil.copy(self.opts.upstream_deb, self.config.cfg_path)
            self._install_upstream_deb()

        # start the party
        cloud_status_bin = ['openstack-status']
        self.display_controller.info_message("Bootstrapping Juju")
        self.start_task("Bootstrapping Juju")
        utils.container_run(
            self.container_name, "JUJU_HOME={} juju bootstrap".format(
                self.config.cfg_path))
        utils.container_run(
            self.container_name, "JUJU_HOME={} juju status".format(
                self.config.cfg_path))

        if self.opts.install_only:
            log.info("Done installing, stopping here per --install-only.")
            sys.exit(0)

        self.display_controller.info_message("Starting cloud deployment")
        utils.container_run_status(
            self.container_name, " ".join(cloud_status_bin))
Exemplo n.º 9
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()
Exemplo n.º 10
0
    def do_install(self):
        self.display_controller.status_info_message("Building environment")
        if os.path.exists(self.container_abspath):
            raise Exception("Container exists, please uninstall or kill "
                            "existing cloud before proceeding.")

        # check for deb early, will actually install it later
        upstream_deb = self.config.getopt('upstream_deb')
        if upstream_deb and not os.path.isfile(upstream_deb):
            raise Exception("Upstream deb '{}' "
                            "not found.".format(upstream_deb))

        utils.ssh_genkey()

        self.setup_apt_proxy()

        self.prep_userdata()

        utils.render_charm_config(self.config)

        self.prep_juju()

        self.set_perms()

        self.create_container_and_wait()

        # Copy over host ssh keys
        Container.cp(self.container_name,
                     os.path.join(utils.install_home(), '.ssh/id_rsa*'),
                     '.ssh/.')

        # Install local copy of openstack installer if provided
        if upstream_deb:
            shutil.copy(upstream_deb, self.config.cfg_path)
            self._install_upstream_deb()

        # Stop before we attempt to access container
        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)

        # Update jujus no-proxy setting if applicable
        if self.config.getopt('http_proxy') or \
           self.config.getopt('https_proxy'):
            log.info("Updating juju environments for proxy support")
            lxc_net = self.config.getopt('lxc_network')
            self.config.update_environments_yaml(
                key='no-proxy',
                val='{},localhost,{}'.format(
                    Container.ip(self.container_name),
                    netutils.get_ip_set(lxc_net)))

        # start the party
        cloud_status_bin = ['openstack-status']
        self.tasker.start_task("Bootstrapping Juju",
                               self.read_progress_output)
        Container.run(self.container_name,
                      "{0} juju --debug bootstrap".format(
                          self.config.juju_home(use_expansion=True)),
                      use_ssh=True, output_cb=self.set_progress_output)
        Container.run(
            self.container_name,
            "{0} juju status".format(
                self.config.juju_home(use_expansion=True)),
            use_ssh=True)
        self.tasker.stop_current_task()

        self.display_controller.status_info_message(
            "Starting cloud deployment")
        Container.run_status(
            self.container_name, " ".join(cloud_status_bin), self.config)
Exemplo n.º 11
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()
Exemplo n.º 12
0
    def do_install(self):
        self.display_controller.status_info_message("Building environment")
        if os.path.exists(self.container_abspath):
            raise Exception("Container exists, please uninstall or kill "
                            "existing cloud before proceeding.")

        # check for deb early, will actually install it later
        upstream_deb = self.config.getopt('upstream_deb')
        if upstream_deb and not os.path.isfile(upstream_deb):
            raise Exception("Upstream deb '{}' "
                            "not found.".format(upstream_deb))

        utils.ssh_genkey()

        self.setup_apt_proxy()

        self.prep_userdata()

        utils.render_charm_config(self.config)

        self.prep_juju()

        self.set_perms()

        self.create_container_and_wait()

        # Copy over host ssh keys
        Container.cp(self.container_name,
                     os.path.join(utils.install_home(), '.ssh/id_rsa*'),
                     '.ssh/.')

        # Install local copy of openstack installer if provided
        if upstream_deb:
            shutil.copy(upstream_deb, self.config.cfg_path)
            self._install_upstream_deb()

        # Stop before we attempt to access container
        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)

        # Update jujus no-proxy setting if applicable
        if self.config.getopt('http_proxy') or \
           self.config.getopt('https_proxy'):
            log.info("Updating juju environments for proxy support")
            lxc_net = self.config.getopt('lxc_network')
            self.config.update_environments_yaml(
                key='no-proxy',
                val='{},localhost,{}'.format(Container.ip(self.container_name),
                                             netutils.get_ip_set(lxc_net)))

        # start the party
        cloud_status_bin = ['openstack-status']
        self.tasker.start_task("Bootstrapping Juju", self.read_progress_output)
        Container.run(self.container_name,
                      "{0} juju --debug bootstrap".format(
                          self.config.juju_home(use_expansion=True)),
                      use_ssh=True,
                      output_cb=self.set_progress_output)
        Container.run(self.container_name,
                      "{0} juju status".format(
                          self.config.juju_home(use_expansion=True)),
                      use_ssh=True)
        self.tasker.stop_current_task()

        self.display_controller.status_info_message(
            "Starting cloud deployment")
        Container.run_status(self.container_name, " ".join(cloud_status_bin),
                             self.config)
Exemplo n.º 13
0
    def do_install(self):
        self.start_task("Bootstrapping Juju")
        self.display_controller.current_state = InstallState.RUNNING

        maas_creds = self.config.maas_creds
        maas_env = utils.load_template('juju-env/maas.yaml')
        maas_env_modified = maas_env.render(
            maas_server=maas_creds['api_host'],
            maas_apikey=maas_creds['api_key'],
            openstack_password=self.config.openstack_password)
        check_output(['mkdir', '-p', self.config.juju_path])
        utils.spew(self.config.juju_environments_path,
                   maas_env_modified)

        utils.render_charm_config(self.config, self.opts)

        utils.ssh_genkey()

        # Set remaining permissions
        self.set_perms()

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

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

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

        cmd = ("JUJU_HOME={0} juju {1} bootstrap {2}".format(
            self.config.cfg_path, 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(
            "JUJU_HOME={} juju status".format(
                self.config.cfg_path),
            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.stop_current_task()

        if self.opts.install_only:
            return

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

            self.drop_privileges()
            os.execvp('openstack-status', args)
        else:
            log.debug("Finished MAAS step, now deploying Landscape.")
            return LandscapeInstallFinal(self,
                                         self.display_controller).run()