Exemplo n.º 1
0
def make_context(resource_json, sudo_password_fn, dry_run=False):
    """Create a Context object (defined in engage.utils.action). This contains
    the resource's metadata in ctx.props, references to the logger and sudo
    password function, and various helper functions. The context object is used
    by individual actions.

    If your resource does not need the sudo password, you can just pass in
    None for sudo_password_fn.
    """
    ctx = Context(resource_json, logger, __file__,
                  sudo_password_fn=sudo_password_fn,
                  dry_run=dry_run)
    ctx.check_port('config_port',
                  JAVA_HOME=unicode)
    ctx.check_port('input_ports.host',
                  cpu_arch=unicode,
                  os_type=unicode,
                  hostname=unicode,
                  os_user_name=unicode)
    ctx.check_port('output_ports.jvm',
                  home=unicode,
                  type=unicode)

    ctx.add("java_exe",
            os.path.join(os.path.join(ctx.props.config_port.JAVA_HOME,
                                      "bin"), "java"))
    return ctx
Exemplo n.º 2
0
def make_context(resource_json, sudo_password_fn, dry_run=False):
    ctx = Context(resource_json, logger, __file__,
                  sudo_password_fn=sudo_password_fn,
                  dry_run=dry_run)
    ctx.checkp("input_ports.macports.macports_exe")
    ctx.checkp("input_ports.python.version")
    ctx.check_port("input_ports.apache",
                   config_file=str,
                   module_config_dir=str,
                   controller_exe=str)
    ctx.checkp("output_ports.wsgi.config_file_path")
    python_version = ctx.props.input_ports.python.version
    if python_version not in variants.keys():
        raise UserError(errors[ERR_UNSUPPORTED_PYTHON_VERSION],
                        msg_args={"pyver":python_version,
                                  "supported_vers":variants.keys().__repr__()})
    ctx.add("variant", variants[python_version])
    return ctx