コード例 #1
0
def disable_eth3_iface():
    """Disable eth3 interface as nat_iface"""
    if check_ipv6_iface() == return_codes.IPV4_ENABLED:
        print("IPv4 is already enabled")
        sys.exit(return_codes.IPV4_ENABLED.value)
    for service, config in IPV6_IFACE_CONFIGS:
        cfg = load_override_config(service) or {}
        cfg[config] = "eth2"
        save_override_config(service, cfg)
コード例 #2
0
def disable_stateless_agw():
    if check_stateless_agw() == magmad_pb2.CheckStatelessResponse.STATEFUL:
        logging.info("Nothing to disable, AGW is stateful")
    for service, config, value in STATELESS_SERVICE_CONFIGS:
        cfg = load_override_config(service) or {}
        cfg[config] = not value
        save_override_config(service, cfg)

    # restart Sctpd so that eNB connections are reset and local state cleared
    _restart_sctpd()
コード例 #3
0
ファイル: config_stateless_agw.py プロジェクト: markjen/magma
def disable_stateless_agw():
    if check_stateless_services() == return_codes.STATEFUL:
        print("Nothing to disable, AGW is stateful")
        sys.exit(return_codes.STATEFUL.value)
    for service, config, value in STATELESS_SERVICE_CONFIGS:
        cfg = load_override_config(service) or {}
        cfg[config] = not value
        save_override_config(service, cfg)

    # restart Sctpd so that eNB connections are reset and local state cleared
    restart_sctpd()
    sys.exit(check_stateless_services().value)
コード例 #4
0
def enable_stateless_agw():
    if _check_stateless_services() == return_codes.STATELESS:
        print("Nothing to enable, AGW is stateless")
        sys.exit(return_codes.STATELESS.value)
    for service, config, value in STATELESS_SERVICE_CONFIGS:
        cfg = load_override_config(service) or {}
        if service == "pipelined":
            cfg[config] = False
        else:
            cfg[config] = True

        save_override_config(service, cfg)

    # restart Sctpd so that eNB connections are reset and local state cleared
    _restart_sctpd()
    sys.exit(_check_stateless_services().value)
コード例 #5
0
def set_streamer_status(_, args):
    service = args.service
    if args.keys is None:
        keys = STREAMER_KEYS_BY_SERVICE.get(service, [])
    else:
        keys = args.keys.split(',')

    invalid_keys = set(keys) - set(STREAMER_KEYS_BY_SERVICE.get(service, []))
    if invalid_keys:
        print(
            '%s does not have the following streamer config keys: %s' % (
                service,
                invalid_keys,
            ), )
        return

    cfg = service_configs.load_override_config(service)
    if cfg is None:
        cfg = {}

    for key in keys:
        if args.enabled == 'default':
            try:
                cfg.pop(key, None)
            except TypeError:
                # No log level set in the config
                pass
        elif args.enabled == 'True':
            cfg[key] = True
        elif args.enabled == 'False':
            cfg[key] = False
        else:
            print(
                'Invalid argument: %s. '
                'Expected one of "True", "False", "default"' % args.enabled, )
            return

    try:
        service_configs.save_override_config(service, cfg)
    except PermissionError:
        print('Need to run as root to modify override config.')
        return

    print('New override config:')
    pp.pprint(cfg)
    # Currently all streamers require service restart for config to take effect
    _restart_service(service)
コード例 #6
0
ファイル: config_cli.py プロジェクト: btekmen/magma
def set_log_level(args):
    cfg = service_configs.load_override_config(args.service)
    if cfg is None:
        cfg = {}
    if args.log_level == 'default':
        try:
            cfg.pop(LOG_LEVEL_KEY, None)
        except TypeError:
            # No log level set in the config
            pass
    else:
        cfg[LOG_LEVEL_KEY] = args.log_level

    try:
        service_configs.save_override_config(args.service, cfg)
    except PermissionError:
        print('Need to run as root to modify override config. Use "venvsudo".')
        return
    print('New override config:')
    pp.pprint(cfg)
コード例 #7
0
def main():
    """Register a gateway"""
    parser = argparse.ArgumentParser(description="Register a gateway.")
    parser.add_argument(
        "domain",
        metavar="DOMAIN_NAME",
        type=str,
        help="orc8r's domain name",
    )
    parser.add_argument(
        "token",
        metavar="REGISTRATION_TOKEN",
        type=str,
        help="registration token after API call",
    )
    parser.add_argument(
        "--ca-file",
        type=str,
        help="orc8r's root CA file",
    )
    parser.add_argument(
        "--cloud-port",
        type=str,
        help="orc8r's port",
    )
    parser.add_argument(
        "--no-control-proxy",
        action="store_true",
        help="disables writing the control proxy file",
    )
    args = parser.parse_args()
    chan = ServiceRegistry.get_bare_bootstrap_rpc_channel(
        args.domain,
        '8444' if not args.cloud_port else args.cloud_port,
        args.ca_file,
    )
    client = RegistrationStub(chan)
    try:
        req, res = register_handler(client, args)
        msg = textwrap.dedent(
            """
            > Registered gateway
            Hardware ID
            -----------
            {}
            Challenge Key
            -----------
            {}
            Control Proxy
            -----------
            {}
            """,
        )
        print(msg.format(req.hwid, req.challenge_key, res.control_proxy))
    except Exception as e:
        msg = textwrap.dedent(" > Error: {} ")
        print(msg.format(e))
        sys.exit(1)

    if not args.no_control_proxy:
        save_override_config("control_proxy", res.control_proxy)