Exemplo n.º 1
0
    def test_no_storage_account_deploy(self, resource_group,
                                       test_vars):  # noqa: E501, F811
        """
        Deploy a vFXT cluster.
          - create a new VNET
          - do NOT use an Avere-backed storage account
        """
        log = logging.getLogger("test_no_storage_account_deploy")
        atd = test_vars["atd_obj"]
        with open("{}/src/vfxt/azuredeploy-auto.json".format(
                test_vars["build_root"])) as tfile:
            atd.template = json.load(tfile)
        with open(test_vars["ssh_pub_key"], "r") as ssh_pub_f:
            ssh_pub_key = ssh_pub_f.read()
        atd.deploy_params = {
            "adminPassword": os.environ["AVERE_ADMIN_PW"],
            "avereClusterName": atd.deploy_id + "-cluster",
            "avereInstanceType": "Standard_E32s_v3",
            "avereNodeCount": 3,
            "controllerAdminUsername": "******",
            "controllerAuthenticationType": "sshPublicKey",
            "controllerName": atd.deploy_id + "-con",
            "controllerPassword": os.environ["AVERE_CONTROLLER_PW"],
            "controllerSSHKeyData": ssh_pub_key,
            "enableCloudTraceDebugging": True,
            "rbacRoleAssignmentUniqueId": str(uuid4()),
            "createVirtualNetwork": True,
            "virtualNetworkName": atd.deploy_id + "-vnet",
            "virtualNetworkResourceGroup": atd.resource_group,
            "virtualNetworkSubnetName": atd.deploy_id + "-subnet",
            "useAvereBackedStorageAccount": False,
            "avereBackedStorageAccountName": atd.deploy_id + "sa",  # BUG
        }

        if "VFXT_CONTROLLER_IMG_REF_ID" in os.environ:
            atd.deploy_params["controllerImageReferenceId"] = os.environ[
                "VFXT_CONTROLLER_IMG_REF_ID"]

        test_vars["controller_name"] = atd.deploy_params["controllerName"]
        test_vars["controller_user"] = atd.deploy_params[
            "controllerAdminUsername"]
        log.debug("Generated deploy parameters: \n{}".format(
            json.dumps(atd.deploy_params, indent=4)))

        atd.deploy_name = "test_no_storage_account_deploy"
        try:
            deploy_outputs = wait_for_op(atd.deploy()).properties.outputs
            test_vars["cluster_mgmt_ip"] = deploy_outputs["mgmt_ip"]["value"]
            test_vars["cluster_vs_ips"] = split_ip_range(
                deploy_outputs["vserver_ips"]["value"])
            time.sleep(60)
        finally:
            # (c_priv_ip, c_pub_ip) = get_vm_ips(
            #     atd.nm_client, atd.resource_group, test_vars["controller_name"])
            # test_vars["controller_ip"] = c_pub_ip or c_priv_ip
            test_vars["public_ip"] = atd.nm_client.public_ip_addresses.get(
                atd.resource_group,
                "publicip-" + test_vars["controller_name"]).ip_address
            test_vars["controller_ip"] = test_vars["public_ip"]
Exemplo n.º 2
0
def node_ips(cluster_ips, ssh_con, test_vars):
    """Queries the cluster to get a list of IPs for each node."""
    log = logging.getLogger("node_ips")
    last_ex = None
    for _ip in cluster_ips:
        # For resiliency, attempt to issue averecmd calls to known cluster IPs.
        try:
            result = run_averecmd(ssh_client=ssh_con,
                                  password=os.environ["AVERE_ADMIN_PW"],
                                  node_ip=_ip,
                                  method="cluster.get")
            test_vars["averecmd_ip"] = _ip  # this IP worked for averecmd
            c_ips = result["clusterIPs"][0]
            node_ip_range = "{0}-{1}".format(c_ips["firstIP"], c_ips["lastIP"])
            test_vars["cluster_node_ips"] = split_ip_range(node_ip_range)
            return test_vars["cluster_node_ips"]
        except Exception as e:
            log.error("cluster.get failed for IP {}".format(_ip))
            log.error(e)
            last_ex = e
    assert not last_ex