Пример #1
0
def load_arguments(self, _):
    with self.argument_context('aro') as c:
        c.argument('location',
                   validator=get_default_location_from_resource_group)
        c.argument('resource_name',
                   name_type,
                   help='Name of cluster.',
                   validator=validate_resource_name)
        c.argument('tags', tags_type)

        c.argument('client_id',
                   help='Client ID of cluster service principal.',
                   validator=validate_client_id)
        c.argument('client_secret',
                   help='Client secret of cluster service principal.',
                   validator=validate_client_secret)

        c.argument('pod_cidr',
                   help='CIDR of pod network.',
                   validator=validate_cidr('pod_cidr'))
        c.argument('service_cidr',
                   help='CIDR of service network.',
                   validator=validate_cidr('service_cidr'))

        c.argument('master_vm_size', help='Size of master VMs.')

        c.argument('worker_vm_size', help='Size of worker VMs.')
        c.argument('worker_vm_disk_size_gb',
                   help='Disk size in GB of worker VMs.',
                   validator=validate_worker_vm_disk_size_gb)
        c.argument('worker_count',
                   help='Count of worker VMs.',
                   validator=validate_worker_count)

        c.argument('vnet_resource_group_name',
                   resource_group_name_type,
                   options_list=['--vnet-resource-group'],
                   help='Name of vnet resource group.',
                   validator=validate_vnet_resource_group_name)
        c.argument(
            'vnet',
            help=
            'Name or ID of vnet.  If name is supplied, `--vnet-resource-group` must be supplied.',
            validator=validate_vnet)
        c.argument(
            'master_subnet',
            help=
            'Name or ID of master vnet subnet.  If name is supplied, `--vnet` must be supplied.',
            validator=validate_subnet('master_subnet'))
        c.argument(
            'worker_subnet',
            help=
            'Name or ID of worker vnet subnet.  If name is supplied, `--vnet` must be supplied.',
            validator=validate_subnet('worker_subnet'))
Пример #2
0
def test_validate_subnet(
        # Mocked functions:
        is_valid_resource_id_mock,
        parse_resource_id_mock,
        get_subscription_id_mock,
        get_mgmt_service_client_mock,

        # Test cases parameters:
        test_description,
        namespace,
        key,
        is_valid_resource_id_mock_return_value,
        parse_resource_id_mock_return_value,
        get_subscription_id_mock_return_value,
        get_mgmt_service_client_mock_return_value,
        cmd,
        expected_exception):
    is_valid_resource_id_mock.return_value = is_valid_resource_id_mock_return_value
    parse_resource_id_mock.return_value = parse_resource_id_mock_return_value
    get_subscription_id_mock.return_value = get_subscription_id_mock_return_value
    get_mgmt_service_client_mock.return_value = get_mgmt_service_client_mock_return_value

    validate_subnet_fn = validate_subnet(key)

    if expected_exception is None:
        validate_subnet_fn(cmd, namespace)
    else:
        with pytest.raises(expected_exception):
            validate_subnet_fn(cmd, namespace)
Пример #3
0
def load_arguments(self, _):
    with self.argument_context('aro') as c:
        c.argument('location',
                   validator=get_default_location_from_resource_group)
        c.argument('resource_name', name_type, help='Name of cluster.')
        c.argument('tags', tags_type)

        c.argument('pull_secret',
                   help='Pull secret of cluster.',
                   validator=validate_pull_secret)
        c.argument('domain',
                   help='Domain of cluster.',
                   validator=validate_domain)
        c.argument('cluster_resource_group',
                   help='Resource group of cluster.',
                   validator=validate_cluster_resource_group)

        c.argument('client_id',
                   help='Client ID of cluster service principal.',
                   validator=validate_client_id)
        c.argument('client_secret',
                   help='Client secret of cluster service principal.',
                   validator=validate_client_secret)

        c.argument('pod_cidr',
                   help='CIDR of pod network.',
                   validator=validate_cidr('pod_cidr'))
        c.argument('service_cidr',
                   help='CIDR of service network.',
                   validator=validate_cidr('service_cidr'))

        c.argument('master_vm_size', help='Size of master VMs.')

        c.argument('worker_vm_size', help='Size of worker VMs.')
        c.argument('worker_vm_disk_size_gb',
                   type=int,
                   help='Disk size in GB of worker VMs.',
                   validator=validate_worker_vm_disk_size_gb)
        c.argument('worker_count',
                   type=int,
                   help='Count of worker VMs.',
                   validator=validate_worker_count)

        c.argument('apiserver_visibility',
                   arg_type=get_enum_type(['Private', 'Public']),
                   help='API server visibility.',
                   validator=validate_visibility('apiserver_visibility'))

        c.argument('ingress_visibility',
                   arg_type=get_enum_type(['Private', 'Public']),
                   help='Ingress visibility.',
                   validator=validate_visibility('ingress_visibility'))

        c.argument('vnet_resource_group_name',
                   resource_group_name_type,
                   options_list=['--vnet-resource-group'],
                   help='Name of vnet resource group.',
                   validator=validate_vnet_resource_group_name)
        c.argument(
            'vnet',
            help=
            'Name or ID of vnet.  If name is supplied, `--vnet-resource-group` must be supplied.',
            validator=validate_vnet)
        c.argument(
            'master_subnet',
            help=
            'Name or ID of master vnet subnet.  If name is supplied, `--vnet` must be supplied.',
            validator=validate_subnet('master_subnet'))
        c.argument(
            'worker_subnet',
            help=
            'Name or ID of worker vnet subnet.  If name is supplied, `--vnet` must be supplied.',
            validator=validate_subnet('worker_subnet'))
Пример #4
0
def load_arguments(self, _):
    with self.argument_context('aro') as c:
        c.argument('location',
                   validator=get_default_location_from_resource_group)
        c.argument('resource_name',
                   name_type,
                   help='Name of cluster.')
        c.argument('tags',
                   tags_type)

        c.argument('pull_secret',
                   help='Pull secret of cluster.',
                   validator=validate_pull_secret)
        c.argument('domain',
                   help='Domain of cluster.',
                   validator=validate_domain)
        c.argument('cluster_resource_group',
                   help='Resource group of cluster.',
                   validator=validate_cluster_resource_group)

        c.argument('client_id',
                   help='Client ID of cluster service principal.',
                   validator=validate_client_id)
        c.argument('client_secret',
                   help='Client secret of cluster service principal.',
                   validator=validate_client_secret(isCreate=True))

        c.argument('pod_cidr',
                   help='CIDR of pod network. Must be a minimum of /18 or larger.',
                   validator=validate_cidr('pod_cidr'))
        c.argument('service_cidr',
                   help='CIDR of service network. Must be a minimum of /18 or larger.',
                   validator=validate_cidr('service_cidr'))
        c.argument('software_defined_network', arg_type=get_enum_type(['OVNKubernetes', 'OpenShiftSDN']),
                   options_list=['--software-defined-network-type', '--sdn-type'],
                   help='SDN type either "OpenShiftSDN" (default) or "OVNKubernetes"',
                   validator=validate_sdn)

        c.argument('disk_encryption_set',
                   help='ResourceID of the DiskEncryptionSet to be used for master and worker VMs.',
                   validator=validate_disk_encryption_set)
        c.argument('master_encryption_at_host', arg_type=get_three_state_flag(),
                   options_list=['--master-encryption-at-host', '--master-enc-host'],
                   help='Encryption at host flag for master VMs.')
        c.argument('master_vm_size',
                   help='Size of master VMs.')

        c.argument('worker_encryption_at_host', arg_type=get_three_state_flag(),
                   options_list=['--worker-encryption-at-host', '--worker-enc-host'],
                   help='Encryption at host flag for worker VMs.')
        c.argument('worker_vm_size',
                   help='Size of worker VMs.')
        c.argument('worker_vm_disk_size_gb',
                   type=int,
                   help='Disk size in GB of worker VMs.',
                   validator=validate_worker_vm_disk_size_gb)
        c.argument('worker_count',
                   type=int,
                   help='Count of worker VMs.',
                   validator=validate_worker_count)

        c.argument('apiserver_visibility', arg_type=get_enum_type(['Private', 'Public']),
                   help='API server visibility.',
                   validator=validate_visibility('apiserver_visibility'))

        c.argument('ingress_visibility', arg_type=get_enum_type(['Private', 'Public']),
                   help='Ingress visibility.',
                   validator=validate_visibility('ingress_visibility'))

        c.argument('vnet_resource_group_name',
                   resource_group_name_type,
                   options_list=['--vnet-resource-group'],
                   help='Name of vnet resource group.',
                   validator=validate_vnet_resource_group_name)
        c.argument('vnet',
                   help='Name or ID of vnet.  If name is supplied, `--vnet-resource-group` must be supplied.',
                   validator=validate_vnet)
        c.argument('master_subnet',
                   help='Name or ID of master vnet subnet.  If name is supplied, `--vnet` must be supplied.',
                   validator=validate_subnet('master_subnet'))
        c.argument('worker_subnet',
                   help='Name or ID of worker vnet subnet.  If name is supplied, `--vnet` must be supplied.',
                   validator=validate_subnet('worker_subnet'))
    with self.argument_context('aro update') as c:
        c.argument('client_secret',
                   help='Client secret of cluster service principal.',
                   validator=validate_client_secret(isCreate=False))
        c.argument('refresh_cluster_credentials',
                   arg_type=get_three_state_flag(),
                   help='Refresh cluster application credentials.',
                   options_list=['--refresh-credentials'],
                   validator=validate_refresh_cluster_credentials)