Esempio n. 1
0
def init_config():
    conf = {
        "KEYSTONE": [
            Argument("keystone-db-pw",
                     "Password for keystone to access DB",
                     "CONFIG_KEYSTONE_DB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("keystone-admin-token",
                     "The token to use for the Keystone service api",
                     "CONFIG_KEYSTONE_ADMIN_TOKEN",
                     uuid.uuid4().hex,
                     validators=[validators.not_empty]),
            Argument("keystone-admin-pw",
                     "The password to use for the Keystone admin user",
                     "CONFIG_KEYSTONE_ADMIN_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("keystone-demo-pw",
                     "The password to use for the Keystone demo user",
                     "CONFIG_KEYSTONE_DEMO_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("keystone-region",
                     "Region name",
                     "CONFIG_KEYSTONE_REGION",
                     "RegionOne",
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 2
0
    def read(self, file, variables_cmd):
        conf = Controller.get().CONF
        config = configparser.RawConfigParser()
        config.optionxform = str
        if not os.path.isfile(file):
            raise IOError("file {0} not found".format(file))

        """ Validate option in answer file"""
        config.read(file)
        if not config.has_section('general'):
            raise KeyError("answer file {0} doesn't have general"
                           " section".format(file))
        conf_file = dict(config['general'])
        conf_file.update(variables_cmd)  # override variables
        conf.update(conf_file)

        try:
            Controller.get().validate_groups(conf_file)
        except Exception as e:
            raise e

        all_args = Controller.get().get_all_arguments()
        for non_supported in (set(conf_file) - set(all_args)):
            LOG.warn("clearstack: variable {0} is not"
                     " supported yet".format(non_supported))
Esempio n. 3
0
def init_config():
    conf = {
        "MONGODB": [
            Argument("mongodb-host",
                     "The IP address or hostname of the MongoDB server",
                     "CONFIG_MONGODB_HOST",
                     util.get_ip(),
                     validators=[validators.ip_or_hostname])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 4
0
def run_all_sequences():
    load_sequences()

    try:
        utils.copy_resources()
    except Exception as e:
        raise e

    try:
        Controller.get().run_all_sequences()
    except Exception as e:
        raise e
    finally:
        utils.get_logs()
Esempio n. 5
0
def init_config():
    conf = {
        "SWIFT": [
            Argument("swift-ks-pw",
                     "Password to use for the Object Storage service to "
                     " authenticate with with the Identity service",
                     "CONFIG_SWIFT_KS_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("swift-storages",
                     "Comma-separated list of devices to use as storage device"
                     " for Object Storage. e.g. /path/to/dev1,/path/to/dev2."
                     " Clearstack DOES NOT creare the file system, you must "
                     "format it with xfs. Leave blank to use a loop device",
                     "CONFIG_SWIFT_STORAGES",
                     '',
                     validators=[validate_storage]),
            Argument("swift-storage-zones",
                     "Number of Object Storage storage zones; this number "
                     "MUST be no larger than the number of configured "
                     "storage devices.",
                     "CONFIG_SWIFT_STORAGE_ZONES",
                     '1',
                     validators=[validators.digit]),
            Argument("swift-storage-replicas",
                     "Number of Object Storage storage replicas; this number "
                     "MUST be no larger than the number of configured "
                     "storage zones.",
                     "CONFIG_SWIFT_STORAGE_REPLICAS",
                     '1',
                     validators=[validators.digit]),
            Argument("swift-hash",
                     "Custom seed number to use for swift_hash_path_suffix in"
                     " /etc/swift/swift.conf. If you do not provide a value, "
                     "a seed number is automatically generated.",
                     "CONFIG_SWIFT_HASH",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("swift-storage-size",
                     "Size of the Object Storage loopback file storage "
                     "device in GB",
                     "CONFIG_SWIFT_STORAGE_SIZE",
                     "2",
                     validators=[validators.digit]),
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 6
0
 def __init__(self):
     conf = Controller.get().CONF
     path = os.path.expanduser(
         conf['CONFIG_PRIVATE_SSH_KEY'])
     path = os.path.realpath(path)
     self.ssh_private_key = path
     self.ssh_user = "******"
Esempio n. 7
0
def load_sequences():
    load_plugins()
    for plugin in Controller.get().get_all_plugins():
        try:
            getattr(plugin, "init_sequences")()
        except AttributeError:
            LOG.debug("missing attribute: init_sequences in %s",
                      plugin.__file__)
Esempio n. 8
0
def init_sequences():
    controller = Controller.get()
    conf = controller.CONF
    if util.str2bool(conf['CONFIG_NOVA_INSTALL']):
        controller.add_sequence("Setting up nova controller",
                                setup_controller)
        controller.add_sequence("Setting up nova computes",
                                setup_computes)
Esempio n. 9
0
def add_arguments(parser):
    load_plugins()
    for group in Controller.get().get_all_groups():
        for argument in group.get_all_arguments():
            parser.add_argument("--{0}".format(argument.cmd_option),
                                action="store",
                                dest=argument.conf_name,
                                help=argument.description,
                                choices=argument.option_list)
Esempio n. 10
0
def get_all_hosts():
    conf = Controller.get().CONF
    hosts = set()
    hosts.update(set(conf["CONFIG_COMPUTE_HOSTS"].split(",")))
    hosts.add(conf["CONFIG_CONTROLLER_HOST"])
    hosts.add(conf["CONFIG_AMQP_HOST"])
    hosts.add(conf["CONFIG_MARIADB_HOST"])
    hosts.add(conf["CONFIG_MONGODB_HOST"])
    return hosts
Esempio n. 11
0
 def generate(self, file, variables_cmd):
     with open(file, "w") as f:
         f.write("[general]\n\n")
         for group in Controller.get().get_all_groups():
             for argument in group.get_all_arguments():
                 f.write("# {0}\n".format(argument.description))
                 value = variables_cmd.get(argument.conf_name,
                                           argument.default_value)
                 f.write("{0}={1}\n\n".format(argument.conf_name, value))
Esempio n. 12
0
def setup_controller():
    conf = Controller.get().CONF
    templates = ['provision']
    recipe = ""
    for template in templates:
        recipe += utils.get_template(template)

    return utils.run_recipe("provision.py", recipe,
                            [conf["CONFIG_CONTROLLER_HOST"]])
Esempio n. 13
0
def init_config():
    conf = {
        "NOVA": [
            Argument("nova-db-pw",
                     "Password for nova to access DB",
                     "CONFIG_NOVA_DB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("nova-ks-pw",
                     "Password to use for the Nova to"
                     " authenticate with Keystone",
                     "CONFIG_NOVA_KS_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 14
0
def load_plugins():
    """ return if plugins already are loaded """
    if Controller.get().get_all_plugins():
        return

    path = "plugins"
    base_module = "clearstack.{0}".format(path)
    directory = "{0}/{1}".format(os.path.dirname(
        os.path.realpath(__file__)), path)
    rx_val = r'^[a-zA-Z]+_[0-9]{3}\.py$'
    files = [fd for fd in os.listdir(directory) if re.match(rx_val, fd)]
    for fd in sorted(files, key=_get_weight):
        plugin = import_module("{0}.{1}".format(base_module, fd.split(".")[0]))
        Controller.get().add_plugin(plugin)
        try:
            getattr(plugin, "init_config")()
        except AttributeError:
            LOG.debug("missing attribute: init_config in %s",
                      plugin.__file__)
Esempio n. 15
0
def init_config():
    conf = {
        "CEILOMETER": [
            Argument("ceilometer-db-pw",
                     "Password for ceilometer to access DB",
                     "CONFIG_CEILOMETER_DB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("ceilometer-ks-pw",
                     "Password to use for Ceilometer to"
                     " authenticate with Keystone",
                     "CONFIG_CEILOMETER_KS_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 16
0
def init_config():
    conf = {
        "GLANCE": [
            Argument("glance-db-pw",
                     "Password for glance to access DB",
                     "CONFIG_GLANCE_DB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("glance-ks-pw",
                     "Password to use for Glance to"
                     " authenticate with Keystone",
                     "CONFIG_GLANCE_KS_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 17
0
def init_config():
    conf = {
        "PROVISION_INIT": [
            Argument("provision-demo",
                     "Specify 'y' to provision for demo usage and testing."
                     " ['y', 'n']",
                     "CONFIG_PROVISION_DEMO",
                     "n",
                     options=['y', 'n'],
                     validators=[validators.y_or_n])
        ],
        "PROVISION_DEMO": [
            Argument("provision-demo-floatrange",
                     "CIDR network address for the floating IP subnet.",
                     "CONFIG_PROVISION_DEMO_FLOATRANGE",
                     "172.24.4.224/28",
                     validators=[validators.cidr]),
            Argument("privision-image-format",
                     'Format for the demo image (default "qcow2").',
                     "CONFIG_PROVISION_IMAGE_FORMAT",
                     "qcow2",
                     validators=[validators.not_empty]),
            Argument("provision-image-name",
                     'The name to be assigned to the demo image in Glance '
                     '(default "cirros")',
                     "CONFIG_PROVISION_IMAGE_NAME",
                     "cirros",
                     validators=[validators.not_empty]),
            Argument("provision-image-url",
                     'A URL or local file location for an image to download'
                     'and provision in Glance (defaults to a URL for a '
                     'recent "cirros" image).',
                     "CONFIG_PROVISION_IMAGE_URL",
                     'http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-'
                     'x86_64-disk.img',
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 18
0
def setup_computes():
    conf = Controller.get().CONF
    if util.str2bool(conf['CONFIG_CLEAN_COMPUTE_HOSTS']):
        try:
            utils.run_recipe("{0}".format("compute_cleanup.sh"),
                             utils.get_template("compute_cleanup.sh"),
                             conf["CONFIG_COMPUTE_HOSTS"].split(','))
        except:
            pass

    template = "pre_compute.sh"
    recipe = utils.get_template(template)
    return utils.run_recipe("{0}".format(template), recipe,
                            conf["CONFIG_COMPUTE_HOSTS"].split(','))
Esempio n. 19
0
def setup_controller():
    conf = Controller.get().CONF
    if util.str2bool(conf['CONFIG_CLEAN_CONTROLLER_HOST']):
        try:
            utils.run_recipe("{0}".format("controller_cleanup.sh"),
                             utils.get_template("controller_cleanup.sh"),
                             [conf["CONFIG_CONTROLLER_HOST"]])
        except:
            pass

    template = "pre_controller.sh"
    recipe = utils.get_template(template)
    return utils.run_recipe("{0}".format(template), recipe,
                            [conf["CONFIG_CONTROLLER_HOST"]])
Esempio n. 20
0
def init_config():
    conf = {
        "MARIADB": [
            Argument("mariadb-host",
                     "The IP address or hostname of the MariaDB server",
                     "CONFIG_MARIADB_HOST",
                     util.get_ip(),
                     validators=[validators.ip_or_hostname]),
            Argument("mariadb-user",
                     "User for mariadb authentication",
                     "CONFIG_MARIADB_USER",
                     "root",
                     validators=[validators.not_empty]),
            Argument("mariadb-pw",
                     "Password for mariadb user",
                     "CONFIG_MARIADB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 21
0
def init_config():
    conf = {
        "HEAT": [
            Argument("heat-db-pw",
                     "Password for heat to access DB",
                     "CONFIG_HEAT_DB_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("heat-ks-pw",
                     "Password to use for Heat to"
                     " authenticate with Keystone",
                     "CONFIG_HEAT_KS_PW",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("heat-domain",
                     "Name of the Identity domain for Orchestration.",
                     "CONFIG_HEAT_DOMAIN",
                     "heat",
                     validators=[validators.not_empty]),
            Argument("heat-domain-admin",
                     "Name of the Identity domain administrative user for "
                     "Orchestration.",
                     "CONFIG_HEAT_DOMAIN_ADMIN",
                     "heat_domain_admin",
                     validators=[validators.not_empty]),
            Argument("heat-domain-password",
                     "Password for the Identity domain administrative user "
                     "for Orchestration",
                     "CONFIG_HEAT_DOMAIN_PASSWORD",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 22
0
def init_config():
    conf = {
        "AMQP": [
            Argument("amqp-auth-user",
                     "User for amqp authentication",
                     "CONFIG_AMQP_AUTH_USER",
                     "amqp_user",
                     validators=[validators.not_empty]),
            Argument("amqp-auth-pw",
                     "Password for amqp user authentication",
                     "CONFIG_AMQP_AUTH_PASSWORD",
                     utils.generate_random_pw(),
                     validators=[validators.not_empty]),
            Argument("amqp-host",
                     "The IP address or hostname of the server on which"
                     " to install the AMQP service",
                     "CONFIG_AMQP_HOST",
                     util.get_ip(),
                     validators=[validators.ip_or_hostname])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])
Esempio n. 23
0
def generate_conf_file(conf_file):
    """ create defaults.conf file """
    conf = Controller.get().CONF
    config_file = configparser.RawConfigParser()
    config_file.optionxform = str
    dir_name = os.path.dirname(conf_file)

    if not os.path.isdir(dir_name):
        os.makedirs(dir_name)

    config_file.add_section("general")
    for key, value in conf.items():
        config_file.set("general", key, '{0}'.format(value))

    with open(conf_file, 'w') as f:
        config_file.write(f)
Esempio n. 24
0
def generate_admin_openrc():
    conf = Controller.get().CONF
    home = os.getenv('HOME')
    with open("{0}/admin-openrc.sh".format(home), "w") as f:
        f.write('export OS_PROJECT_DOMAIN_ID=default\n')
        f.write('export OS_USER_DOMAIN_ID=default\n')
        f.write('export OS_PROJECT_NAME=admin\n')
        f.write('export OS_USERNAME="******"\n')
        f.write('export OS_TENANT_NAME="admin"\n')
        f.write('export OS_AUTH_URL=http://{0}:35357/v3\n'
                .format(conf['CONFIG_CONTROLLER_HOST']))
        f.write('export OS_REGION_NAME="{0}"\n'
                .format(conf['CONFIG_KEYSTONE_REGION']))
        f.write('export OS_PASSWORD={0}\n'
                .format(conf['CONFIG_KEYSTONE_ADMIN_PW']))
        f.write('export OS_IDENTITY_API_VERSION=3\n')
Esempio n. 25
0
    def test_hosts(self, _hosts):
        hosts = set(_hosts)
        connection = None
        conf = Controller.get().CONF

        util.remove_localhost(hosts)

        if not conf['CONFIG_PRIVATE_SSH_KEY'] and hosts:
            raise Exception("CONFIG_PRIVATE_SSH_KEY: missing private key")

        for host in hosts:
            try:
                connection = self.connect(self.ssh_user, self.ssh_private_key,
                                          host)
                self.test_python_in_host(host, connection)
            except Exception as e:
                raise Exception("host {0}: {1}".format(host, str(e)))
            finally:
                if connection:
                    connection.close()
Esempio n. 26
0
def setup_keystone():
    conf = Controller.get().CONF
    recipe = utils.get_template('keystone')
    return utils.run_recipe("keystone.py", recipe,
                            [conf["CONFIG_CONTROLLER_HOST"]])
Esempio n. 27
0
def init_sequences():
    Controller.get().add_sequence("Setting up keystone", setup_keystone)
Esempio n. 28
0
def setup_mariadb(template):
    conf = Controller.get().CONF
    recipe = utils.get_template(template)
    return utils.run_recipe("{0}.py".format(template), recipe,
                            [conf["CONFIG_MARIADB_HOST"]])
Esempio n. 29
0
def init_sequences():
    controller = Controller.get()
    controller.add_sequence("Setting up mariadb",
                            setup_mariadb, args=['mariadb'])
Esempio n. 30
0
def init_config():
    home = os.getenv('HOME')
    if home is None:
        home = "/root"
    conf = {
        "GENERAL": [
            Argument("debug-mode",
                     "Set to 'y' if you want to run"
                     " OpenStack services in debug mode",
                     "CONFIG_DEBUG_MODE",
                     "n",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("ssh-private-key",
                     "Path to the private SSH key file",
                     "CONFIG_PRIVATE_SSH_KEY",
                     "",
                     validators=[validate_ssh_key]),
            Argument("controller-host",
                     "IP address or hostname of the server on which "
                     " to install OpenStack services specific to"
                     " controller role such as API servers",
                     "CONFIG_CONTROLLER_HOST",
                     util.get_ip(),
                     validators=[validators.ip_or_hostname]),
            Argument("clean-controller-host",
                     "Set 'y' if you would like Clearstack to "
                     "clean up controller host",
                     "CONFIG_CLEAN_CONTROLLER_HOST",
                     "y",
                     validators=[validators.y_or_n]),
            Argument("compute-hosts",
                     "List of IP addresses or hostnames of the server on which"
                     " to install the Nova compute service",
                     "CONFIG_COMPUTE_HOSTS",
                     util.get_ip(),
                     validators=[validators.ip_or_hostname]),
            Argument("clean-compute-hosts",
                     "Set 'y' if you would like Clearstack to "
                     "clean up compute hosts",
                     "CONFIG_CLEAN_COMPUTE_HOSTS",
                     "y",
                     validators=[validators.y_or_n]),
            Argument("mariadb-install",
                     "Set 'y' if you would like Clearstack to install MariaDB",
                     "CONFIG_MARIADB_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("mongodb-install",
                     "Set 'y' if you would like Clearstack to install MongoDB",
                     "CONFIG_MONGODB_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("http-service",
                     "Set 'apache2' or 'nginx' as HTTP Service for Horizon, "
                     "Keystone and Nova API web services",
                     "CONFIG_HTTP_SERVICE",
                     "nginx",
                     options=['nginx', 'apache2'],
                     validators=[validators.not_empty]),
            Argument("glance-install ",
                     "Set 'y' if you would like Clearstack to install"
                     " Openstack image (glance)",
                     "CONFIG_GLANCE_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("nova-install ",
                     "Set 'y' if you would like Clearstack to install"
                     " Openstack compute (nova)",
                     "CONFIG_NOVA_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("horizon-install",
                     "Set 'y' if you would like Clearstack to install"
                     " OpenStack dashboard (horizon)",
                     "CONFIG_HORIZON_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("neutron-install",
                     "Set 'y' if you would like Clearstack to install"
                     " OpenStack Networking (neutron)",
                     "CONFIG_NEUTRON_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("ceilometer-install",
                     "Set 'y' if you would like Clearstack to install"
                     " OpenStack Telemetry (ceilometer)",
                     "CONFIG_CEILOMETER_INSTALL",
                     "y",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("heat-install",
                     "Set 'y' if you would like Clearstack to install"
                     " OpenStack Orchestration (heat)",
                     "CONFIG_HEAT_INSTALL",
                     "n",
                     options=['y', 'n'],
                     validators=[validators.y_or_n]),
            Argument("swift-install",
                     "Set 'y' if you would like Clearstack to install"
                     " OpenStack Object Storage (swift)",
                     "CONFIG_SWIFT_INSTALL",
                     "n",
                     options=['y', 'n'],
                     validators=[validators.y_or_n])
        ]
    }

    for group in conf:
        Controller.get().add_group(group, conf[group])