Explorar o código

Azure documentation & Getting started update

almahmoud %!s(int64=7) %!d(string=hai) anos
pai
achega
af4eae55ad

+ 13 - 16
docs/getting_started.rst

@@ -136,7 +136,7 @@ a private network.
     from cloudbridge.cloud.interfaces.resources import TrafficDirection
     from cloudbridge.cloud.interfaces.resources import TrafficDirection
     fw = provider.security.vm_firewalls.create(
     fw = provider.security.vm_firewalls.create(
         label='cloudbridge-intro', description='A VM firewall used by
         label='cloudbridge-intro', description='A VM firewall used by
-        CloudBridge', network=net.id)
+        CloudBridge', network_id=net.id)
     fw.rules.create(TrafficDirection.INBOUND, 'tcp', 22, 22, '0.0.0.0/0')
     fw.rules.create(TrafficDirection.INBOUND, 'tcp', 22, 22, '0.0.0.0/0')
 
 
 Launch an instance
 Launch an instance
@@ -196,6 +196,10 @@ unique, multiple resources of the same type could use the same label, thus the
 `find` method always returns a list, while the `get` method returns a single
 `find` method always returns a list, while the `get` method returns a single
 object. While the methods are similar across resources, they are explicitly
 object. While the methods are similar across resources, they are explicitly
 listed in order to help map each resource with the service that handles it.
 listed in order to help map each resource with the service that handles it.
+Note that labeled resources allow to find by label, while unlabeled
+resources find by name or their special properties (eg: public_ip for
+floating IPs). For more detailed information on the types of resources and
+their provider mappings, see :doc:`topics/resource_types_and_mappings`.
 
 
 .. code-block:: python
 .. code-block:: python
 
 
@@ -204,50 +208,43 @@ listed in order to help map each resource with the service that handles it.
     kp_list = provider.security.key_pairs.find(name='cloudbridge_intro')
     kp_list = provider.security.key_pairs.find(name='cloudbridge_intro')
     kp = kp_list[0]
     kp = kp_list[0]
 
 
+    # Floating IPs
+    fip = gateway.floating_ips.get('FloatingIP ID')
+    # Find using public IP address
+    fip_list = gateway.floating_ips.find(public_ip='IP address')
+    # Find using name or tag
+    fip_list = net.gateways.floating_ips.find(name='my-fip')
+    fip = fip_list[0]
+
     # Network
     # Network
     net = provider.networking.networks.get('network ID')
     net = provider.networking.networks.get('network ID')
-    net_list = provider.networking.networks.find(name='my-network')
     net_list = provider.networking.networks.find(label='my-network')
     net_list = provider.networking.networks.find(label='my-network')
     net = net_list[0]
     net = net_list[0]
 
 
     # Subnet
     # Subnet
     sn = provider.networking.subnets.get('subnet ID')
     sn = provider.networking.subnets.get('subnet ID')
     # Unknown network
     # Unknown network
-    sn_list = provider.networking.subnets.find(name='my-subnet')
     sn_list = provider.networking.subnets.find(label='my-subnet')
     sn_list = provider.networking.subnets.find(label='my-subnet')
     # Known network
     # Known network
-    sn_list = provider.networking.subnets.find(network=net.id, name='my-subnet')
     sn_list = provider.networking.subnets.find(network=net.id,
     sn_list = provider.networking.subnets.find(network=net.id,
                                                label='my-subnet')
                                                label='my-subnet')
     sn = sn_list(0)
     sn = sn_list(0)
 
 
     # Router
     # Router
     router = provider.networking.routers.get('router ID')
     router = provider.networking.routers.get('router ID')
-    router_list = provider.networking.routers.find(name='my-router')
     router_list = provider.networking.routers.find(label='my-router')
     router_list = provider.networking.routers.find(label='my-router')
     router = router_list[0]
     router = router_list[0]
 
 
     # Gateway
     # Gateway
     gateway = net.gateways.get_or_create_inet_gateway()
     gateway = net.gateways.get_or_create_inet_gateway()
 
 
-    # Floating IPs
-    fip = gateway.floating_ips.get('FloatingIP ID')
-    # Find using public IP address
-    fip_list = gateway.floating_ips.find(public_ip='IP address')
-    # Find using name or tag
-    fip_list = net.gateways.floating_ips.find(name='my-fip')
-    fip_list = net.gateways.floating_ips.find(label='my-fip')
-    fip = fip_list[0]
-
     # Firewall
     # Firewall
     fw = provider.security.vm_firewalls.get('firewall ID')
     fw = provider.security.vm_firewalls.get('firewall ID')
-    fw_list = provider.security.vm_firewalls.find(name='cloudbridge-intro')
     fw_list = provider.security.vm_firewalls.find(label='cloudbridge-intro')
     fw_list = provider.security.vm_firewalls.find(label='cloudbridge-intro')
     fw = fw_list[0]
     fw = fw_list[0]
 
 
     # Instance
     # Instance
     inst = provider.compute.instances.get('instance ID')
     inst = provider.compute.instances.get('instance ID')
-    inst_list = provider.compute.instances.list(name='cloudbridge-intro')
     inst_list = provider.compute.instances.list(label='cloudbridge-intro')
     inst_list = provider.compute.instances.list(label='cloudbridge-intro')
     inst = inst_list[0]
     inst = inst_list[0]
 
 

BIN=BIN
docs/topics/captures/az-storacc.png


BIN=BIN
docs/topics/captures/az-subnet-label.png


BIN=BIN
docs/topics/captures/az-subnet-name.png


+ 0 - 121
docs/topics/dashboard.rst

@@ -1,121 +0,0 @@
-Dashboard Mapping
-=================
-
-Cross-Platform Concepts
------------------------
-
-Given cloudbridge's goal to work uniformly across cloud providers, some
-compromises were necessary in order to bridge the many differences between
-providers' resources and features. Notably, in order to create a robust and
-conceptually consistent cross-cloud library, resources were given three main
-properties: ID, name, and label.
-The `ID` corresponds to a unique identifier that can be reliably used to
-reference a resource. Users can safely use an ID knowing that it will always
-point to the same resource.
-The `name` property corresponds to an unchangeable and unique designation for
-a particular resource. This property is meant to be, in some ways, a more
-human-readable identifier. However, when no conceptually comparable property
-exists for a given resource in a particular provider, the ID is returned
-instead, as is the case for OpenStack resources. When the name can be
-determined by a user at resource creation, either the name parameter will be
-used for resources that support it, or the label will be used, when provided
-as a prefix, with an appended uuid to ensure that the name remains unique.
-The `label` property, conversely, is a changeable value that does not need
-to be unique. Unlike the name property, it is not used to identify a
-particular resource, but rather label a resource for easier distinction. It
-is however important to note that not all resources support labels. When
-supported, labels given at creation will also be used as a prefix to the name.
-
-Properties per Resource per Provider
-------------------------------------
-The sections below will present a summary table detailing the cloudbridge
-properties implemented for each resource, and their corresponding value in
-the provider's dashboard.
-
-Azure
------
-+-----------------------------------+-------+---------------+---------------+
-| CloudServiceType                 	| CB_ID	| CB_Name      	| CB_Label  	|
-+===================================+=======+===============+===============+
-| Instance                         	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| MachineImage (Private)           	| ID   	| Name       	| Tags:Label 	|
-| MachineImage (Gallery Reference) 	| URN  	| URN        	| URN        	|
-+-----------------------------------+-------+---------------+---------------+
-| Network                          	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| Subnet                           	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| FloatingIP                       	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| Router                           	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| InternetGateway                  	| None 	| None       	| -          	|
-+-----------------------------------+-------+---------------+---------------+
-| Volume                           	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| Snapshot                         	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| KeyPair                          	| Name 	| Name       	| -          	|
-+-----------------------------------+-------+---------------+---------------+
-| VMFirewall                       	| ID   	| Name       	| Tags:Label 	|
-+-----------------------------------+-------+---------------+---------------+
-| VMFirewallRule                   	| ID   	| Name       	| -          	|
-+-----------------------------------+-------+---------------+---------------+
-| Bucket                           	| Name 	| Name       	| -          	|
-+-----------------------------------+-------+---------------+---------------+
-| BucketObject                     	| Name 	| Name       	| -          	|
-+-----------------------------------+-------+---------------+---------------+
-
-One of the major discrepancies in Azure is the non-existence of an Internet
-Gateway. In fact, Azure resources are automatically exposed to the internet,
-and thus an internet gateway object is not necessary for this purpose. Thus,
-a gateway object created through cloudbridge in Azure will not appear on the
-dashboard, as a cloudbridge-level wrapper object is returned when trying to
-create or get a gateway, but no object corresponds to that concept in Azure.
-For a succinct comparison between AWS Gateways and Azure, see:
-https://social.msdn.microsoft.com/Forums/en-US/
-814ccee0-9fbb-4c04-8135-49d0aaea5f38/
-equivalent-of-aws-internet-gateways-in-azure?
-forum=WAVirtualMachinesVirtualNetwork
-
-
-.. figure:: captures/az-label-dash.png
-   :scale: 50 %
-   :alt: name and label properties in Azure portal
-
-   The cloudbridge `name` property always maps to the unchangeable resource
-   name in Azure. The `label` property maps to the tag with key 'Label' in
-   Azure. By default, this label will appear in the tags column, but can also
-   be made into its own column, following the button indicated in the
-   screenshot above.
-
-.. figure:: captures/az-net-id.png
-   :scale: 50 %
-   :alt: network id in Azure portal
-
-   The cloudbridge `ID` property most often maps to the Resource ID in Azure,
-   which can be found under the properties tab within a resource. The above
-   screenshot shows where to find a resource's label in Azure's web portal
-
-.. figure:: captures/az-net-label.png
-   :scale: 50 %
-   :alt: network label in Azure portal
-
-   The cloudbridge `label` property most often maps to the tag with key
-   'Label' in Azure, which can be found under the tags tab within a resource.
-   The above screenshot shows where to find a resource's label in Azure's
-   web portal.
-
-.. figure:: captures/az-storacc.png
-   :scale: 50 %
-   :alt: storage account in Azure portal
-
-   Bucket and Key Pair objects are different than other resources in Azure,
-   as they are not resources residing in a resource group, but rather reside
-   in a storage account. As a result of this difference, these resources do
-   not support labels, and cannot be seen on the default dashboard. In order
-   to find these resources in the Azure web portal, one must head to the
-   storage account containing them, and look in the `Blobs` and `Tables`
-   services respectively for `Buckets` and `KeyPairs`.
-

+ 220 - 0
docs/topics/resource_types_and_mapping.rst

@@ -0,0 +1,220 @@
+Resource Types and Dashboard Mapping
+====================================
+
+Cross-Platform Concepts
+-----------------------
+
+Given CloudBridge's goal to work uniformly across cloud providers, some
+compromises were necessary in order to bridge the many differences between
+providers' resources and features. Notably, in order to create a robust and
+conceptually consistent cross-cloud library, resources were given three main
+properties: ID, name, and label.
+The `ID` corresponds to a unique identifier that can be reliably used to
+reference a resource. Users can safely use an ID knowing that it will always
+point to the same resource.
+The `name` property corresponds to an unchangeable and unique designation for
+a particular resource. This property is meant to be, in some ways, a more
+human-readable identifier. However, when no conceptually comparable property
+exists for a given resource in a particular provider, the ID is returned
+instead, as is the case for OpenStack resources. When the name can be
+determined by a user at resource creation, either the name parameter will be
+used for resources that support it, or the label will be used, when provided
+as a prefix, with an appended uuid to ensure that the name remains unique.
+The `label` property, conversely, is a changeable value that does not need
+to be unique. Unlike the name property, it is not used to identify a
+particular resource, but rather label a resource for easier distinction. It
+is however important to note that not all resources support labels. When
+supported, labels given at creation will also be used as a prefix to the name.
+
+
+Properties per Resource per Provider
+------------------------------------
+The sections below will present a summary table detailing the CloudBridge
+properties implemented for each resource, and their corresponding value in
+the provider's dashboard. It will also delineate the different types of
+CloudBridge resources, as well as present some design decisions made to
+preserve consistency across providers.
+
+
+Azure - Labeled Resources
+-------------------------
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Labeled CloudBridge Resource     | Azure Resource Type    | CB ID | CB Name                | CB Label                           |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Instance                         | Virtual Machine        | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| MachineImage (Private)           | Image                  | ID    | Name                   | tag:Label                          |
+| MachineImage (Gallery Reference) | Gallery Reference      | URN   | URN                    | URN                                |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Network                          | Virtual Network        | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Subnet                           | Subnet                 | ID    | NetworkName/SubnetName | Network:tag:SubnetLabel_SubnetName |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Router                           | Route Table            | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Volume                           | Disk                   | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| Snapshot                         | Snapshot               | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+| VMFirewall                       | Network security group | ID    | Name                   | tag:Label                          |
++----------------------------------+------------------------+-------+------------------------+------------------------------------+
+
+The resources listed above are labeled. They thus have both the `name` and
+`label` properties in CloudBridge. These resources require a mandatory `label`
+parameter at creation. The `label` will then be used to create the `name`,
+which will consist of up to 55 characters from the label, followed by a UUID.
+The label property can subsequently be changed, but the name property will
+remain unchanged, as it is part of the ID. Finally, labeled resources support
+a `label` parameter for the `find` method in their corresponding services.
+The below screenshots will help map these properties to Azure objects in the
+web portal.
+
+.. figure:: captures/az-label-dash.png
+   :scale: 50 %
+   :alt: name and label properties in Azure portal
+
+   The CloudBridge `name` property always maps to the unchangeable resource
+   name in Azure. The `label` property maps to the tag with key 'Label' for
+   most resources in Azure. By default, this label will appear in the tags
+   column, but can also be made into its own column, using the feature
+   pointed out in the screenshot above.
+
+.. figure:: captures/az-net-id.png
+   :scale: 50 %
+   :alt: network id in Azure portal
+
+   The CloudBridge `ID` property most often maps to the Resource ID in Azure,
+   which can be found under the properties tab within a resource. The above
+   screenshot shows where to find a resource's ID in Azure's web portal.
+
+.. figure:: captures/az-net-label.png
+   :scale: 50 %
+   :alt: network label in Azure portal
+
+   The CloudBridge `label` property most often maps to the tag with key
+   'Label' in Azure, which can be found under the tags tab within a resource.
+   The above screenshot shows where to find a resource's label in Azure's
+   web portal.
+
+Two labeled resources are exceptions to the general trends presented above,
+namely public images (i.e. Azure Marketplace Gallery References) and subnets.
+
+Gallery Images are public images from the Azure Marketplace, and cannot be
+found on a user's dashboard. A Gallery Image Reference is passed by URN, and
+does not need to be linked to a user. While all Gallery Image References cannot
+yet be listed in CloudBridge, a pre-set list of popular images is built into
+CloudBridge. For more on listing images through the Azure CLI, see the
+`Microsoft Documentation here. <https://docs.microsoft
+.com/en-us/azure/virtual-machines/linux/
+cli-ps-findimage#list-popular-images.>`_ Given that these resources are not
+owned by the user, they can only be referenced by URN. All CloudBridge
+properties map to the URN and none of them can be set or changed.
+
+Additionally, Subnets are a particular resource in Azure because they are
+not simply found in the Resource Group like most resources, but are rather
+nested within a network. Moreover, Subnets do not support tags in Azure.
+However, they remain a labeled resource in CloudBridge, which was
+accomplished by creating Network tags holding Subnet labels in Azure. The
+below screenshots will show how to find Subnets and their labels in the
+Azure web portal.
+
+.. figure:: captures/az-subnet-name.png
+   :scale: 50 %
+   :alt: subnet name in Azure portal
+
+   The CloudBridge `name` property for Subnets corresponds to the
+   unchangeable Resource Name in Azure. However, unlike other resources
+   where the Azure Name maps directly to the `name` property alone, a Subnet's
+   `name` property returns the Network's name and the Subnet's name,
+   separated by a slash, thus having the format [networkName]/[subnetName].
+   Subnets are additionally not found in the default resource list, but are
+   rather nested within a Network, in the Subnets tab as shown above.
+
+.. figure:: captures/az-subnet-label.png
+   :scale: 50 %
+   :alt: subnet label in Azure portal
+
+   The CloudBridge `label` property most often maps to the tag with key
+   'Label' in Azure, which can be found under the tags tab within a resource.
+   However, given that Subnets can't hold tags themselves, we set their tags
+   in the Network with which they are associated. The tag name 'Label' thus
+   corresponds to the Network's label, while each contained Subnet will have
+   a corresponding tag with the name 'SubnetLabel_[subnetName]'.
+
+
+Azure - Unlabeled Resources
+---------------------------
++--------------------+----------------------------------------+-------+---------+----------+
+| Unlabeled Resource | Azure Resource Type                    | CB ID | CB Name | CB Label |
++--------------------+----------------------------------------+-------+---------+----------+
+| KeyPair            | StorageAccount:Table                   | Name  | Name    | -        |
++--------------------+----------------------------------------+-------+---------+----------+
+| Bucket             | StorageAccount:BlobContainer           | Name  | Name    | -        |
++--------------------+----------------------------------------+-------+---------+----------+
+| BucketObject       | StorageAccount:BlobContainer:BlockBlob | Name  | Name    | -        |
++--------------------+----------------------------------------+-------+---------+----------+
+
+The resources listed above are unlabeled. They thus only have the `name`
+property in CloudBridge. These resources require a mandatory `name`
+parameter at creation, which will directly map to the unchangeable `name`
+property. Additionally, for these resources, the `ID` property also maps to
+the `name` in Azure, as these resources don't have an `ID` in the
+traditional sense and can be located simply by name. Finally, unlabeled
+resources support a `name` parameter for the `find` method in their
+corresponding services.
+
+.. figure:: captures/az-storacc.png
+   :scale: 50 %
+   :alt: storage account in Azure portal
+
+   Bucket and Key Pair objects are different than other resources in Azure,
+   as they are not resources simply residing in a resource group, but are
+   rather found in a storage account. As a result of this difference, these
+   resources do not support labels, and cannot be seen on the default
+   dashboard. In order to find these resources in the Azure web portal, one
+   must head to the storage account containing them, and look in the `Blobs`
+   and `Tables` services respectively for `Buckets` and `KeyPairs`.
+
+
+Azure - Special Unlabeled Resources
+-----------------------------------
++--------------------+------------------------+--------------------+--------------------+----------+
+| Unlabeled Resource | Azure Resource Type    | CB ID              | CB Name            | CB Label |
++--------------------+------------------------+--------------------+--------------------+----------+
+| FloatingIP         | Public IP Address      | ID                 | [public_ip]        | -        |
++--------------------+------------------------+--------------------+--------------------+----------+
+| InternetGateway    | None                   | cb-gateway-wrapper | cb-gateway-wrapper | -        |
++--------------------+------------------------+--------------------+--------------------+----------+
+| VMFirewallRule     | Network Security Rules | ID                 | name               | -        |
++--------------------+------------------------+--------------------+--------------------+----------+
+
+While these resources are similarly unlabeled, they do not follow the same
+general rules as the ones listed above. Firstly, they differ by the fact
+that they take neither a `name` nor a `label` parameter at creation.
+Moreover, each of them has other special properties.
+The FloatingIP resource has a traditional resource ID, but instead of a
+traditional name, its `name` property maps to its Public IP. Thus, the name
+seen in the Azure web portal will not map to the CloudBridge name, but will
+rather be auto-generated, while the Azure `IP Address` will map to CloudBridge
+name. Moreover, the corresponding `find` method for Floating IPs can thus help
+find a resource by `Public IP Address`, and the get method also accepts a
+'Public IP' instead of an 'ID'.
+
+In terms of the gateway, one of the major discrepancies in Azure is the
+non-existence of an InternetGateway. In fact, Azure resources are exposed
+with no need for an Internet gateway. However, in order to keep resources
+consistent across providers, the CloudBridge Gateway resource exists
+regardless of provider. For Azure, the gateway object created through
+CloudBridge will not appear on the dashboard, but will rather be a cached
+CloudBridge-level wrapper object.
+For a succinct comparison between AWS Gateways and Azure, see `this answer
+<https://social.msdn.microsoft.com/Forums/en-US/
+814ccee0-9fbb-4c04-8135-49d0aaea5f38/
+equivalent-of-aws-internet-gateways-in-azure?
+forum=WAVirtualMachinesVirtualNetwork>`_.
+
+Finally, Firewall Rules in Azure differ from traditional unlabeled
+resources by the fact that they do not take a `name` parameter at creation.
+These rules can be found within each Firewall (i.e. Security Group) in the
+Azure web portal, and will have an automatically generated `name` of the form
+'cb-rule-[int]'.