diff --git a/azure-cli.pyproj b/azure-cli.pyproj index f029358170c..28a4caa8398 100644 --- a/azure-cli.pyproj +++ b/azure-cli.pyproj @@ -12,7 +12,7 @@ . {888888a0-9f3d-457c-b088-3a5042f75d52} Standard Python launcher - {4ae3497d-f45c-4ec2-9e26-57476ef276a0} + {1dd9c42b-5980-42ce-a2c3-46d3bf0eede4} 3.5 @@ -25,7 +25,12 @@ + + + + + @@ -54,28 +59,6 @@ - - {83c20e12-84e3-4c10-a1ba-466d2b57483d} - {2af0f10d-7135-4994-9156-5d01c9c11b7e} - 2.7 - env27b (Python 2.7) - Scripts\python.exe - Scripts\pythonw.exe - Lib\ - PYTHONPATH - X86 - - - {4ae3497d-f45c-4ec2-9e26-57476ef276a0} - {2af0f10d-7135-4994-9156-5d01c9c11b7e} - 3.5 - env35d (Python 3.5) - Scripts\python.exe - Scripts\pythonw.exe - Lib\ - PYTHONPATH - X86 - {1dd9c42b-5980-42ce-a2c3-46d3bf0eede4} {2af0f10d-7135-4994-9156-5d01c9c11b7e} diff --git a/src/azure/cli/commands/_auto_command.py b/src/azure/cli/commands/_auto_command.py index 02a2722b190..821aa4d1fe6 100644 --- a/src/azure/cli/commands/_auto_command.py +++ b/src/azure/cli/commands/_auto_command.py @@ -23,7 +23,8 @@ def __call__(self, poller): try: while not poller.done(): if self.progress_file: - print('.', end='', flush=True, file=self.progress_file) + print('.', end='', file=self.progress_file) + self.progress_file.flush() time.sleep(self.poll_interval_ms / 1000.0) result = poller.result() succeeded = True diff --git a/src/azure/cli/commands/network.py b/src/azure/cli/commands/network.py index 39f0615eb68..665d458bb3e 100644 --- a/src/azure/cli/commands/network.py +++ b/src/azure/cli/commands/network.py @@ -1,3 +1,4 @@ +from msrest import Serializer from .._locale import L from azure.mgmt.network import NetworkManagementClient, NetworkManagementClientConfiguration from azure.mgmt.network.operations import (ApplicationGatewaysOperations, @@ -21,6 +22,7 @@ from ._command_creation import get_service_client from ..commands._auto_command import build_operation, LongRunningOperation +from ..commands import command, description, option def _network_client_factory(): return get_service_client(NetworkManagementClient, NetworkManagementClientConfiguration) @@ -240,3 +242,74 @@ def _network_client_factory(): (VirtualNetworksOperations.list, '[VirtualNetwork]'), (VirtualNetworksOperations.list_all, '[VirtualNetwork]'), ]) + +@command('network vnet create') +@description(L('Create or update a virtual network (VNet)')) +@option('--resource-group -g ', L('the resource group name'), required=True) +@option('--name -n ', L('the VNet name'), required=True) +@option('--location -l ', L('the VNet location'), required=True) +@option('--address-space -a ', L('the VNet address-space in CIDR notation or multiple address-spaces, quoted and space-seperated'), required=True) +@option('--dns-servers -d ', L('the VNet DNS servers, quoted and space-seperated')) +def create_update_vnet(args, unexpected): #pylint: disable=unused-argument + from azure.mgmt.network.models import AddressSpace, DhcpOptions, VirtualNetwork + + resource_group = args.get('resource-group') + name = args.get('name') + location = args.get('location') + address_space = AddressSpace(address_prefixes=args.get('address-space').split()) + dhcp_options = DhcpOptions(dns_servers=args.get('dns-servers').split()) + + vnet_settings = VirtualNetwork(location=location, + address_space=address_space, + dhcp_options=dhcp_options) + + op = LongRunningOperation('Creating virtual network', 'Virtual network created') + smc = _network_client_factory() + poller = smc.virtual_networks.create_or_update(resource_group, name, vnet_settings) + return Serializer().serialize_data(op(poller), 'VirtualNetwork') + +@command('network subnet create') +@description(L('Create or update a virtual network (VNet) subnet')) +@option('--resource-group -g ', L('the the resource group name'), required=True) +@option('--name -n ', L('the the subnet name'), required=True) +@option('--vnet -v ', L('the name of the subnet vnet'), required=True) +@option('--address-prefix -a ', L('the the address prefix in CIDR format'), required=True) +# TODO: setting the IPConfiguration fails, will contact owning team +#@option('--ip-name -ipn ', L('the IP address configuration name')) +#@option('--ip-private-address -ippa ', L('the private IP address')) +#@option('--ip-allocation-method -ipam ', L('the IP address allocation method')) +#@option('--ip-public-address -ipa ', L('the public IP address')) +def create_update_subnet(args, unexpected): #pylint: disable=unused-argument + from azure.mgmt.network.models import (Subnet, + # TODO: setting the IPConfiguration fails + #IPConfiguration, + ) + + resource_group = args.get('resource-group') + vnet = args.get('vnet') + name = args.get('name') + address_prefix = args.get('address-prefix') + # TODO: setting the IPConfiguration fails, will contact owning team + #ip_name = args.get('ip-name') + #ip_private_address = args.get('ip-private-address') + #ip_allocation_method = args.get('ip-allocation-method') + #ip_public_address = args.get('ip-public-address') + + # TODO: setting the IPConfiguration fails, will contact owning team + #ip_configuration = IPConfiguration(subnet = name, + # name = ip_name, + # private_ip_address = ip_private_address, + # private_ip_allocation_method = ip_allocation_method, + # public_ip_address = ip_public_address) + + subnet_settings = Subnet(name=name, + address_prefix=address_prefix) + # TODO: setting the IPConfiguration fails, will contact owning team + #ip_configurations = [ip_configuration]) + + op = LongRunningOperation('Creating subnet', 'Subnet created') + smc = _network_client_factory() + poller = smc.subnets.create_or_update(resource_group, vnet, name, subnet_settings) + return Serializer().serialize_data(op(poller), 'Subnet') + +