Ejemplo n.º 1
0
    def run(self, reinstall=False, refresh_conf=False, overwrite=False):
        if self.uninstall:
            LOG.info("Uninstalling snail _@/")
            if not common.check_dir(self.install_path):
                LOG.error("Not installed. Not that bad really.")
                common.exit(1)
            common.remove_dir(self.install_path)
            common.exit(0)
        LOG.info("Installing snail _@/")
        if not common.check_basics(require_super=False, require_venv=False):
            common.exit(1)

        self.check_snail_conf()

        if not self.backup_existing_supernova_conf(overwrite=overwrite):
            exit(1)
        if not self.backup_existing_inova_conf(overwrite=overwrite):
            exit(1)
        if not refresh_conf:
            LOG.info("Starting install")
            self.install(reinstall)
            LOG.info("Finished install")
        LOG.info("Generating supernova and inova conf")
        self.generate_supernova_conf()
        LOG.info("Finished generating supernova and inova conf")
        LOG.info("Configuring keyrings")
        if not self.configure_keyring():
            if not DEBUG:
                self.abort()
        LOG.info("Done configuring keyrings")
        self.confirm_inovas()
Ejemplo n.º 2
0
    def install(self, reinstall=False):
        if common.check_dir(self.install_path):
            if not reinstall:
                raise AlreadyInstalledException()
            else:
                common.remove_dir(self.install_path)

        if not common.mkdir_p(self.install_path):
            LOG.error("Could not create installation path, %s" % self.install_path)
            self.abort()

        if not common.install_system_package("curl git python-dev python-pip"):
            LOG.error("Could not install basic packages")
            self.abort()

        if not common.install_python_package("virtualenv", with_sudo=True):
            LOG.error("Could not install virtualenv")
            self.abort()

        venv_path = "%s/%s" % (self.install_path, ".venv")
        if not common.install_virtual_env("(_@/)", venv_path):
            LOG.error("Could not create virtualenv")
            self.abort()

        if not common.enter_virtualenv(venv_path):
            LOG.error("Could not enter virtualenv")
            self.abort()

        packages = ["pip", "distribute", "eventlet", "pexpect", "rackspace-novaclient"]
        if not common.install_python_package(packages):
            LOG.error("Could not install %s" % packages)
            self.abort()

        pkg = "github.com/openstack/python-novaclient.git"
        if not common.install_git_package(pkg, "python-novaclient"):
            LOG.error("Could not install %s" % pkg)
            self.abort()

        pkg = "github.com/emonty/rackspace-auth-openstack.git"
        if not common.install_git_package(pkg, "rackspace-auth-openstack"):
            LOG.error("Could not install %s" % pkg)
            self.abort()

        pkg = "github.com/major/supernova.git"
        if not common.install_git_package(pkg, "supernova"):
            LOG.error("Could not install %s" % pkg)
            self.abort()

        pkg = self.inova_repo
        if not common.install_git_package(pkg, "inova-login"):
            LOG.error("Could not install %s" % pkg)
            self.abort()
Ejemplo n.º 3
0
 def abort(self):
     common.remove_dir(self.install_path)
     common.exit(1)
Ejemplo n.º 4
0
    def generate_supernova_conf(self):
        repo = self.template_repo
        secure_dir = "%s/%s" % (self.install_path, "secure")
        if common.check_dir(secure_dir):
            common.remove_dir(secure_dir)
        if not common.clone_from_git_repo(repo, secure_dir):
            LOG.error("Could not clone %s" % repo)
            self.abort()

        seed_file = "%s/snail/supernova_seed.conf" % secure_dir
        remote_config = ConfigParser.ConfigParser()
        remote_config.readfp(open(seed_file))

        snail_conf = "%s/snail.conf" % common.get_home()
        if not common.check_file(snail_conf):
            LOG.error("Could not locate snail.conf")
            self.abort()
        snail_config = ConfigParser.ConfigParser()
        snail_config.readfp(open(snail_conf))

        inovas = {}
        supernovas = {}
        inova_template = None
        sn_template = None

        config_list = [remote_config, snail_config]
        ignored_keys = ["pw_type"]
        for config in config_list:
            sections = config.sections()
            for section in sections:
                td = {}
                for k, v in config.items(section):
                    if k in ignored_keys:
                        continue
                    td[k] = v
                if section == "inova-template":
                    inova_template = td
                    continue
                elif section == "supernova-template":
                    sn_template = td
                    continue
                if not config.has_option(section, "type"):
                    continue
                type = config.get(section, "type")
                if type == "inova":
                    if section in inovas:
                        inovas[section].update(td)
                    else:
                        inovas[section] = td
                elif type == "supernova":
                    if section in supernovas:
                        supernovas[section].update(td)
                    else:
                        supernovas[section] = td

        if not inova_template or not sn_template:
            LOG.error("Could not find inova or supernova template anywhere")
            common.self.abort()

        out_file = "%s/snail/supernova_out.conf" % secure_dir
        if common.check_file(out_file):
            common.remove_file(out_file)
        out_config = ConfigParser.ConfigParser()
        out_config.add_section("snail")
        out_config.set("snail", "version", "0.1")

        out_list = [(inovas, inova_template), (supernovas, sn_template)]
        for listing, template in out_list:
            for title, items in listing.items():
                out_config.add_section(title)
                for template_key, template_value in template.items():
                    src = template_value.lower()
                    value = template_value
                    if src == "title":
                        value = title
                    if src in items:
                        value = items[template_value.lower()]
                    if template_key.lower() in items:
                        value = items[template_key.lower()]
                    out_config.set(title, template_key.upper(), value)

                for template_key, template_value in template.items():
                    src = template_value.lower()
                    if src in items:
                        del items[template_value.lower()]

                for item_key, item_value in items.items():
                    if not out_config.has_option(title, item_key):
                        out_config.set(title, item_key, item_value)
        out_config.write(open(out_file, "w+"))
        sn_conf = "%s/.supernova" % common.get_home()
        common.copy_file(out_file, sn_conf)

        seed_file = "%s/snail/inova_seed.conf" % secure_dir
        remote_config = ConfigParser.ConfigParser()
        remote_config.readfp(open(seed_file))

        out_file = "%s/snail/inovalogin_out.conf" % secure_dir
        if common.check_file(out_file):
            common.remove_file(out_file)
        out_config = ConfigParser.ConfigParser()

        out_config.add_section("inova-login")
        for k, v in remote_config.items("inova-login"):
            value = v
            if v == "USER":
                value = self.inova_user
            out_config.set("inova-login", k, value)
        out_config.set("inova-login", "snail_gen", "1")
        out_config.write(open(out_file, "w+"))
        sn_conf = "%s/.inova-login" % common.get_home()
        common.copy_file(out_file, sn_conf)