コード例 #1
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def stop_improv():
    """Stop a simulated Juju environment."""
    log('Stopping the staging backend.')
    with su('root'):
        service_control(IMPROV, STOP)
    log('Removing the staging Upstart script.')
    cmd_log(run('rm', '-f', IMPROV_INIT_PATH))
コード例 #2
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def stop_agent():
    """Stop the Juju agent."""
    log('Stopping the API agent.')
    with su('root'):
        service_control(AGENT, STOP)
    log('Removing the API agent Upstart script.')
    cmd_log(run('rm', '-f', AGENT_INIT_PATH))
コード例 #3
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def stop_haproxy_apache():
    """Stop the haproxy and Apache services."""
    log('Stopping the haproxy and Apache services.')
    with su('root'):
        service_control(HAPROXY, STOP)
        service_control(APACHE, STOP)
    remove_haproxy_setup()
    remove_apache_setup()
コード例 #4
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def start_haproxy_apache(
        build_dir, serve_tests, ssl_cert_path, secure):
    """Set up and start the haproxy and Apache services."""
    log('Setting up Apache and haproxy.')
    setup_apache_config(build_dir, serve_tests)
    setup_haproxy_config(ssl_cert_path, secure)
    log('Starting the haproxy and Apache services.')
    with su('root'):
        service_control(APACHE, RESTART)
        service_control(HAPROXY, RESTART)
コード例 #5
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def start_builtin_server(
        build_dir, ssl_cert_path, serve_tests, sandbox, builtin_server_logging,
        insecure, charmworld_url):
    """Start the builtin server."""
    write_builtin_server_startup(
        build_dir, ssl_cert_path, serve_tests=serve_tests, sandbox=sandbox,
        builtin_server_logging=builtin_server_logging, insecure=insecure,
        charmworld_url=charmworld_url)
    log('Starting the builtin server.')
    with su('root'):
        service_control(BUILTIN_SERVER, RESTART)
コード例 #6
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def start_improv(staging_env, ssl_cert_path):
    """Start a simulated juju environment using ``improv.py``."""
    log('Setting up the staging Upstart script.')
    context = {
        'juju_dir': JUJU_AGENT_DIR,
        'keys': ssl_cert_path,
        'port': API_PORT,
        'staging_env': staging_env,
    }
    render_to_file('juju-api-improv.conf.template', context, IMPROV_INIT_PATH)
    log('Starting the staging backend.')
    with su('root'):
        service_control(IMPROV, START)
コード例 #7
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def start_agent(ssl_cert_path, read_only=False):
    """Start the Juju agent and connect to the current environment."""
    # Retrieve the Zookeeper address from the start up script.
    unit_name = os.path.basename(
        os.path.realpath(os.path.join(CURRENT_DIR, '..')))
    agent_file = os.path.join(SYS_INIT_DIR, 'juju-{}.conf'.format(unit_name))
    zookeeper = get_zookeeper_address(agent_file)
    log('Setting up the API agent Upstart script.')
    context = {
        'juju_dir': JUJU_AGENT_DIR,
        'keys': ssl_cert_path,
        'port': API_PORT,
        'zookeeper': zookeeper,
        'read_only': read_only
    }
    render_to_file('juju-api-agent.conf.template', context, AGENT_INIT_PATH)
    log('Starting the API agent.')
    with su('root'):
        service_control(AGENT, START)
コード例 #8
0
ファイル: utils.py プロジェクト: bac/juju-gui-charm
def start_builtin_server(
        ssl_cert_path, serve_tests, sandbox, builtin_server_logging,
        insecure, charmworld_url, env_password=None, env_uuid=None,
        juju_version=None, debug=False, port=None, jem_location=None,
        interactive_login=False):
    """Start the builtin server."""
    if (port is not None) and not port_in_range(port):
        # Do not use the user provided port if it is not valid.
        port = None
    write_builtin_server_startup(
        ssl_cert_path, serve_tests=serve_tests, sandbox=sandbox,
        builtin_server_logging=builtin_server_logging, insecure=insecure,
        charmworld_url=charmworld_url, env_password=env_password,
        env_uuid=env_uuid, juju_version=juju_version,
        debug=debug, port=port, jem_location=jem_location,
        interactive_login=interactive_login)
    log('Starting the builtin server.')
    with su('root'):
        service_control(GUISERVER, RESTART)
コード例 #9
0
    def test_service_control(self):
        # Collect commands that have been run
        commands_set = {}

        def mock_service(*args):
            service = args[0]
            action = args[1]
            if service not in commands_set:
                commands_set[service] = []
            if ((len(commands_set[service]) > 1 and
                 commands_set[service][-1] == 'stop' and
                 action == 'restart')):
                # Service is stopped - so needs 'start'
                # action as restart will fail
                commands_set[service].append(action)
                raise CalledProcessError(1, repr(args))
            else:
                commands_set[service].append(action)

        result = ['start', 'stop', 'restart', 'start']

        # Monkey patch service command
        self._patch_command(mock_service)
        charmhelpers.service_control('myservice', 'start')
        charmhelpers.service_control('myservice', 'stop')
        charmhelpers.service_control('myservice', 'restart')
        self.assertEquals(result, commands_set['myservice'])
コード例 #10
0
    def test_service_control(self):
        # Collect commands that have been run
        commands_set = {}

        def mock_service(*args):
            service = args[0]
            action = args[1]
            if service not in commands_set:
                commands_set[service] = []
            if ((len(commands_set[service]) > 1
                 and commands_set[service][-1] == 'stop'
                 and action == 'restart')):
                # Service is stopped - so needs 'start'
                # action as restart will fail
                commands_set[service].append(action)
                raise CalledProcessError(1, repr(args))
            else:
                commands_set[service].append(action)

        result = ['start', 'stop', 'restart', 'start']

        # Monkey patch service command
        self._patch_command(mock_service)
        charmhelpers.service_control('myservice', 'start')
        charmhelpers.service_control('myservice', 'stop')
        charmhelpers.service_control('myservice', 'restart')
        self.assertEquals(result, commands_set['myservice'])
コード例 #11
0
def start_builtin_server(build_dir,
                         ssl_cert_path,
                         serve_tests,
                         sandbox,
                         builtin_server_logging,
                         insecure,
                         charmworld_url,
                         port=None):
    """Start the builtin server."""
    if (port is not None) and not port_in_range(port):
        # Do not use the user provided port if it is not valid.
        port = None
    write_builtin_server_startup(build_dir,
                                 ssl_cert_path,
                                 serve_tests=serve_tests,
                                 sandbox=sandbox,
                                 builtin_server_logging=builtin_server_logging,
                                 insecure=insecure,
                                 charmworld_url=charmworld_url,
                                 port=port)
    log('Starting the builtin server.')
    with su('root'):
        service_control(GUISERVER, RESTART)
コード例 #12
0
ファイル: utils.py プロジェクト: CiscoSystems/jujucharm-n1k
def stop_builtin_server():
    """Stop the builtin server."""
    log('Stopping the builtin server.')
    with su('root'):
        service_control(BUILTIN_SERVER, STOP)
    cmd_log(run('rm', '-f', GUISERVER_INIT_PATH))
コード例 #13
0
def stop_builtin_server():
    """Stop the builtin server."""
    log('Stopping the builtin server.')
    with su('root'):
        service_control(GUISERVER, STOP)
    cmd_log(run('rm', '-f', GUISERVER_INIT_PATH))