зеркало из https://github.com/Azure/ARO-RP.git
python: prefer single quotes
This commit is contained in:
Родитель
6a359dbe8a
Коммит
9c6c88fc1c
|
@ -13,7 +13,7 @@ from azure.graphrbac.models import ServicePrincipalCreateParameters
|
|||
|
||||
|
||||
class AADManager(object):
|
||||
MANAGED_APP_PREFIX = "https://az.aro.azure.com/"
|
||||
MANAGED_APP_PREFIX = 'https://az.aro.azure.com/'
|
||||
|
||||
def __init__(self, cli_ctx):
|
||||
profile = Profile(cli_ctx=cli_ctx)
|
||||
|
|
|
@ -13,7 +13,7 @@ def cf_aro(cli_ctx, *_):
|
|||
cli_ctx, AzureRedHatOpenShiftClient).open_shift_clusters
|
||||
|
||||
if rp_mode_development():
|
||||
client.config.base_url = "https://localhost:8443/"
|
||||
client.config.base_url = 'https://localhost:8443/'
|
||||
client.config.connection.verify = False
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ def aro_list_table_format(results):
|
|||
|
||||
|
||||
def aro_show_table_format(result):
|
||||
parts = parse_resource_id(result["id"])
|
||||
parts = parse_resource_id(result['id'])
|
||||
|
||||
return collections.OrderedDict(
|
||||
Name=result["name"],
|
||||
ResourceGroup=parts["resource_group"],
|
||||
Location=result["location"],
|
||||
ProvisioningState=result["provisioningState"],
|
||||
WorkerCount=result["workerProfiles"][0]["count"],
|
||||
ConsoleURL=result["consoleUrl"],
|
||||
Name=result['name'],
|
||||
ResourceGroup=parts['resource_group'],
|
||||
Location=result['location'],
|
||||
ProvisioningState=result['provisioningState'],
|
||||
WorkerCount=result['workerProfiles'][0]['count'],
|
||||
ConsoleURL=result['consoleUrl'],
|
||||
)
|
||||
|
|
|
@ -10,7 +10,7 @@ from azure.cli.core.profiles import ResourceType
|
|||
from msrestazure.tools import resource_id
|
||||
|
||||
|
||||
CONTRIBUTOR = "b24988ac-6180-42a0-ab88-20f7382dd24c"
|
||||
CONTRIBUTOR = 'b24988ac-6180-42a0-ab88-20f7382dd24c'
|
||||
|
||||
|
||||
def assign_contributor_to_vnet(cli_ctx, vnet, object_id):
|
||||
|
@ -35,5 +35,5 @@ def assign_contributor_to_vnet(cli_ctx, vnet, object_id):
|
|||
client.role_assignments.create(vnet, uuid.uuid4(), RoleAssignmentCreateParameters(
|
||||
role_definition_id=role_definition_id,
|
||||
principal_id=object_id,
|
||||
principal_type="ServicePrincipal",
|
||||
principal_type='ServicePrincipal',
|
||||
))
|
||||
|
|
|
@ -36,13 +36,13 @@ def validate_client_id(namespace):
|
|||
raise CLIError("Invalid --client-id '%s'." % namespace.client_id)
|
||||
|
||||
if namespace.client_secret is None or not str(namespace.client_secret):
|
||||
raise CLIError("Must specify --client-secret with --client-id.")
|
||||
raise CLIError('Must specify --client-secret with --client-id.')
|
||||
|
||||
|
||||
def validate_client_secret(namespace):
|
||||
if namespace.client_secret is not None:
|
||||
if namespace.client_id is not None or not str(namespace.client_id):
|
||||
raise CLIError("Must specify --client-id with --client-secret.")
|
||||
raise CLIError('Must specify --client-id with --client-secret.')
|
||||
|
||||
|
||||
def validate_cluster_domain(namespace):
|
||||
|
@ -69,7 +69,7 @@ def validate_resource_name(cmd, namespace):
|
|||
# TODO: remove this limitation, ideally by allowing the end user to specify
|
||||
# the cluster resource group
|
||||
|
||||
if cmd.name == "aro create":
|
||||
if cmd.name == 'aro create':
|
||||
client = get_mgmt_service_client(
|
||||
cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
|
||||
|
||||
|
@ -85,44 +85,44 @@ def validate_subnet(key):
|
|||
if not is_valid_resource_id(subnet):
|
||||
if not namespace.vnet:
|
||||
raise CLIError(
|
||||
"Must specify --vnet if --%s is not an id." % key.replace('_', '-'))
|
||||
'Must specify --vnet if --%s is not an id.' % key.replace('_', '-'))
|
||||
|
||||
validate_vnet(cmd, namespace)
|
||||
|
||||
subnet = namespace.vnet + "/subnets/" + subnet
|
||||
subnet = namespace.vnet + '/subnets/' + subnet
|
||||
setattr(namespace, key, subnet)
|
||||
|
||||
parts = parse_resource_id(subnet)
|
||||
|
||||
if parts["subscription"] != get_subscription_id(cmd.cli_ctx):
|
||||
if parts['subscription'] != get_subscription_id(cmd.cli_ctx):
|
||||
raise CLIError("--%s subscription '%s' must equal cluster subscription." %
|
||||
(key.replace('_', '-'), parts["subscription"]))
|
||||
|
||||
if parts["namespace"].lower() != "microsoft.network":
|
||||
if parts['namespace'].lower() != 'microsoft.network':
|
||||
raise CLIError("--%s namespace '%s' must equal Microsoft.Network." %
|
||||
(key.replace('_', '-'), parts["namespace"]))
|
||||
|
||||
if parts["type"].lower() != "virtualnetworks":
|
||||
if parts['type'].lower() != 'virtualnetworks':
|
||||
raise CLIError("--%s type '%s' must equal virtualNetworks." %
|
||||
(key.replace('_', '-'), parts["type"]))
|
||||
|
||||
if parts["last_child_num"] != 1:
|
||||
if parts['last_child_num'] != 1:
|
||||
raise CLIError("--%s '%s' must have one child." %
|
||||
(key.replace('_', '-'), subnet))
|
||||
|
||||
if "child_namespace_1" in parts:
|
||||
if 'child_namespace_1' in parts:
|
||||
raise CLIError("--%s '%s' must not have child namespace." %
|
||||
(key.replace('_', '-'), subnet))
|
||||
|
||||
if parts["child_type_1"].lower() != "subnets":
|
||||
if parts['child_type_1'].lower() != 'subnets':
|
||||
raise CLIError("--%s child type '%s' must equal subnets." %
|
||||
(key.replace('_', '-'), subnet))
|
||||
|
||||
client = get_mgmt_service_client(
|
||||
cmd.cli_ctx, ResourceType.MGMT_NETWORK)
|
||||
try:
|
||||
client.subnets.get(parts["resource_group"],
|
||||
parts["name"], parts["child_name_1"])
|
||||
client.subnets.get(parts['resource_group'],
|
||||
parts['name'], parts['child_name_1'])
|
||||
except CloudError as err:
|
||||
raise CLIError(err.message)
|
||||
|
||||
|
@ -133,24 +133,24 @@ def validate_subnets(master_subnet, worker_subnet):
|
|||
master_parts = parse_resource_id(master_subnet)
|
||||
worker_parts = parse_resource_id(worker_subnet)
|
||||
|
||||
if master_parts["resource_group"].lower() != worker_parts["resource_group"].lower():
|
||||
if master_parts['resource_group'].lower() != worker_parts['resource_group'].lower():
|
||||
raise CLIError("--master-subnet resource group '%s' must equal --worker-subnet resource group '%s'." %
|
||||
(master_parts["resource_group"], worker_parts["resource_group"]))
|
||||
(master_parts['resource_group'], worker_parts['resource_group']))
|
||||
|
||||
if master_parts["name"].lower() != worker_parts["name"].lower():
|
||||
if master_parts['name'].lower() != worker_parts['name'].lower():
|
||||
raise CLIError("--master-subnet vnet name '%s' must equal --worker-subnet vnet name '%s'." %
|
||||
(master_parts["name"], worker_parts["name"]))
|
||||
(master_parts['name'], worker_parts['name']))
|
||||
|
||||
if master_parts["child_name_1"].lower() == worker_parts["child_name_1"].lower():
|
||||
if master_parts['child_name_1'].lower() == worker_parts['child_name_1'].lower():
|
||||
raise CLIError("--master-subnet name '%s' must not equal --worker-subnet name '%s'." %
|
||||
(master_parts["child_name_1"], worker_parts["child_name_1"]))
|
||||
(master_parts['child_name_1'], worker_parts['child_name_1']))
|
||||
|
||||
return resource_id(
|
||||
subscription=master_parts["subscription"],
|
||||
resource_group=master_parts["resource_group"],
|
||||
subscription=master_parts['subscription'],
|
||||
resource_group=master_parts['resource_group'],
|
||||
namespace='Microsoft.Network',
|
||||
type='virtualNetworks',
|
||||
name=master_parts["name"],
|
||||
name=master_parts['name'],
|
||||
)
|
||||
|
||||
|
||||
|
@ -158,7 +158,7 @@ def validate_visibility(key):
|
|||
def _validate_visibility(namespace):
|
||||
visibility = getattr(namespace, key)
|
||||
if visibility is not None:
|
||||
if visibility not in ["Private", "Public"]:
|
||||
if visibility not in ['Private', 'Public']:
|
||||
raise CLIError("Invalid --%s '%s'." %
|
||||
(key.replace('_', '-'), visibility))
|
||||
|
||||
|
@ -187,18 +187,18 @@ def validate_vnet_resource_group_name(namespace):
|
|||
def validate_worker_count(namespace):
|
||||
if namespace.worker_count:
|
||||
namespace.worker_count = _validate_int(
|
||||
"worker_count", namespace.worker_count)
|
||||
'worker_count', namespace.worker_count)
|
||||
|
||||
if namespace.worker_count < 3:
|
||||
raise CLIError(
|
||||
"--worker-count must be greater than or equal to 3.")
|
||||
'--worker-count must be greater than or equal to 3.')
|
||||
|
||||
|
||||
def validate_worker_vm_disk_size_gb(namespace):
|
||||
if namespace.worker_vm_disk_size_gb:
|
||||
namespace.worker_vm_disk_size_gb = _validate_int(
|
||||
"worker_vm_disk_size_gb", namespace.worker_vm_disk_size_gb)
|
||||
'worker_vm_disk_size_gb', namespace.worker_vm_disk_size_gb)
|
||||
|
||||
if namespace.worker_vm_disk_size_gb < 128:
|
||||
raise CLIError(
|
||||
"--worker_vm_disk_size_gb must be greater than or equal to 128.")
|
||||
'--worker_vm_disk_size_gb must be greater than or equal to 128.')
|
||||
|
|
|
@ -14,7 +14,7 @@ from azure.cli.core.commands.client_factory import get_subscription_id
|
|||
from azure.cli.core.util import sdk_no_wait
|
||||
|
||||
|
||||
FP_CLIENT_ID = "f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875"
|
||||
FP_CLIENT_ID = 'f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875'
|
||||
|
||||
|
||||
def aro_create(cmd, # pylint: disable=too-many-locals
|
||||
|
@ -46,7 +46,7 @@ def aro_create(cmd, # pylint: disable=too-many-locals
|
|||
aad = AADManager(cmd.cli_ctx)
|
||||
if client_id is None:
|
||||
app, client_secret = aad.create_application(
|
||||
"aro-%d-%s-%s-%s" % (time.time(), subscription_id, resource_group_name, resource_name))
|
||||
'aro-%d-%s-%s-%s' % (time.time(), subscription_id, resource_group_name, resource_name))
|
||||
client_id = app.app_id
|
||||
|
||||
client_sp = aad.get_service_principal(client_id)
|
||||
|
@ -72,29 +72,29 @@ def aro_create(cmd, # pylint: disable=too-many-locals
|
|||
client_secret=client_secret,
|
||||
),
|
||||
network_profile=v2019_12_31_preview.NetworkProfile(
|
||||
pod_cidr=pod_cidr or "10.128.0.0/14",
|
||||
service_cidr=service_cidr or "172.30.0.0/16",
|
||||
pod_cidr=pod_cidr or '10.128.0.0/14',
|
||||
service_cidr=service_cidr or '172.30.0.0/16',
|
||||
),
|
||||
master_profile=v2019_12_31_preview.MasterProfile(
|
||||
vm_size=master_vm_size or "Standard_D8s_v3",
|
||||
vm_size=master_vm_size or 'Standard_D8s_v3',
|
||||
subnet_id=master_subnet,
|
||||
),
|
||||
worker_profiles=[
|
||||
v2019_12_31_preview.WorkerProfile(
|
||||
name="worker", # TODO: "worker" should not be hard-coded
|
||||
vm_size=worker_vm_size or "Standard_D2s_v3",
|
||||
name='worker', # TODO: 'worker' should not be hard-coded
|
||||
vm_size=worker_vm_size or 'Standard_D2s_v3',
|
||||
disk_size_gb=worker_vm_disk_size_gb or 128,
|
||||
subnet_id=worker_subnet,
|
||||
count=worker_count or 3,
|
||||
)
|
||||
],
|
||||
apiserver_profile=v2019_12_31_preview.APIServerProfile(
|
||||
visibility=apiserver_visibility or "Public",
|
||||
visibility=apiserver_visibility or 'Public',
|
||||
),
|
||||
ingress_profiles=[
|
||||
v2019_12_31_preview.IngressProfile(
|
||||
name="default", # TODO: "default" should not be hard-coded
|
||||
visibility=ingress_visibility or "Public",
|
||||
name='default', # TODO: 'default' should not be hard-coded
|
||||
visibility=ingress_visibility or 'Public',
|
||||
)
|
||||
],
|
||||
)
|
||||
|
|
Загрузка…
Ссылка в новой задаче