Skip to content

Commit 30d7274

Browse files
author
huguesv
committed
Merge branch 'zlike-msft-master'
2 parents ea0d41c + 292e4f4 commit 30d7274

File tree

4 files changed

+62
-24
lines changed

4 files changed

+62
-24
lines changed

azure/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,9 @@ def _to_datetime(strtime):
282282
'operation_id': 'OperationId',
283283
'operation_object_id': 'OperationObjectId',
284284
'client_ip': 'ClientIP',
285-
'status_id': 'ID'
285+
'status_id': 'ID',
286+
'virtual_ips': 'VirtualIPs',
287+
'virtual_ip': 'VirtualIP'
286288
}
287289

288290

azure/servicemanagement/__init__.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
AZURE_MANAGEMENT_SUBSCRIPTIONID = 'AZURE_MANAGEMENT_SUBSCRIPTIONID'
4949

5050
# x-ms-version for service management.
51-
X_MS_VERSION = '2014-06-01'
51+
X_MS_VERSION = '2014-10-01'
5252

5353
#-----------------------------------------------------------------------------
5454
# Data classes
@@ -289,6 +289,7 @@ def __init__(self):
289289
self.last_modified_time = u''
290290
self.extended_properties = _dict_of(
291291
'ExtendedProperty', 'Name', 'Value')
292+
self.virtual_ips = VirtualIPs()
292293

293294

294295
class RoleInstanceList(WindowsAzureData):
@@ -707,6 +708,28 @@ def __init__(self):
707708
self.end_time = u''
708709
self.status = u''
709710

711+
class VirtualIPs(WindowsAzureData):
712+
713+
def __init__(self):
714+
self.virtual_ips = _list_of(VirtualIP)
715+
716+
def __iter__(self):
717+
return iter(self.virtual_ips)
718+
719+
def __len__(self):
720+
return len(self.virtual_ips)
721+
722+
def __getitem__(self, index):
723+
return self.virtual_ips[index]
724+
725+
class VirtualIP(WindowsAzureData):
726+
727+
def __init__(self):
728+
self.address = u''
729+
self.is_reserved = False
730+
self.reserved_ip_name = u''
731+
self.type = u''
732+
710733

711734
class Certificates(WindowsAzureData):
712735

@@ -2775,15 +2798,16 @@ def network_configuration_to_xml(configuration):
27752798
('Name', endpoint.name),
27762799
('Port', endpoint.port)])
27772800

2778-
if endpoint.load_balancer_probe.path or\
2779-
endpoint.load_balancer_probe.port or\
2780-
endpoint.load_balancer_probe.protocol:
2781-
xml += '<LoadBalancerProbe>'
2782-
xml += _XmlSerializer.data_to_xml(
2783-
[('Path', endpoint.load_balancer_probe.path),
2784-
('Port', endpoint.load_balancer_probe.port),
2785-
('Protocol', endpoint.load_balancer_probe.protocol)])
2786-
xml += '</LoadBalancerProbe>'
2801+
if endpoint.load_balancer_probe:
2802+
if endpoint.load_balancer_probe.path or\
2803+
endpoint.load_balancer_probe.port or\
2804+
endpoint.load_balancer_probe.protocol:
2805+
xml += '<LoadBalancerProbe>'
2806+
xml += _XmlSerializer.data_to_xml(
2807+
[('Path', endpoint.load_balancer_probe.path),
2808+
('Port', endpoint.load_balancer_probe.port),
2809+
('Protocol', endpoint.load_balancer_probe.protocol)])
2810+
xml += '</LoadBalancerProbe>'
27872811

27882812
xml += _XmlSerializer.data_to_xml(
27892813
[('Protocol', endpoint.protocol),
@@ -2795,8 +2819,9 @@ def network_configuration_to_xml(configuration):
27952819
xml += '</InputEndpoint>'
27962820
xml += '</InputEndpoints>'
27972821
xml += '<SubnetNames>'
2798-
for name in configuration.subnet_names:
2799-
xml += _XmlSerializer.data_to_xml([('SubnetName', name)])
2822+
if configuration.subnet_names:
2823+
for name in configuration.subnet_names:
2824+
xml += _XmlSerializer.data_to_xml([('SubnetName', name)])
28002825
xml += '</SubnetNames>'
28012826

28022827
if configuration.public_ips:

azure/servicemanagement/servicemanagementservice.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,8 @@ def create_hosted_service(self, service_name, label, description=None,
375375
description,
376376
location,
377377
affinity_group,
378-
extended_properties))
378+
extended_properties),
379+
async=True)
379380

380381
def update_hosted_service(self, service_name, label=None, description=None,
381382
extended_properties=None):
@@ -410,15 +411,25 @@ def update_hosted_service(self, service_name, label=None, description=None,
410411
description,
411412
extended_properties))
412413

413-
def delete_hosted_service(self, service_name):
414+
def delete_hosted_service(self, service_name, complete=False):
414415
'''
415416
Deletes the specified hosted service from Windows Azure.
416417
417418
service_name:
418419
Name of the hosted service.
420+
complete:
421+
True if all OS/data disks and the source blobs for the disks should
422+
also be deleted from storage.
419423
'''
424+
420425
_validate_not_none('service_name', service_name)
421-
return self._perform_delete(self._get_hosted_service_path(service_name))
426+
427+
path = self._get_hosted_service_path(service_name)
428+
429+
if complete == True:
430+
path = path +'?comp=media'
431+
432+
return self._perform_delete(path, async=True)
422433

423434
def get_deployment_by_slot(self, service_name, deployment_slot):
424435
'''
@@ -898,23 +909,24 @@ def get_service_certificate(self, service_name, thumbalgorithm, thumbprint):
898909
Certificate)
899910

900911
def add_service_certificate(self, service_name, data, certificate_format,
901-
password):
912+
password=None):
902913
'''
903914
Adds a certificate to a hosted service.
904915
905916
service_name:
906917
Name of the hosted service.
907918
data:
908-
The base-64 encoded form of the pfx file.
919+
The base-64 encoded form of the pfx/cer file.
909920
certificate_format:
910-
The service certificate format. The only supported value is pfx.
921+
The service certificate format.
911922
password:
912-
The certificate password.
923+
The certificate password. Default to None when using cer format.
913924
'''
914925
_validate_not_none('service_name', service_name)
915926
_validate_not_none('data', data)
916927
_validate_not_none('certificate_format', certificate_format)
917928
_validate_not_none('password', password)
929+
918930
return self._perform_post(
919931
'/' + self.subscription_id + '/services/hostedservices/' +
920932
_str(service_name) + '/certificates',

tests/test_servicemanagementservice.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def _create_hosted_service(self, name, location=None, affinity_group=None):
251251
location,
252252
affinity_group,
253253
{'ext1': 'val1', 'ext2': 42})
254-
self.assertIsNone(result)
254+
self._wait_for_async(result.request_id)
255255

256256
def _hosted_service_exists(self, name):
257257
try:
@@ -859,9 +859,9 @@ def test_create_hosted_service(self):
859859
result = self.sms.create_hosted_service(
860860
self.hosted_service_name, label, description, location, None,
861861
{'ext1': 'val1', 'ext2': 'val2'})
862+
self._wait_for_async(result.request_id)
862863

863864
# Assert
864-
self.assertIsNone(result)
865865
self.assertTrue(self._hosted_service_exists(self.hosted_service_name))
866866

867867
def test_update_hosted_service(self):
@@ -898,9 +898,9 @@ def test_delete_hosted_service(self):
898898

899899
# Act
900900
result = self.sms.delete_hosted_service(self.hosted_service_name)
901+
self._wait_for_async(result.request_id)
901902

902903
# Assert
903-
self.assertIsNone(result)
904904
self.assertFalse(self._hosted_service_exists(self.hosted_service_name))
905905

906906
def test_get_deployment_by_slot(self):
@@ -2098,7 +2098,6 @@ def test_list_vm_images(self):
20982098
if image.category == 'Public':
20992099
self.assertGreater(len(image.name), 0)
21002100
self.assertGreater(len(image.category), 0)
2101-
self.assertGreater(len(image.description), 0)
21022101
self.assertGreater(len(image.label), 0)
21032102
self.assertGreater(len(image.location), 0)
21042103
self.assertGreater(len(image.publisher_name), 0)

0 commit comments

Comments
 (0)