示例#1
0
def config(tmp_path):
    tests_dir = pathlib.Path(__file__).parent.absolute()
    original_config_path = os.path.join(tests_dir, "config.yaml")

    tmp_keys_dir = os.path.join(tmp_path, "keys")
    shutil.copytree(os.path.join(tests_dir, "keys"), tmp_keys_dir)

    test_cert = os.path.join(tmp_path, "keys", "user1.crt")
    test_priv_key = os.path.join(tmp_path, "keys", "user1.pem")
    test_symm_key = os.path.join(tmp_path, "keys", "user1_sym.key")

    # Rewrite config YAML with test paths
    config = EnvYAML(original_config_path)
    config["user"]["certificate"] = test_cert
    config["user"]["private_key"] = test_priv_key
    config["user"]["symmetric_key"] = test_symm_key

    # Point to root certificate
    config["user"]["root_private_key"] = os.path.join(tmp_path,
                                                      "keys/root.pem")
    config["user"]["root_certificate"] = os.path.join(tmp_path,
                                                      "keys/root.crt")

    test_config_path = os.path.join(tmp_path, "config.yaml")

    with open(test_config_path, "w") as out:
        yaml.dump(dict(config), out, default_flow_style=False)

    mc2.set_config(test_config_path)
    return tests_dir
示例#2
0
def config(tmp_path):
    tests_dir = pathlib.Path(__file__).parent.absolute()
    original_config_path = os.path.join(tests_dir, "config.yaml")

    test_cert = os.path.join(tmp_path, "test.crt")
    test_priv_key = os.path.join(tmp_path, "test.pem")
    test_symm_key = os.path.join(tmp_path, "test_sym.key")

    # Rewrite config YAML with test paths
    config = yaml.safe_load(open(original_config_path).read())
    config["user"]["certificate"] = test_cert
    config["user"]["private_key"] = test_priv_key
    config["user"]["symmetric_key"] = test_symm_key

    # Point to root certificate
    config["user"]["root_private_key"] = os.path.join(tests_dir,
                                                      "keys/root.pem")
    config["user"]["root_certificate"] = os.path.join(tests_dir,
                                                      "keys/root.crt")

    test_config_path = os.path.join(tmp_path, "config.yaml")

    with open(test_config_path, "w") as out:
        yaml.dump(config, out, default_flow_style=False)

    mc2.set_config(test_config_path)
    return tests_dir
示例#3
0
parser_launch.add_argument("--xgb",
                           help="Launch Secure XGBoost service",
                           action="store_true")

# Check
parser_check = subparsers.add_parser("check",
                                     help="Check status of compute service")

if __name__ == "__main__":
    mc2_config = os.environ.get("MC2_CONFIG")
    if not mc2_config:
        raise Exception(
            "Please set the environment variable `MC2_CONFIG` to the path of your config file"
        )

    mc2.set_config(mc2_config)
    args = parser.parse_args()
    config = yaml.safe_load(open(mc2_config).read())

    # All data that will be used during computation
    data = config["local"]["data"]

    # Path to schemas for Opaque SQL execution
    schemas = config["local"].get("schemas")

    # Username to use to scp data to cloud
    remote_username = config["cloud"]["remote_username"]

    # Remote data path
    remote_data = config["cloud"]["data_dir"]
示例#4
0
# -------------Stop-------------------
parser_stop = subparsers.add_parser("stop",
                                    help="Stop previously started service")

# -------------Teardown---------------
parser_teardown = subparsers.add_parser("teardown",
                                        help="Teardown Azure resources")

if __name__ == "__main__":
    oc_config = os.environ.get("MC2_CONFIG")
    if not oc_config:
        raise Exception(
            "Please set the environment variable `MC2_CONFIG` to the path of your config file"
        )

    mc2.set_config(oc_config)
    args = parser.parse_args()
    config = EnvYAML(oc_config)

    if args.command == "init":
        # Generate a private key and certificate
        mc2.generate_keypair()

        # Generate a CIPHER_KEY_SIZE byte symmetric key
        mc2.generate_symmetric_key()

    elif args.command == "launch":
        config_launch = config["launch"]

        # If the nodes have been manually specified, don't do anything
        if config_launch.get("head") or config_launch.get("workers"):
示例#5
0
parser_stop = subparsers.add_parser("stop",
                                    help="Stop previously started service")

# -------------Teardown---------------
parser_teardown = subparsers.add_parser("teardown",
                                        help="Teardown Azure resources")

if __name__ == "__main__":  # noqa: C901
    args = parser.parse_args()

    if args.command == "configure":
        config_path = os.path.abspath(os.path.expanduser(args.config_path))
        if not os.path.exists(config_path):
            raise Exception(
                "Specified config path {} does not exist".format(config_path))
        mc2.set_config(config_path)
        logging.info("Set configuration path to {}".format(config_path))
        quit()

    # If we're not configuring the config path, retrieve the config path
    mc2_config = mc2.set_config()
    config = EnvYAML(mc2_config)

    if args.command == "init":
        # Generate a private key and certificate
        mc2.generate_keypair()

        # Generate a CIPHER_KEY_SIZE byte symmetric key
        mc2.generate_symmetric_key()

        logging.info("init finished successfully")
示例#6
0
import os
import pathlib

import mc2client as mc2

print("Setting config file path")
tests_dir = pathlib.Path(__file__).parent.absolute()
config = os.path.join(tests_dir, "../test.yaml")
mc2.set_config(config)

download_path = os.path.join(tests_dir, "dummy_downloaded.txt")

print("Downloading file")
mc2.download_file("dummy.txt", download_path)

if not os.path.isfile(download_path):
    print("Error: Couldn't download file from Azure")
else:
    os.remove(download_path)

print("Deleting container")
mc2.delete_container()

print("Deleting storage")
mc2.delete_storage()

print("Deleting cluster")
mc2.delete_cluster()

print("Deleting resource group")
mc2.delete_resource_group()
示例#7
0
import mc2client as mc2
import mc2client.opaquesql as osql

# TODO: modify the `orchestrator` value in tests/config.yaml to reflect
# Opaque SQL driver IP address
mc2.set_config("config.yaml")
osql.run("opaquesql_example.scala")