Просмотр исходного кода

Updated Image Lists, Added URN parsing

Alexandru Mahmoud 7 лет назад
Родитель
Сommit
6b1d4a8b7b

+ 2 - 2
cloudbridge/cloud/interfaces/services.py

@@ -55,7 +55,7 @@ class ComputeService(CloudService):
                 print(image.id, image.name)
 
             # find image by name
-            image = provider.compute.images.find(name='Ubuntu 14.04')
+            image = provider.compute.images.find(name='Ubuntu 16.04')
             print(image.id, image.name)
 
         :rtype: :class:`.ImageService`
@@ -95,7 +95,7 @@ class ComputeService(CloudService):
         .. code-block:: python
 
             # launch a new instance
-            image = provider.compute.images.find(name='Ubuntu 14.04')[0]
+            image = provider.compute.images.find(name='Ubuntu 16.04')[0]
             size = provider.compute.vm_types.find(name='m1.small')
             instance = provider.compute.instances.create('Hello', image, size)
             print(instance.id, instance.name)

+ 48 - 0
cloudbridge/cloud/providers/azure/azure_client.py

@@ -87,6 +87,54 @@ gallery_image_references = \
      GalleryImageReference(publisher='Canonical',
                            offer='UbuntuServer',
                            sku='14.04.5-LTS',
+                           version='latest'),
+     GalleryImageReference(publisher='OpenLogic',
+                           offer='CentOS',
+                           sku='7.5',
+                           version='latest'),
+     GalleryImageReference(publisher='OpenLogic',
+                           offer='CentOS',
+                           sku='6.9',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftWindowsServer',
+                           offer='WindowsServer',
+                           sku='2016-Nano-Server',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftWindowsServer',
+                           offer='WindowsServer',
+                           sku='2016-Datacenter',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftWindowsDesktop',
+                           offer='Windows-10',
+                           sku='rs4-pron',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftVisualStudio',
+                           offer='Windows',
+                           sku='Windows-10-N-x64',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftVisualStudio',
+                           offer='VisualStudio',
+                           sku='VS-2017-Ent-WS2016',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftSQLServer',
+                           offer='SQL2017-WS2016',
+                           sku='Web',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftSQLServer',
+                           offer='SQL2017-WS2016',
+                           sku='Standard',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftSQLServer',
+                           offer='SQL2017-WS2016',
+                           sku='SQLDEV',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftSQLServer',
+                           offer='SQL2017-WS2016',
+                           sku='Express',
+                           version='latest'),
+     GalleryImageReference(publisher='MicrosoftSQLServer',
+                           offer='SQL2017-WS2016',
+                           sku='Enterprise',
                            version='latest')]
 
 

+ 8 - 0
cloudbridge/cloud/providers/azure/helpers.py

@@ -28,12 +28,20 @@ def parse_url(template_urls, original_url):
        'virtualMachines/{vmName}'
     This function splits the resource ID based on the template urls passed
     and returning the dictionary.
+
+    The only exception to that format are image URN's which are used for
+    public gallery references:
+    https://docs.microsoft.com/en-us/azure/virtual-machines/linux/cli-ps-findimage
     """
     if not original_url:
         raise InvalidValueException(template_urls, original_url)
     original_url_parts = original_url.split('/')
+    if len(original_url_parts) == 1:
+        original_url_parts = original_url.split(':')
     for each_template in template_urls:
         template_url_parts = each_template.split('/')
+        if len(template_url_parts) == 1:
+            template_url_parts = each_template.split(':')
         if len(template_url_parts) == len(original_url_parts):
             break
     if len(template_url_parts) != len(original_url_parts):