Ejemplo n.º 1
0
    def _create_resource_group(cluster_details: dict) -> None:
        """Create the resource group if it does not exist.

        Args:
            cluster_details (dict): details of the cluster.

        Returns:
            None.
        """

        # Get params
        subscription = cluster_details["cloud"]["subscription"]
        resource_group = cluster_details["cloud"]["resource_group"]

        # Check if Azure CLI is installed, and print version
        azure_version = AzureController.get_version()
        logger.info_green(
            f"Your Azure CLI version: {azure_version['azure-cli']}")

        # Set subscription id
        AzureController.set_subscription(subscription=subscription)
        logger.info_green(f"Set subscription to '{subscription}'")

        # Check and create resource group
        resource_group_info = AzureController.get_resource_group(
            resource_group=resource_group)
        if resource_group_info:
            logger.warning_yellow(
                f"Azure resource group '{resource_group}' already exists")
        else:
            AzureController.create_resource_group(
                resource_group=resource_group,
                location=cluster_details["cloud"]["location"])
            logger.info_green(f"Resource group '{resource_group}' is created")
Ejemplo n.º 2
0
 def _create_virtual_machines(cls, test_config: dict):
     cls.build_arm_parameters(
         build_config={
             "location": cls.location,
             "default_username": cls.default_username,
             "default_public_key": test_config["cloud/default_public_key"],
             "ssh": {
                 "port": GlobalParams.DEFAULT_SSH_PORT
             },
             "api_server": {
                 "port": GrassParams.DEFAULT_API_SERVER_PORT
             }
         },
         export_path=cls.arm_parameters_file_export_path)
     AzureController.set_subscription(
         subscription=test_config["cloud/subscription"])
     AzureController.create_resource_group(
         resource_group=cls.resource_group, location=cls.location)
     AzureController.start_deployment(
         resource_group=cls.resource_group,
         deployment_name="cluster",
         template_file_path=cls.arm_template_file_path,
         parameters_file_path=cls.arm_parameters_file_export_path)