Exemplo n.º 1
0
def generate(wp_env,
             wp_url,
             wp_title=None,
             wp_tagline=None,
             admin_password=None,
             theme=None,
             theme_faculty=None,
             installs_locked=None,
             updates_automatic=None,
             extra_config=None,
             **kwargs):
    """
    This command may need more params if reference to them are done in YAML file. In this case, you'll see an
    error explaining which params are needed and how they can be added to command line
    """

    # if nothing is specified we want a locked install
    if installs_locked is None:
        installs_locked = DEFAULT_CONFIG_INSTALLS_LOCKED
    else:
        installs_locked = cast_boolean(installs_locked)

    # if nothing is specified we want automatic updates
    if updates_automatic is None:
        updates_automatic = DEFAULT_CONFIG_UPDATES_AUTOMATIC
    else:
        updates_automatic = cast_boolean(updates_automatic)

    # FIXME: When we will use 'unit_id' from CSV file, add parameter here OR dynamically get it from AD
    all_params = {
        'openshift_env': wp_env,
        'wp_site_url': wp_url,
        'theme': theme or DEFAULT_THEME_NAME,
        'installs_locked': installs_locked,
        'updates_automatic': updates_automatic
    }

    # Adding parameters if given
    if theme_faculty is not None:
        all_params['theme_faculty'] = theme_faculty

    if wp_title is not None:
        all_params['wp_site_title'] = wp_title

    if wp_tagline is not None:
        all_params['wp_tagline'] = wp_tagline

    # if we have extra configuration to load,
    if extra_config is not None:
        all_params = _add_extra_config(extra_config, all_params)

    wp_generator = WPGenerator(all_params, admin_password=admin_password)

    if not wp_generator.generate():
        raise Exception("Generation failed. More info above")

    print("Successfully created new WordPress site at {}".format(
        wp_generator.wp_site.url))
Exemplo n.º 2
0
def generate(wp_env,
             wp_url,
             wp_title=None,
             admin_password=None,
             unit_name=None,
             theme=None,
             theme_faculty=None,
             installs_locked=None,
             updates_automatic=None,
             **kwargs):

    # if nothing is specified we want a locked install
    if installs_locked is None:
        installs_locked = DEFAULT_CONFIG_INSTALLS_LOCKED
    else:
        installs_locked = cast_boolean(installs_locked)

    # if nothing is specified we want automatic updates
    if updates_automatic is None:
        updates_automatic = DEFAULT_CONFIG_UPDATES_AUTOMATIC
    else:
        updates_automatic = cast_boolean(updates_automatic)

    wp_generator = WPGenerator(wp_env,
                               wp_url,
                               wp_default_site_title=wp_title,
                               admin_password=admin_password,
                               unit_name=unit_name,
                               theme=theme or DEFAULT_THEME_NAME,
                               theme_faculty=theme_faculty,
                               installs_locked=installs_locked,
                               updates_automatic=updates_automatic)
    if not wp_generator.generate():
        raise SystemExit("Generation failed. More info above")

    print("Successfully created new WordPress site at {}".format(
        wp_generator.wp_site.url))