Example #1
0
 def GetOperationMessage(self, args):
     """See base class."""
     return environments_api_util.Create(
         self.env_ref,
         args.node_count,
         labels=args.labels,
         location=self.zone,
         machine_type=self.machine_type,
         network=self.network,
         subnetwork=self.subnetwork,
         env_variables=args.env_variables,
         airflow_config_overrides=args.airflow_configs,
         service_account=args.service_account,
         oauth_scopes=args.oauth_scopes,
         tags=args.tags,
         disk_size_gb=args.disk_size >> 30,
         python_version=args.python_version,
         image_version=self.image_version,
         airflow_executor_type=args.airflow_executor_type,
         use_ip_aliases=args.enable_ip_alias,
         cluster_secondary_range_name=args.cluster_secondary_range_name,
         services_secondary_range_name=args.services_secondary_range_name,
         cluster_ipv4_cidr_block=args.cluster_ipv4_cidr,
         services_ipv4_cidr_block=args.services_ipv4_cidr,
         private_environment=args.enable_private_environment,
         private_endpoint=args.enable_private_endpoint,
         main_ipv4_cidr=args.main_ipv4_cidr,
         release_track=self.ReleaseTrack())
Example #2
0
 def GetOperationMessage(self, args):
     """Constructs Create message."""
     return environments_api_util.Create(
         self.env_ref,
         args.node_count,
         labels=args.labels,
         location=self.zone,
         machine_type=self.machine_type,
         network=self.network,
         subnetwork=self.subnetwork,
         env_variables=args.env_variables,
         airflow_config_overrides=args.airflow_configs,
         service_account=args.service_account,
         oauth_scopes=args.oauth_scopes,
         tags=args.tags,
         disk_size_gb=args.disk_size >> 30,
         python_version=args.python_version,
         image_version=self.image_version,
         use_ip_aliases=args.enable_ip_alias,
         cluster_secondary_range_name=args.cluster_secondary_range_name,
         services_secondary_range_name=args.services_secondary_range_name,
         cluster_ipv4_cidr_block=args.cluster_ipv4_cidr,
         services_ipv4_cidr_block=args.services_ipv4_cidr,
         kms_key=self.kms_key,
         private_environment=args.enable_private_environment,
         private_endpoint=args.enable_private_endpoint,
         master_ipv4_cidr=args.master_ipv4_cidr,
         web_server_ipv4_cidr=args.web_server_ipv4_cidr,
         cloud_sql_ipv4_cidr=args.cloud_sql_ipv4_cidr,
         web_server_access_control=self.web_server_access_control,
         cloud_sql_machine_type=args.cloud_sql_machine_type,
         web_server_machine_type=args.web_server_machine_type,
         release_track=self.ReleaseTrack())
Example #3
0
    def Run(self, args):
        flags.ValidateDiskSize('--disk-size', args.disk_size)
        env_ref = args.CONCEPTS.environment.Parse()
        env_name = env_ref.Name()
        if not command_util.IsValidEnvironmentName(env_name):
            raise command_util.InvalidUserInputError(
                'Invalid environment name: [{}]. Must match pattern: {}'.
                format(env_name,
                       command_util.ENVIRONMENT_NAME_PATTERN.pattern))

        zone_ref = parsers.ParseZone(args.zone) if args.zone else None
        zone = zone_ref.RelativeName() if zone_ref else None
        machine_type = None
        network = None
        subnetwork = None
        if args.machine_type:
            machine_type = parsers.ParseMachineType(
                args.machine_type,
                fallback_zone=zone_ref.Name()
                if zone_ref else None).RelativeName()
        if args.network:
            network = parsers.ParseNetwork(args.network).RelativeName()
        if args.subnetwork:
            subnetwork = parsers.ParseSubnetwork(
                args.subnetwork,
                fallback_region=env_ref.Parent().Name()).RelativeName()
        operation = environments_api_util.Create(
            env_ref,
            args.node_count,
            labels=args.labels,
            location=zone,
            machine_type=machine_type,
            network=network,
            subnetwork=subnetwork,
            env_variables=args.env_variables,
            airflow_config_overrides=args.airflow_configs,
            service_account=args.service_account,
            oauth_scopes=args.oauth_scopes,
            tags=args.tags,
            disk_size_gb=args.disk_size >> 30,
            release_track=self.ReleaseTrack())
        details = 'with operation [{0}]'.format(operation.name)
        if args. async:
            log.CreatedResource(env_ref.RelativeName(),
                                kind='environment',
                                is_async=True,
                                details=details)
            return operation
        else:
            try:
                operations_api_util.WaitForOperation(
                    operation,
                    'Waiting for [{}] to be created with [{}]'.format(
                        env_ref.RelativeName(), operation.name),
                    release_track=self.ReleaseTrack())
            except command_util.OperationError as e:
                raise command_util.EnvironmentCreateError(
                    'Error creating [{}]: {}'.format(env_ref.RelativeName(),
                                                     str(e)))
 def GetOperationMessage(self, args):
     """Constructs Create message."""
     return environments_api_util.Create(
         self.env_ref,
         args.node_count,
         labels=args.labels,
         location=self.zone,
         machine_type=self.machine_type,
         network=self.network,
         subnetwork=self.subnetwork,
         env_variables=args.env_variables,
         airflow_config_overrides=args.airflow_configs,
         service_account=args.service_account,
         oauth_scopes=args.oauth_scopes,
         tags=args.tags,
         disk_size_gb=args.disk_size >> 30,
         release_track=self.ReleaseTrack())
Example #5
0
 def GetOperationMessage(self, args):
     """See base class."""
     return environments_api_util.Create(
         self.env_ref,
         args.node_count,
         labels=args.labels,
         location=self.zone,
         machine_type=self.machine_type,
         network=self.network,
         subnetwork=self.subnetwork,
         env_variables=args.env_variables,
         airflow_config_overrides=args.airflow_configs,
         service_account=args.service_account,
         oauth_scopes=args.oauth_scopes,
         tags=args.tags,
         disk_size_gb=args.disk_size >> 30,
         python_version=args.python_version,
         image_version=self.image_version,
         airflow_executor_type=args.airflow_executor_type,
         use_ip_aliases=args.enable_ip_alias,
         cluster_secondary_range_name=args.cluster_secondary_range_name,
         services_secondary_range_name=args.services_secondary_range_name,
         cluster_ipv4_cidr_block=args.cluster_ipv4_cidr,
         services_ipv4_cidr_block=args.services_ipv4_cidr,
         max_pods_per_node=args.max_pods_per_node,
         kms_key=self.kms_key,
         private_environment=args.enable_private_environment,
         private_endpoint=args.enable_private_endpoint,
         web_server_ipv4_cidr=args.web_server_ipv4_cidr,
         cloud_sql_ipv4_cidr=args.cloud_sql_ipv4_cidr,
         master_ipv4_cidr=args.master_ipv4_cidr,
         web_server_access_control=self.web_server_access_control,
         cloud_sql_machine_type=args.cloud_sql_machine_type,
         web_server_machine_type=args.web_server_machine_type,
         scheduler_cpu=args.scheduler_cpu,
         worker_cpu=args.worker_cpu,
         min_workers=args.min_workers,
         max_workers=args.max_workers,
         maintenance_window_start=args.maintenance_window_start,
         maintenance_window_end=args.maintenance_window_end,
         maintenance_window_recurrence=args.maintenance_window_recurrence,
         release_track=self.ReleaseTrack())
Example #6
0
    def GetOperationMessage(self, args, is_composer_v1):
        """See base class."""

        create_flags = environments_api_util.CreateEnvironmentFlags(
            node_count=args.node_count,
            environment_size=args.environment_size,
            labels=args.labels,
            location=self.zone,
            machine_type=self.machine_type,
            network=self.network,
            subnetwork=self.subnetwork,
            env_variables=args.env_variables,
            airflow_config_overrides=args.airflow_configs,
            service_account=args.service_account,
            oauth_scopes=args.oauth_scopes,
            tags=args.tags,
            disk_size_gb=environments_api_util.DiskSizeBytesToGB(
                args.disk_size),
            python_version=args.python_version,
            image_version=self.image_version,
            airflow_executor_type=args.airflow_executor_type,
            use_ip_aliases=args.enable_ip_alias,
            cluster_secondary_range_name=args.cluster_secondary_range_name,
            services_secondary_range_name=args.services_secondary_range_name,
            cluster_ipv4_cidr_block=args.cluster_ipv4_cidr,
            services_ipv4_cidr_block=args.services_ipv4_cidr,
            max_pods_per_node=args.max_pods_per_node,
            enable_ip_masq_agent=args.enable_ip_masq_agent,
            kms_key=self.kms_key,
            private_environment=args.enable_private_environment,
            private_endpoint=args.enable_private_endpoint,
            web_server_ipv4_cidr=args.web_server_ipv4_cidr,
            cloud_sql_ipv4_cidr=args.cloud_sql_ipv4_cidr,
            composer_network_ipv4_cidr=args.composer_network_ipv4_cidr,
            master_ipv4_cidr=args.master_ipv4_cidr,
            privately_used_public_ips=args.enable_privately_used_public_ips,
            connection_subnetwork=args.connection_subnetwork,
            web_server_access_control=self.web_server_access_control,
            cloud_sql_machine_type=args.cloud_sql_machine_type,
            web_server_machine_type=args.web_server_machine_type,
            scheduler_cpu=args.scheduler_cpu,
            worker_cpu=args.worker_cpu,
            web_server_cpu=args.web_server_cpu,
            scheduler_memory_gb=environments_api_util.MemorySizeBytesToGB(
                args.scheduler_memory),
            worker_memory_gb=environments_api_util.MemorySizeBytesToGB(
                args.worker_memory),
            web_server_memory_gb=environments_api_util.MemorySizeBytesToGB(
                args.web_server_memory),
            scheduler_storage_gb=environments_api_util.MemorySizeBytesToGB(
                args.scheduler_storage),
            worker_storage_gb=environments_api_util.MemorySizeBytesToGB(
                args.worker_storage),
            web_server_storage_gb=environments_api_util.MemorySizeBytesToGB(
                args.web_server_storage),
            min_workers=args.min_workers,
            max_workers=args.max_workers,
            scheduler_count=args.scheduler_count,
            maintenance_window_start=args.maintenance_window_start,
            maintenance_window_end=args.maintenance_window_end,
            maintenance_window_recurrence=args.maintenance_window_recurrence,
            enable_master_authorized_networks=args.
            enable_master_authorized_networks,
            master_authorized_networks=args.master_authorized_networks,
            release_track=self.ReleaseTrack())

        return environments_api_util.Create(self.env_ref, create_flags,
                                            is_composer_v1)