From 01ce1d5cb8c72884037a5a1ad18ce7212e79fe75 Mon Sep 17 00:00:00 2001 From: nurfet-becirevic Date: Sun, 3 Sep 2017 17:56:17 -0400 Subject: [PATCH 1/4] ProfitBricks provider API v4 update; fix & update tests and docs --- .../images/provider_logos/profitbricks.png | Bin 0 -> 3866 bytes docs/compute/drivers/profitbricks.rst | 83 + .../compute/profitbricks/create_datacenter.py | 26 + .../compute/profitbricks/create_lan.py | 20 + .../compute/profitbricks/create_node.py | 51 + .../compute/profitbricks/create_volume.py | 29 + .../profitbricks/instantiate_driver.py | 5 + libcloud/compute/drivers/profitbricks.py | 172 +- .../fixtures/profitbricks/attach_volume.json | 10 +- .../fixtures/profitbricks/create_node.json | 10 +- .../fixtures/profitbricks/create_volume.json | 8 +- .../profitbricks/create_volume_snapshot.json | 6 +- .../error_resource_not_found.json | 8 + .../profitbricks/ex_create_datacenter.json | 6 +- .../profitbricks/ex_create_firewall_rule.json | 10 +- .../profitbricks/ex_create_ip_block.json | 6 +- .../fixtures/profitbricks/ex_create_lan.json | 4 +- .../profitbricks/ex_create_load_balancer.json | 25 +- .../ex_create_network_interface.json | 6 +- .../profitbricks/ex_describe_datacenter.json | 60 +- .../ex_describe_firewall_rule.json | 10 +- .../profitbricks/ex_describe_image.json | 5 +- .../profitbricks/ex_describe_ip_block.json | 11 +- .../profitbricks/ex_describe_lan.json | 6 +- .../ex_describe_load_balancer.json | 6 +- .../profitbricks/ex_describe_location.json | 6 +- .../ex_describe_network_interface.json | 8 +- .../profitbricks/ex_describe_node.json | 28 +- .../profitbricks/ex_describe_snapshot.json | 6 +- .../profitbricks/ex_describe_volume.json | 10 +- .../ex_list_attached_volumes.json | 49 +- .../profitbricks/ex_list_datacenters.json | 18 +- .../profitbricks/ex_list_firewall_rules.json | 8 +- .../profitbricks/ex_list_ip_blocks.json | 10 +- .../fixtures/profitbricks/ex_list_lans.json | 24 +- .../ex_list_load_balanced_nics.json | 12 +- .../profitbricks/ex_list_load_balancers.json | 30 +- .../ex_list_network_interfaces.json | 14 +- .../profitbricks/ex_rename_datacenter.json | 16 +- .../profitbricks/ex_set_inet_access.json | 31 - .../profitbricks/ex_update_firewall_rule.json | 10 +- .../profitbricks/ex_update_image.json | 5 +- .../fixtures/profitbricks/ex_update_lan.json | 8 +- .../profitbricks/ex_update_load_balancer.json | 6 +- .../ex_update_network_interface.json | 22 +- .../fixtures/profitbricks/ex_update_node.json | 16 +- .../profitbricks/ex_update_snapshot.json | 6 +- .../profitbricks/ex_update_volume.json | 10 +- .../fixtures/profitbricks/list_images.json | 26 +- .../fixtures/profitbricks/list_locations.json | 83 +- .../fixtures/profitbricks/list_nodes.json | 46 +- .../fixtures/profitbricks/list_snapshots.json | 4 +- .../fixtures/profitbricks/list_volumes.json | 10 +- libcloud/test/compute/test_profitbricks.py | 1485 +++++++---------- 54 files changed, 1298 insertions(+), 1292 deletions(-) create mode 100644 docs/_static/images/provider_logos/profitbricks.png create mode 100644 docs/compute/drivers/profitbricks.rst create mode 100644 docs/examples/compute/profitbricks/create_datacenter.py create mode 100644 docs/examples/compute/profitbricks/create_lan.py create mode 100644 docs/examples/compute/profitbricks/create_node.py create mode 100644 docs/examples/compute/profitbricks/create_volume.py create mode 100644 docs/examples/compute/profitbricks/instantiate_driver.py create mode 100644 libcloud/test/compute/fixtures/profitbricks/error_resource_not_found.json delete mode 100644 libcloud/test/compute/fixtures/profitbricks/ex_set_inet_access.json diff --git a/docs/_static/images/provider_logos/profitbricks.png b/docs/_static/images/provider_logos/profitbricks.png new file mode 100644 index 0000000000000000000000000000000000000000..de1a9eb3285003d9ae1811c163591f5ff998ed1e GIT binary patch literal 3866 zcmV+#59RQQP)GANgE8FM9k^FIH-*80|E@BOZ|zV)qd?U*J@ z)^GH{7D7ghxF|e@u-QeP<8PAk>FH^&5H=Gw8nB7bB*t)2d<(*I;9~#t7%jukY zbKjVpoWk_1-zO~d!5f4Q>K$H2m}8N5CgC=HuN2pbupD^IkY1B8iLi-qhL8gsB&;Hg zFyxsk%4}_VFBD&yuoP`uLl`g8F6XuoRuB#l&ZEw=gzbda2@P^`a$*=UqET+>tty}E zBcGuN@gGGVjT>Fa*V!kZgVThkM80x_BbIsB6Pl@dhY)^3`YDj#!3hyR#mSSF*0BJE zzp|)rFY2g-@JfUiTDJEBi1?4w+v68~%HsVo0e&P*7VoeK;Ty}mhY1S^@gjeJAu~tu z<3YmLgmWI{a=RB1N{Dr@kbKs5bEOhgG)^O zIfOcdx(f9O>4Y7SyFn2D9AT>=kAtR!QOLK4a5?feL)-zvZG;3uNr4K4wwS?Ku7@E0 zZo*+gBbPe4y|qwJ6-9gwCka`;-3<(X zzN3Ug=s-GcLIC2wD$==A-5}Cdsd5kD{&=L{t+*9J+OhsI*B7QxWyyb-YaQ4DT=|X(^ ztti^Vd8)dUSxw|UAv%+h_{=B8ud%AUrXuYdx917n-;tYcL;T~IIvkwIXT+}$xy6E% zw#0uDvfUA0f^Z$5d?ldgf0>Vne}#+OMDcDWyNviLE_q9ck&;o{gZPa^9P84BUCOLP z_>{1gkVS|y5WfrJ>Vtny{47Ix$s&D^2l2VXC1FOZXhZz|n5rBs%xA=R^zzwi#Lu=M z;7rK2MR*ay^?dS`1o5{i;{OmqRVN7XSq-TG%Z5ZEEGrki8-tGTM*KL!5i#Od^B{f` zIr6#@--DQv`1eEI+9l#XVfDq3ue_L*&SQp4h6Sh;p_r5pV%51hmbK#em^rW~mZk;S5KX;ZjF8A+ygRvjy>)utmZkzP1Rh<28au-US98p2mWDKg{eO5}qI= zIK=No=n3nMRB!%7xSdd4Rnijiy$s;^%IXESVOu+4x*+>LLNCOZ^CA9cSm=!tc%1OG zm`&K!SWyuF1Wc0i3I7zB4?TV@Mr__k=pyP2hxj`zOp(hWTRFnS_rqQ$z96n9J`-oU z0>_;cG9$dKIuRzm#yp?AyqH~V`7Czuj36^#qs&3EF%i7z1@;sK*lZzhYsY62H#gYv z&x70=Cq-U1mBvMg_X>i*$_Nwxt`Lcz8L*ym0T#E8 zdU6%Qi!H4>B{AaX7po30ZcDkyC5rdT7Mh}nm&9+a3>b`Sp%*(cpZO5Ku87<3)MIE* ztWwb$`{sM#P=HUQ`G`B)H}ji@6Et`YIyLC5X}y*mTzkPSkHtuDnah+hyk ze`$P4Hq2<;DPBNlNC9rd^Y~H7W!n(HZD0NeV*z)gCevEr@?6;I8_EVsX36g7`^FO)?SxEg|0}V0)&z_}lbw z*-YE0+LMU1cLUVPrrnnLnfMt85G3-Kb+Kp5dTvP z;@{~({IixGmOC%_r(A5u-yM+nKM3Lv5b<+Wo<6Xfd$nf|tSyB^zSTmer%QXPs1D2b zm4J<^Swht^f%iJH*}2Vj11qnH&u#$?9Q%BL`U=5|G0{S{8oVN74QaLDiODlhC;YZ| zv-nW_HH2%q6Ij$63vbPjCULi~HeB>r+A;;3ipA)B= zT1H<-^vVn3I~x{ll$j|J@v&hNzZf=r9uUOeE>1NSioTBMb;*e@76y&f&TXkkR>;c^~TQf3V6k45~g9VVeRjEmX)fGv%__la#~77d>Lg4&^U$3HV{0yrZ z?y)O>$pWe-e=Dg2Htz04_yy@6F4}%K;d<aV5rAGQAMe3*42AgG8*bjEIC>ZY@pr?&g*(6kJ_aZ^f8fe|7!P(Z{BjQ3 zsu3pQ-2+!k*GIQ<^4A-Si{i)=E1$8qL6tN?Yo&b!U$EJlVJfz`=Y3;tEK!B ze2Qflo(mt?`JP?3h0HMLKtEw94g+!f*Wr0G0jJ^}H5U1rBVQKooll~D&2_3aJO{Z^ zc#hNI{hB0XoU_$yu-1AQpLuy-$fQBVD=y-ANByx-h`$?-MUEHep?paE{e=5e9FyoK z5q^wERVBlt(XKFv&#J=^CHF_dP8B!QFv9bC@h3W;>{I0q4TJcZhLMm@nr#>1c(lESLDflDy69_$dT&DhIGc82!O1Gp z7?=C__3La{FrLl7x59l2A$_~JpfR+zy))z1@Zf+#qFYipBGsh%I8H?85JPg$|e1<)M-I{9?5Ps z=$nHuI(J0dwgw=6j@(d!y*vjqhcn`Dm(wdo{M}GXQsLqG4Dw0!Yz$@({({7x3HM_b zVB7n$fD7EgD1U+|YcTw#jwtje7Qo+9xpi`{T1=WQ12&(=fcl^ zW=!;oUb(pG$0PEAJgS?&nKathWg&V+uiPTO9HlQoofTky<@3*#qr{J1zZc^7$NFHT cDcvFdFTeJQb`1|^CjbBd07*qoM6N<$f~ibzM*si- literal 0 HcmV?d00001 diff --git a/docs/compute/drivers/profitbricks.rst b/docs/compute/drivers/profitbricks.rst new file mode 100644 index 0000000000..5c6420c5a2 --- /dev/null +++ b/docs/compute/drivers/profitbricks.rst @@ -0,0 +1,83 @@ +ProfitBricks Driver Documentation +================================= + +`ProfitBricks`_ is an innovative and enterprise-grade IaaS provider. + +.. figure:: /_static/images/provider_logos/profitbricks.png + :align: center + :width: 300 + :target: https://www.profitbricks.com/ + +The ProfitBricks driver allows you to integrate with the `ProfitBricks Cloud API`_ to manage +virtual data centers and other resources located in the United States and Germany availability zones. + +Instantiating a Driver +---------------------- + +Before you start using the ProfitBricks driver you will have to sign up for a ProfitBricks account. +To instantiate a driver you will need to pass your ProfitBrick credentials, i.e., username and password. + +.. literalinclude:: /examples/compute/profitbricks/instantiate_driver.py + :language: python + +Examples +-------- + +Create a data center +~~~~~~~~~~~~~~~~~~~~ + +.. literalinclude:: /examples/compute/profitbricks/create_datacenter.py + :language: python + +Create a LAN +~~~~~~~~~~~~ + +.. literalinclude:: /examples/compute/profitbricks/create_lan.py + :language: python + +Create a node +~~~~~~~~~~~~~ + +.. literalinclude:: /examples/compute/profitbricks/create_node.py + :language: python + +Create an SSD volume +~~~~~~~~~~~~~~~~~~~~ + +.. literalinclude:: /examples/compute/profitbricks/create_volume.py + :language: python + +Refer to the `driver documentation`_ for more examples and code snippets. + +API Docs +-------- + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksNodeDriver + :members: + :inherited-members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.Datacenter + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksNetworkInterface + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksFirewallRule + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksLan + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksLoadBalancer + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksAvailabilityZone + :members: + +.. autoclass:: libcloud.compute.drivers.profitbricks.ProfitBricksIPBlock + :members: + +.. _`ProfitBricks`: https://www.profitbricks.com/ +.. _`ProfitBricks Cloud API`: https://devops.profitbricks.com/api/cloud/ +.. _`driver documentation`: https://devops.profitbricks.com/libraries/libcloud/ + diff --git a/docs/examples/compute/profitbricks/create_datacenter.py b/docs/examples/compute/profitbricks/create_datacenter.py new file mode 100644 index 0000000000..3912af7820 --- /dev/null +++ b/docs/examples/compute/profitbricks/create_datacenter.py @@ -0,0 +1,26 @@ +import os + +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver + +cls = get_driver(Provider.PROFIT_BRICKS) + +# Get ProfitBricks credentials from environment variables +pb_username = os.environ.get('PROFITBRICKS_USERNAME') +pb_password = os.environ.get('PROFITBRICKS_PASSWORD') + +driver = cls(pb_username, pb_password) + +# list available locations +locations = driver.list_locations() + +my_location = None +# US Las Vegas location +for loc in locations: + if loc.id == 'us/las': + my_location = loc + break + +# Create a data center +datacenter = driver.ex_create_datacenter('demo-dc', my_location) +print(datacenter) diff --git a/docs/examples/compute/profitbricks/create_lan.py b/docs/examples/compute/profitbricks/create_lan.py new file mode 100644 index 0000000000..03fe75d103 --- /dev/null +++ b/docs/examples/compute/profitbricks/create_lan.py @@ -0,0 +1,20 @@ +import os + +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver + +cls = get_driver(Provider.PROFIT_BRICKS) + +# Get ProfitBricks credentials from environment variables +pb_username = os.environ.get('PROFITBRICKS_USERNAME') +pb_password = os.environ.get('PROFITBRICKS_PASSWORD') + +driver = cls(pb_username, pb_password) + +datacenters = driver.list_datacenters() +# Looks for existing data centers named 'demo-dc' +datacenter = [dc for dc in datacenters if dc.name == 'demo-dc'][0] + +# Create a public LAN +lan = driver.ex_create_lan(datacenter, is_public=True) +print(lan) diff --git a/docs/examples/compute/profitbricks/create_node.py b/docs/examples/compute/profitbricks/create_node.py new file mode 100644 index 0000000000..7c79e28751 --- /dev/null +++ b/docs/examples/compute/profitbricks/create_node.py @@ -0,0 +1,51 @@ +import os + +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver +from libcloud.compute.base import NodeAuthSSHKey + +cls = get_driver(Provider.PROFIT_BRICKS) + +# Get ProfitBricks credentials from environment variables +pb_username = os.environ.get('PROFITBRICKS_USERNAME') +pb_password = os.environ.get('PROFITBRICKS_PASSWORD') + +driver = cls(pb_username, pb_password) + +# List available sizes +sizes = driver.list_sizes() + +# Medium-size instance +my_size = sizes[1] + +datacenters = driver.ex_list_datacenters() +# Looks for existing data centers named 'demo-dc' +desired_dc = [dc for dc in datacenters if dc.name == 'demo-dc'] + +# Get available HDD public images +images = driver.list_images('HDD') + +my_image = None +# Let's choose Ubuntu-16.04 image in us/las region +for img in images: + if ('Ubuntu-16.04-LTS-server' in img.name and + 'us/las' == img.extra['location']): + my_image = img + break + +node_key = None +# Read SSH key from file +# Specify correct path +with open('/home/user/.ssh/id_rsa.pub', 'r') as f: + node_key = NodeAuthSSHKey(f.read()) +f.close() + +node = driver.create_node( + name='demo-node', + size=my_size, + ex_cpu_family='INTEL_XEON', + image=my_image, + ex_datacenter=desired_dc[0], + ex_ssh_keys=[node_key] +) +print(node) diff --git a/docs/examples/compute/profitbricks/create_volume.py b/docs/examples/compute/profitbricks/create_volume.py new file mode 100644 index 0000000000..a506d292c8 --- /dev/null +++ b/docs/examples/compute/profitbricks/create_volume.py @@ -0,0 +1,29 @@ +import os + +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver + +cls = get_driver(Provider.PROFIT_BRICKS) + +# Get ProfitBricks credentials from environment variables +pb_username = os.environ.get('PROFITBRICKS_USERNAME') +pb_password = os.environ.get('PROFITBRICKS_PASSWORD') + +driver = cls(pb_username, pb_password) + +datacenters = driver.ex_list_datacenters() +location = driver.ex_describe_location(ex_location_id='us/las') +datacenter = [dc for dc in datacenters if dc.extra['location'] == location.id] + +images = driver.list_images(image_type='HDD') +image = [img for img in images if img.extra['location'] == location.id][0] +# Create a new SSD volume. Set `ex_type='HDD'` to create a HDD volume. +ssd_volume = driver.create_volume( + name='Example SSD volume', + size=100, + image=image, + ex_type='SSD', + ex_datacenter=datacenter[0], + ex_password='PuTSoMeSTRONGPaSsWoRdHeRe2017' +) +print(ssd_volume) diff --git a/docs/examples/compute/profitbricks/instantiate_driver.py b/docs/examples/compute/profitbricks/instantiate_driver.py new file mode 100644 index 0000000000..059613aa73 --- /dev/null +++ b/docs/examples/compute/profitbricks/instantiate_driver.py @@ -0,0 +1,5 @@ +from libcloud.compute.types import Provider +from libcloud.compute.providers import get_driver + +cls = get_driver(Provider.PROFIT_BRICKS) +driver = cls('username', 'password') diff --git a/libcloud/compute/drivers/profitbricks.py b/libcloud/compute/drivers/profitbricks.py index 43996d460a..f2d44cb6e1 100644 --- a/libcloud/compute/drivers/profitbricks.py +++ b/libcloud/compute/drivers/profitbricks.py @@ -26,6 +26,7 @@ from libcloud.common.base import ConnectionUserAndKey, JsonResponse from libcloud.compute.base import Node, NodeDriver, NodeLocation, NodeSize from libcloud.compute.base import NodeImage, StorageVolume, VolumeSnapshot +from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey from libcloud.compute.base import UuidMixin from libcloud.compute.types import NodeState from libcloud.common.types import LibcloudError, MalformedResponseError @@ -41,13 +42,14 @@ 'ProfitBricksNetworkInterface', 'ProfitBricksFirewallRule', 'ProfitBricksLan', + 'ProfitBricksIPFailover', 'ProfitBricksLoadBalancer', 'ProfitBricksAvailabilityZone', 'ProfitBricksIPBlock' ] API_HOST = 'api.profitbricks.com' -API_VERSION = '/cloudapi/v3/' +API_VERSION = '/cloudapi/v4/' class ProfitBricksResponse(JsonResponse): @@ -296,6 +298,30 @@ def __repr__(self): % (self.id, self.name, self.href)) +class ProfitBricksIPFailover(object): + """ + Extension class which stores information about a + ProfitBricks LAN's failover + + :param ip: The IP address to fail over. + :type ip: ``str`` + + :param nic_uuid: The ID of the NIC to fail over. + :param nic_uuid: ``str`` + + Note: This class is ProfitBricks specific. + + """ + + def __init__(self, ip, nic_uuid): + self.ip = ip + self.nic_uuid = nic_uuid + + def __repr__(self): + return (('') + % (self.ip, self.nic_uuid)) + + class ProfitBricksLoadBalancer(object): """ Extention class which stores information about a @@ -670,10 +696,10 @@ def create_node( :type ex_disk: ``int`` :param ex_password: The password for the volume. - :type ex_password: ``str`` + :type ex_password: :class:`NodeAuthPassword` :param ex_ssh_keys: Optional SSH keys for the volume. - :type ex_ssh_keys: ``list`` of ``str`` + :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` :param ex_bus_type: Volume bus type (VIRTIO, IDE). :type ex_bus_type: ``str`` @@ -736,7 +762,7 @@ def create_node( ''' If passing in an image we need - to enfore a password or ssh keys. + to enforce a password or ssh keys. ''' if not volume and image is not None: if ex_password is None and ex_ssh_keys is None: @@ -807,10 +833,12 @@ def create_node( } if ex_password is not None: - new_volume['properties']['imagePassword'] = ex_password + new_volume['properties']['imagePassword'] = \ + ex_password.password if ex_ssh_keys is not None: - new_volume['properties']['sshKeys'] = ex_ssh_keys + new_volume['properties']['sshKeys'] = \ + [ssh_key.pubkey for ssh_key in ex_ssh_keys] body['entities']['volumes']['items'].append(new_volume) @@ -1008,9 +1036,10 @@ def attach_volume(self, node, volume): def create_volume( self, size, - image, ex_datacenter, name=None, + image=None, + ex_image_alias=None, ex_type=None, ex_bus_type=None, ex_ssh_keys=None, @@ -1023,9 +1052,6 @@ def create_volume( :param size: The size of the volume in GB. :type size: ``int`` - :param image: The OS image for the volume. - :type image: :class:`NodeImage` - :param ex_datacenter: The datacenter you're placing the storage in. (req) :type ex_datacenter: :class:`Datacenter` @@ -1033,6 +1059,13 @@ def create_volume( :param name: The name to be given to the volume. :param name: ``str`` + :param image: The OS image for the volume. + :type image: :class:`NodeImage` + + :param ex_image_alias: An alias to a ProfitBricks public image. + Use instead of 'image'. + :type ex_image_alias: ``str`` + :param ex_type: The type to be given to the volume (SSD or HDD). :param ex_type: ``str`` @@ -1040,10 +1073,10 @@ def create_volume( :type ex_bus_type: ``str`` :param ex_ssh_keys: Optional SSH keys. - :type ex_ssh_keys: ``dict`` + :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` :param ex_password: Optional password for root. - :type ex_password: ``str`` + :type ex_password: :class:`NodeAuthPassword` :param ex_availability_zone: Volume Availability Zone. :type ex_availability_zone: ``str`` @@ -1056,39 +1089,43 @@ def create_volume( raise ValueError('You need to specify a data center' ' to attach this volume to.') - if not image: - raise ValueError('You need to specify an image' - ' to create this volume from.') - - if image.extra['image_type'] != 'HDD': - raise ValueError('Invalid type of {image_type} specified for ' - '{image_name}, which needs to be of type HDD' - .format(image_type=image.extra['image_type'], - image_name=image.name)) - - if ex_datacenter.extra['location'] != image.extra['location']: - raise ValueError( - 'The image {image_name} ' - '(location: {image_location}) you specified ' - 'is not available at the data center ' - '{datacenter_name} ' - '(location: {datacenter_location}).' - .format( - image_name=image.extra['name'], - datacenter_name=ex_datacenter.extra['name'], - image_location=image.extra['location'], - datacenter_location=ex_datacenter.extra['location'] + if image is not None: + if image.extra['image_type'] != 'HDD': + raise ValueError('Invalid type of {image_type} specified for ' + '{image_name}, which needs to be of type HDD' + .format(image_type=image.extra['image_type'], + image_name=image.name)) + + if ex_datacenter.extra['location'] != image.extra['location']: + raise ValueError( + 'The image {image_name} ' + '(location: {image_location}) you specified ' + 'is not available at the data center ' + '{datacenter_name} ' + '(location: {datacenter_location}).' + .format( + image_name=image.extra['name'], + datacenter_name=ex_datacenter.extra['name'], + image_location=image.extra['location'], + datacenter_location=ex_datacenter.extra['location'] + ) ) - ) + else: + if not ex_image_alias: + raise ValueError('You need to specify an image or image alias' + ' to create this volume from.') action = ex_datacenter.href + '/volumes' body = { 'properties': { - 'size': size, - 'image': image.id + 'size': size } } + if image is not None: + body['properties']['image'] = image.id + else: + body['properties']['imageAlias'] = ex_image_alias if name is not None: body['properties']['name'] = name if ex_type is not None: @@ -1096,9 +1133,10 @@ def create_volume( if ex_bus_type is not None: body['properties']['bus'] = ex_bus_type if ex_ssh_keys is not None: - body['properties']['sshKeys'] = ex_ssh_keys + body['properties']['sshKeys'] = \ + [ssh_key.pubkey for ssh_key in ex_ssh_keys] if ex_password is not None: - body['properties']['imagePassword'] = ex_password + body['properties']['imagePassword'] = ex_password.password if ex_availability_zone is not None: body['properties']['availabilityZone'] = ex_availability_zone @@ -1382,7 +1420,8 @@ def ex_update_node(self, node, name=None, cores=None, :param availability_zone: Update the availability zone. :type availability_zone: :class:`ProfitBricksAvailabilityZone` - :param ex_licence_type: Licence type (WINDOWS, LINUX, OTHER). + :param ex_licence_type: Licence type (WINDOWS, WINDOWS2016, LINUX, + OTHER, UNKNOWN). :type ex_licence_type: ``str`` :param ex_boot_volume: Setting the new boot (HDD) volume. @@ -1531,7 +1570,7 @@ def ex_describe_datacenter(self, ex_href=None, ex_datacenter_id=None): you are describing. :type ex_href: ``str`` - :param ex_datacenter_id: The ID for the data cente + :param ex_datacenter_id: The ID for the data center you are describing. :type ex_datacenter_id: ``str`` @@ -1696,37 +1735,37 @@ def ex_update_image( body['description'] = description if licence_type is not None: - body['licence_type'] = licence_type + body['licenceType'] = licence_type if cpu_hot_plug is not None: - body['cpu_hot_plug'] = cpu_hot_plug + body['cpuHotPlug'] = cpu_hot_plug if cpu_hot_unplug is not None: - body['cpu_hot_unplug'] = cpu_hot_unplug + body['cpuHotUnplug'] = cpu_hot_unplug if ram_hot_plug is not None: - body['ram_hot_plug'] = ram_hot_plug + body['ramHotPlug'] = ram_hot_plug if ram_hot_unplug is not None: - body['ram_hot_unplug'] = ram_hot_unplug + body['ramHotUnplug'] = ram_hot_unplug if nic_hot_plug is not None: - body['nic_hot_plug'] = nic_hot_plug + body['nicHotPlug'] = nic_hot_plug if nic_hot_unplug is not None: - body['nic_hot_unplug'] = nic_hot_unplug + body['nicHotUnplug'] = nic_hot_unplug if disc_virtio_hot_plug is not None: - body['disc_virtio_hot_plug'] = disc_virtio_hot_plug + body['discVirtioHotPlug'] = disc_virtio_hot_plug if disc_virtio_hot_unplug is not None: - body['disc_virtio_hot_unplug'] = disc_virtio_hot_unplug + body['discVirtioHotUnplug'] = disc_virtio_hot_unplug if disc_scsi_hot_plug is not None: - body['disc_scsi_hot_plug'] = disc_scsi_hot_plug + body['discScsiHotPlug'] = disc_scsi_hot_plug if disc_scsi_hot_unplug is not None: - body['disc_scsi_hot_unplug'] = disc_scsi_hot_unplug + body['discScsiHotUnplug'] = disc_scsi_hot_unplug response = self.connection.request( action=action, @@ -1754,7 +1793,7 @@ def ex_describe_location(self, ex_href=None, ex_location_id=None): :type ex_href: ``str`` :param ex_location_id: The id for the location you are - describing ('de/fra', 'de/fkb', 'us/las') + describing ('de/fra', 'de/fkb', 'us/las', 'us/ewr') :type ex_location_id: ``str`` :return: Instance of class ``NodeLocation`` @@ -1766,7 +1805,7 @@ def ex_describe_location(self, ex_href=None, ex_location_id=None): if ex_href is None: if ex_location_id is None: raise ValueError( - 'The loctation ID is required.' + 'The location ID is required.' ) else: use_full_url = False @@ -2347,7 +2386,7 @@ def ex_list_lans(self, datacenter=None): - a datacenter if one is specified - all datacenters if none specified - :param datacenter: The DC you are renaming. + :param datacenter: The parent DC for the LAN. :type datacenter: :class:`Datacenter` :return: ``list`` of class ``ProfitBricksLan`` @@ -2378,13 +2417,16 @@ def ex_list_lans(self, datacenter=None): return lans - def ex_create_lan(self, datacenter, is_public=False, nics=None): + def ex_create_lan(self, datacenter, name=None, is_public=False, nics=None): """ Create and attach a Lan to a data center. - :param datacenter: The DC you are renaming. + :param datacenter: The parent DC for the LAN.. :type datacenter: :class:`Datacenter` + :param name: LAN name. + :type name: ``str`` + :param is_public: True if the Lan is to have internet access. :type is_public: ``bool`` @@ -2398,7 +2440,9 @@ def ex_create_lan(self, datacenter, is_public=False, nics=None): action = datacenter.extra['entities']['lans']['href'] body = { 'properties': { - 'name': 'LAN - {datacenter_name}'.format( + 'name': + name or + 'LAN - {datacenter_name}'.format( datacenter_name=datacenter.name ), 'public': is_public @@ -2472,7 +2516,7 @@ def ex_describe_lan( return self._to_lan(response.object) - def ex_update_lan(self, lan, is_public, name=None): + def ex_update_lan(self, lan, is_public, name=None, ip_failover=None): """ Update a local area network @@ -2486,6 +2530,9 @@ def ex_update_lan(self, lan, is_public, name=None): :param name: The name of the lan. :type name: ``str`` + :param ip_failover: The IP to fail over. + :type ip_failover: ``list`` of :class: ``ProfitBricksIPFailover`` + :return: Instance class ``ProfitBricksLan`` :rtype: :class:`ProfitBricksLan` """ @@ -2497,6 +2544,10 @@ def ex_update_lan(self, lan, is_public, name=None): if name is not None: body['name'] = name + if ip_failover is not None: + body['ipFailover'] = [{'ip': item.ip, 'nicUuid': item.nic_uuid} + for item in ip_failover] + request = self.connection.request( action=action, headers={ @@ -2908,7 +2959,7 @@ def ex_create_load_balancer( """ Create and attach a load balancer to a data center. - :param datacenter: The DC you are renaming. + :param datacenter: The parent DC for the load balancer. :type datacenter: :class:`Datacenter` :param name: Load balancer name. @@ -3595,6 +3646,7 @@ def _to_image(self, image, headers=None): 'discScsiHotUnplug': 'disc_scsi_hot_unplug', 'licenceType': 'licence_type', 'imageType': 'image_type', + 'imageAliases': 'image_aliases', 'public': 'public' } } diff --git a/libcloud/test/compute/fixtures/profitbricks/attach_volume.json b/libcloud/test/compute/fixtures/profitbricks/attach_volume.json index eda9a22aa5..700aa0f5d6 100644 --- a/libcloud/test/compute/fixtures/profitbricks/attach_volume.json +++ b/libcloud/test/compute/fixtures/profitbricks/attach_volume.json @@ -1,7 +1,7 @@ { "id" : "vol-2", "type" : "volume", - "href" : "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", + "href" : "/cloudapi/v4/datacenters/dc-1/volumes/vol-2", "metadata" : { "createdDate" : "2016-10-17T13:13:36Z", "createdBy" : "test@test.te", @@ -11,14 +11,14 @@ "state" : "BUSY" }, "properties" : { - "name" : "Updated storage name", + "name" : "libcloud Test", "type" : "HDD", - "size" : 40, + "size" : 2, "image" : "bvol-img", "imagePassword" : null, "sshKeys": null, "bus" : "VIRTIO", - "licenceType" : "LINUX", + "licenceType" : "UNKNOWN", "cpuHotPlug" : true, "cpuHotUnplug" : false, "ramHotPlug" : true, @@ -29,6 +29,6 @@ "discVirtioHotUnplug" : true, "discScsiHotPlug" : false, "discScsiHotUnplug" : false, - "deviceNumber" : 3 + "deviceNumber" : 2 } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/create_node.json b/libcloud/test/compute/fixtures/profitbricks/create_node.json index b7329805a2..8a129f42fb 100644 --- a/libcloud/test/compute/fixtures/profitbricks/create_node.json +++ b/libcloud/test/compute/fixtures/profitbricks/create_node.json @@ -1,7 +1,7 @@ { "id": "srv-2", "type": "server", - "href": "cloudapi/v3/datacenters/f3f7ca3c-6f3d-4a4d-b3d6-15853ae5ba78/servers/srv-2", + "href": "cloudapi/v4/datacenters/f3f7ca3c-6f3d-4a4d-b3d6-15853ae5ba78/servers/srv-2", "metadata": { "createdDate": "2016-10-19T13:25:19Z", "createdBy": "test@test.te", @@ -11,9 +11,9 @@ "state": "BUSY" }, "properties": { - "name": "Test", + "name": "libcloud Test", "cores": 1, - "ram": 512, + "ram": 1024, "availabilityZone": "ZONE_1", "vmState": null, "bootCdrom": null, @@ -24,12 +24,12 @@ "volumes": { "id": "srv-2/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/f3f7ca3c-6f3d-4a4d-b3d6-15853ae5ba78/servers/srv-2/volumes", + "href": "/cloudapi/v4/datacenters/f3f7ca3c-6f3d-4a4d-b3d6-15853ae5ba78/servers/srv-2/volumes", "items": [ { "id": "53abb4de-b37b-4025-b139-3e09141e20bb", "type": "volume", - "href": "/cloudapi/v3/datacenters/srv-2/volumes/53abb4de-b37b-4025-b139-3e09141e20bb" + "href": "/cloudapi/v4/datacenters/srv-2/volumes/53abb4de-b37b-4025-b139-3e09141e20bb" } ] } diff --git a/libcloud/test/compute/fixtures/profitbricks/create_volume.json b/libcloud/test/compute/fixtures/profitbricks/create_volume.json index 59720d9c07..5118cde2d6 100644 --- a/libcloud/test/compute/fixtures/profitbricks/create_volume.json +++ b/libcloud/test/compute/fixtures/profitbricks/create_volume.json @@ -1,7 +1,7 @@ { "id" : "vol-2", "type" : "volume", - "href" : "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", + "href" : "/cloudapi/v4/datacenters/dc-1/volumes/vol-2", "metadata" : { "createdDate" : "2016-10-17T13:13:36Z", "createdBy" : "test@test.te", @@ -11,10 +11,10 @@ "state" : "BUSY" }, "properties" : { - "name": "Updated storage name", + "name": "libcloud Test", "type": "HDD", - "size": 40, - "availabilityZone": "AUTO", + "size": 2, + "availabilityZone": "ZONE_3", "image": "bvol-img", "imagePassword": null, "sshKeys": null, diff --git a/libcloud/test/compute/fixtures/profitbricks/create_volume_snapshot.json b/libcloud/test/compute/fixtures/profitbricks/create_volume_snapshot.json index a90f585bfd..da1eec6165 100644 --- a/libcloud/test/compute/fixtures/profitbricks/create_volume_snapshot.json +++ b/libcloud/test/compute/fixtures/profitbricks/create_volume_snapshot.json @@ -1,7 +1,7 @@ { "id": "sshot", "type": "snapshot", - "href": "/cloudapi/v3/snapshots/sshot", + "href": "/cloudapi/v4/snapshots/sshot", "metadata": { "createdDate": "2016-10-26T11:38:45Z", "createdBy": "test@test.te", @@ -11,8 +11,8 @@ "state": "BUSY" }, "properties": { - "name": "Test Created Snapshot", - "description": "Test Created Snapshot", + "name": "libcloud Test", + "description": "libcloud test snapshot", "location": "us/las", "size": 10, "cpuHotPlug": true, diff --git a/libcloud/test/compute/fixtures/profitbricks/error_resource_not_found.json b/libcloud/test/compute/fixtures/profitbricks/error_resource_not_found.json new file mode 100644 index 0000000000..d0ce3c3938 --- /dev/null +++ b/libcloud/test/compute/fixtures/profitbricks/error_resource_not_found.json @@ -0,0 +1,8 @@ +{ + "httpStatus": 404, + "messages": [{ + "errorCode": "309", + "message": "Resource does not exist" + } + ] +} \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_datacenter.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_datacenter.json index 3f4268967c..e819d8ef00 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_datacenter.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_datacenter.json @@ -1,7 +1,7 @@ { "id": "dc-1", "type": "datacenter", - "href": "/cloudapi/v3/datacenters/dc-1", + "href": "/cloudapi/v4/datacenters/dc-1", "metadata": { "createdDate": "2016-10-18T17:20:56Z", "createdBy": "test@test.te", @@ -11,8 +11,8 @@ "state": "BUSY" }, "properties": { - "name": "Test Data Center", - "description": "Test Data Center.", + "name": "libcloud Test", + "description": "libcloud test datacenter", "location": "us/las", "version": null, "features": [] diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_firewall_rule.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_firewall_rule.json index a5f4210a57..fe1f685864 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_firewall_rule.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_firewall_rule.json @@ -1,7 +1,7 @@ { "id": "fwr-1", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fwr-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fwr-1", "metadata": { "createdDate": "2016-10-19T11:08:04Z", "createdBy": "test@test.te", @@ -11,14 +11,14 @@ "state": "BUSY" }, "properties": { - "name": "Test created firewall rule", + "name": "SSH", "protocol": "TCP", - "sourceMac": null, + "sourceMac": "01:23:45:67:89:00", "sourceIp": null, "targetIp": null, "icmpCode": null, "icmpType": null, - "portRangeStart": 80, - "portRangeEnd": 80 + "portRangeStart": 22, + "portRangeEnd": 22 } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_ip_block.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_ip_block.json index 56b05449ca..b561bb081f 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_ip_block.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_ip_block.json @@ -1,7 +1,7 @@ { "id": "ipb-1", "type": "ipblock", - "href": "/cloudapi/v3/ipblocks/ipb-1", + "href": "/cloudapi/v4/ipblocks/ipb-1", "metadata": { "createdDate": "2016-10-26T15:05:36Z", "createdBy": "test@test.te", @@ -15,8 +15,8 @@ "11.12.13.14", "15.16.17.18" ], - "location": "de/fkb", + "location": "us/las", "size": 2, - "name": "Test Created IP Block" + "name": "libcloud Test" } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_lan.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_lan.json index 0e2b9cc913..c76ed44f58 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_lan.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_lan.json @@ -1,7 +1,7 @@ { "id" : "10", "type" : "lan", - "href" : "/cloudapi/v3/datacenters/dc-1/lans/10", + "href" : "/cloudapi/v4/datacenters/dc-1/lans/10", "metadata" : { "createdDate": "2016-10-17T11:33:11Z", "createdBy": "test@test.te", @@ -11,7 +11,7 @@ "state": "BUSY" }, "properties" : { - "name" : "Test Created Lan", + "name" : "libcloud Test", "public" : true } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_load_balancer.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_load_balancer.json index 67af86b321..3f7761c4e3 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_load_balancer.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_load_balancer.json @@ -1,7 +1,7 @@ { "id": "bal-1", "type": "loadbalancer", - "href": "/cloudapi/v3/datacenters/dc-1/loadbalancers/bal-1", + "href": "/cloudapi/v4/datacenters/dc-1/loadbalancers/bal-1", "metadata": { "createdDate": "2016-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -11,8 +11,29 @@ "state": "BUSY" }, "properties": { - "name": "Test load balancer", + "name": "libcloud Test", "ip": null, "dhcp": true + }, + "entities": { + "balancednics": { + "id": "bal-1/balancednics", + "type": "collection", + "href": "cloudapi/v4/datacenters/dc-1/loadbalancers/bal-1/balancednics", + "items": [{ + "id": "nic-1", + "type": "nic", + "href": "cloudapi/v4/datacenters/dc-1/servers/bal-1/nics/nic-1", + "metadata": { + "createdDate": "2016-10-17T15:46:38Z", + "createdBy": "test@test.te", + "etag": "dbd8216137cf0ec9951170f93fa8fa53", + "lastModifiedDate": "2016-10-17T18:19:43Z", + "lastModifiedBy": "test@test.te", + "state": "BUSY" + } + } + ] + } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_create_network_interface.json b/libcloud/test/compute/fixtures/profitbricks/ex_create_network_interface.json index 5e45994a5a..0210b83fe5 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_create_network_interface.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_create_network_interface.json @@ -1,7 +1,7 @@ { "id": "nic-2", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics/nic-2", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics/nic-2", "metadata": { "createdDate": "2016-10-19T08:18:50Z", "createdBy": "test@test.te", @@ -11,9 +11,9 @@ "state": "BUSY" }, "properties": { - "name": "Creating a test network interface.", + "name": "libcloud Test", "mac": null, - "ips": [], + "ips": [ "10.0.0.1" ], "dhcp": true, "lan": 1, "firewallActive": null, diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_datacenter.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_datacenter.json index 4f20e63f30..36ba13d57d 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_datacenter.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_datacenter.json @@ -1,7 +1,7 @@ { "id": "dc-1", "type": "datacenter", - "href": "/cloudapi/v3/datacenters/dc-1", + "href": "/cloudapi/v4/datacenters/dc-1", "metadata": { "createdDate": "2016-10-17T11:33:11Z", "createdBy": "test@test.test", @@ -11,9 +11,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Data Center", - "description": "This is a test data center.", - "location": "de/fkb", + "name": "libcloud Test", + "description": "libcloud test datacenter", + "location": "us/las", "version": 35, "features": [ "SSD", @@ -24,12 +24,12 @@ "servers": { "id": "dc-1/servers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers", + "href": "/cloudapi/v4/datacenters/dc-1/servers", "items": [ { "id": "srv-1", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1", "metadata": { "createdDate": "2016-10-18T07:28:05Z", "createdBy": "test@test.test", @@ -48,7 +48,7 @@ "bootVolume": { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -84,35 +84,35 @@ "cdroms": { "id": "srv-1/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/cdroms", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/cdroms", "items": [] }, "volumes": { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes", "items": [ { "id": "d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3" }, { "id": "vol-2", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/vol-2" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/vol-2" }, { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1" } ] }, "nics": { "id": "srv-1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics", "items": [] } } @@ -120,7 +120,7 @@ { "id": "s-3", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3", "metadata": { "createdDate": "2016-10-17T11:33:20Z", "createdBy": "test@test.test", @@ -139,7 +139,7 @@ "bootVolume": { "id": "21d7e7de-5054-4041-b691-717aa8b3c799", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", "metadata": { "createdDate": "2016-10-17T11:33:20Z", "createdBy": "test@test.test", @@ -175,30 +175,30 @@ "cdroms": { "id": "s-3/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/cdroms", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/cdroms", "items": [] }, "volumes": { "id": "s-3/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/volumes", "items": [ { "id": "21d7e7de-5054-4041-b691-717aa8b3c799", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799" } ] }, "nics": { "id": "s-3/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics", "items": [ { "id": "nic-1", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1" } ] } @@ -209,12 +209,12 @@ "volumes": { "id": "dc-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/volumes", "items": [ { "id": "vol-2", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/vol-2", "metadata": { "createdDate": "2016-10-18T15:13:44Z", "createdBy": "test@test.test", @@ -249,7 +249,7 @@ { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -284,7 +284,7 @@ { "id": "d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "metadata": { "createdDate": "2016-10-17T13:13:36Z", "createdBy": "test@test.test", @@ -319,7 +319,7 @@ { "id": "21d7e7de-5054-4041-b691-717aa8b3c799", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", "metadata": { "createdDate": "2016-10-17T11:33:20Z", "createdBy": "test@test.test", @@ -356,18 +356,18 @@ "loadbalancers": { "id": "dc-1/loadbalancers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/loadbalancers", + "href": "/cloudapi/v4/datacenters/dc-1/loadbalancers", "items": [] }, "lans": { "id": "dc-1/lans", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans", + "href": "/cloudapi/v4/datacenters/dc-1/lans", "items": [ { "id": "2", "type": "lan", - "href": "/cloudapi/v3/datacenters/dc-1/lans/2", + "href": "/cloudapi/v4/datacenters/dc-1/lans/2", "metadata": { "createdDate": "2016-10-17T18:19:43Z", "createdBy": "test@test.test", @@ -384,12 +384,12 @@ "nics": { "id": "2/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans/2/nics", + "href": "/cloudapi/v4/datacenters/dc-1/lans/2/nics", "items": [ { "id": "nic-1", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1" } ] } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_firewall_rule.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_firewall_rule.json index 523245d403..5573809fd0 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_firewall_rule.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_firewall_rule.json @@ -1,7 +1,7 @@ { "id": "fw2", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", "metadata": { "createdDate": "2016-10-19T09:55:10Z", "createdBy": "test@test.te", @@ -11,14 +11,14 @@ "state": "AVAILABLE" }, "properties": { - "name": "HTTPs (SSL)", + "name": "SSH", "protocol": "TCP", - "sourceMac": null, + "sourceMac": "01:23:45:67:89:00", "sourceIp": null, "targetIp": null, "icmpCode": null, "icmpType": null, - "portRangeStart": 443, - "portRangeEnd": 443 + "portRangeStart": 22, + "portRangeEnd": 22 } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_image.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_image.json index a6977ac517..bf3faf4a36 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_image.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_image.json @@ -1,7 +1,7 @@ { "id": "img-2", "type": "image", - "href": "/cloudapi/v3/images/img-2", + "href": "/cloudapi/v4/images/img-2", "metadata": { "createdDate": "2015-10-09T12:06:34Z", "createdBy": "test@test.te", @@ -13,7 +13,7 @@ "properties": { "name": "vivid-server-cloudimg-amd64-disk1.img", "description": null, - "location": "de/fkb", + "location": "us/las", "size": 2, "cpuHotPlug": false, "cpuHotUnplug": false, @@ -27,6 +27,7 @@ "discScsiHotUnplug": false, "licenceType": "UNKNOWN", "imageType": "HDD", + "imageAliases": [ ], "public": false } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_ip_block.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_ip_block.json index 63f59e5b39..1abab89f03 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_ip_block.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_ip_block.json @@ -1,7 +1,7 @@ { "id": "ipb-2", "type": "ipblock", - "href": "/cloudapi/v3/ipblocks/ipb-2", + "href": "/cloudapi/v4/ipblocks/ipb-2", "metadata": { "createdDate": "2016-10-26T15:05:12Z", "createdBy": "test@test.te", @@ -12,10 +12,11 @@ }, "properties": { "ips": [ - "78.137.101.250" + "208.94.36.101", + "192.152.28.137" ], - "location": "de/fkb", - "size": 1, - "name": "Test IP Block One" + "location": "us/las", + "size": 2, + "name": "libcloud Test" } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_lan.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_lan.json index 459a74e053..f7612955a2 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_lan.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_lan.json @@ -1,7 +1,7 @@ { "id" : "10", "type" : "lan", - "href" : "/cloudapi/v3/datacenters/dc-1/lans/10", + "href" : "/cloudapi/v4/datacenters/dc-1/lans/10", "metadata" : { "createdDate": "2016-10-17T11:33:11Z", "createdBy": "test@test.te", @@ -11,14 +11,14 @@ "state": "BUSY" }, "properties" : { - "name" : "Test Created Lan", + "name" : "libcloud Test", "public" : true }, "entities": { "nics": { "id": "10/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans/10/nics" + "href": "/cloudapi/v4/datacenters/dc-1/lans/10/nics" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_load_balancer.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_load_balancer.json index bb2643427f..2ddd7d675e 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_load_balancer.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_load_balancer.json @@ -1,7 +1,7 @@ { "id": "bal-1", "type": "loadbalancer", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/bal-1", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/bal-1", "metadata": { "createdDate": "2016-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -11,7 +11,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test One", + "name": "libcloud Test", "ip": "111.112.113.114", "dhcp": true }, @@ -19,7 +19,7 @@ "balancednics": { "id": "bal-1/balancednics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/bal-1/balancednics" + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/bal-1/balancednics" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_location.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_location.json index 6cd662864a..845c7ef303 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_location.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_location.json @@ -1,9 +1,9 @@ { - "id": "de/fkb", + "id": "us/las", "type": "location", - "href": "/cloudapi/v3/locations/de/fkb", + "href": "/cloudapi/v4/locations/us/las", "properties": { - "name": "karlsruhe", + "name": "lasvegas", "features": [ "SSD", "MULTIPLE_CPU" diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_network_interface.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_network_interface.json index dedecce410..3ff65857f5 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_network_interface.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_network_interface.json @@ -1,7 +1,7 @@ { "id": "nic-2", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2", "metadata": { "createdDate": "2016-10-17T15:46:38Z", "createdBy": "test@test.te", @@ -11,12 +11,12 @@ "state": "AVAILABLE" }, "properties": { - "name": "Updated from LibCloud", + "name": "libcloud Test", "mac": "02:01:0b:9d:4d:ce", "ips": [ "10.15.124.11" ], - "dhcp": false, + "dhcp": true, "lan": 2, "firewallActive": true, "nat": false @@ -25,7 +25,7 @@ "firewallrules": { "id": "nic-1/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_node.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_node.json index 476a4b946e..88e2b5ff0e 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_node.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_node.json @@ -1,7 +1,7 @@ { "id": "srv-1", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1", "metadata": { "createdDate": "2016-10-18T07:28:05Z", "createdBy": "test@test.test", @@ -11,16 +11,16 @@ "state": "AVAILABLE" }, "properties": { - "name": "A test node", - "cores": 2, - "ram": 4096, - "availabilityZone": "AUTO", + "name": "libcloud Test", + "cores": 1, + "ram": 1024, + "availabilityZone": "ZONE_1", "vmState": "RUNNING", "bootCdrom": null, "bootVolume": { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -30,9 +30,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "A test node boot volume", + "name": "libcloud Test", "type": "HDD", - "size": 10, + "size": 2, "image": "bvol-img", "imagePassword": null, "bus": "VIRTIO", @@ -56,18 +56,18 @@ "cdroms": { "id": "srv-1/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/cdroms", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/cdroms", "items": [] }, "volumes": { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes", "items": [ { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -77,9 +77,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "A test node volume", + "name": "libcloud Test", "type": "HDD", - "size": 10, + "size": 2, "availabilityZone": "AUTO", "image": "bvol-img", "imagePassword": null, @@ -104,7 +104,7 @@ "nics": { "id": "srv-1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics", "items": [] } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_snapshot.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_snapshot.json index 06cce65971..10a2f1c468 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_snapshot.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_snapshot.json @@ -1,7 +1,7 @@ { "id": "sshot", "type": "snapshot", - "href": "/cloudapi/v3/snapshots/sshot", + "href": "/cloudapi/v4/snapshots/sshot", "metadata": { "createdDate": "2016-10-26T11:38:45Z", "createdBy": "test@test.te", @@ -11,8 +11,8 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Snapshot", - "description": "Test Snapshot", + "name": "libcloud Test", + "description": "libcloud test snapshot", "location": "us/las", "size": 10, "cpuHotPlug": true, diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_describe_volume.json b/libcloud/test/compute/fixtures/profitbricks/ex_describe_volume.json index d0eab6af68..732d8f912a 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_describe_volume.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_describe_volume.json @@ -1,7 +1,7 @@ { "id": "vol-2", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/vol-2", "metadata": { "createdDate": "2016-10-17T13:13:36Z", "createdBy": "test@test.te", @@ -11,15 +11,15 @@ "state": "AVAILABLE" }, "properties": { - "name": "Updated storage name", + "name": "libcloud Test", "type": "HDD", - "size": 40, - "availabilityZone": "AUTO", + "size": 2, + "availabilityZone": "ZONE_3", "image": "bvol-img", "imagePassword": null, "sshKeys": null, "bus": "VIRTIO", - "licenceType": "LINUX", + "licenceType": "UNKNOWN", "cpuHotPlug": true, "cpuHotUnplug": false, "ramHotPlug": true, diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_attached_volumes.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_attached_volumes.json index 6777ba3bb5..c422c004ac 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_attached_volumes.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_attached_volumes.json @@ -1,12 +1,12 @@ { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes", "items": [ { "id": "d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "metadata": { "createdDate": "2016-10-17T13:13:36Z", "createdBy": "test@test.test", @@ -16,15 +16,15 @@ "state": "AVAILABLE" }, "properties": { - "name": "Volume one", + "name": "libcloud Test", "type": "HDD", - "size": 40, + "size": 2, "availabilityZone": "AUTO", "image": "bvol-img", "imagePassword": null, "sshKeys": null, "bus": "VIRTIO", - "licenceType": "LINUX", + "licenceType": "UNKNOWN", "cpuHotPlug": true, "cpuHotUnplug": false, "ramHotPlug": true, @@ -35,48 +35,13 @@ "discVirtioHotUnplug": true, "discScsiHotPlug": false, "discScsiHotUnplug": false, - "deviceNumber": 3 - } - }, - { - "id": "vol-2", - "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", - "metadata": { - "createdDate": "2016-10-18T15:13:44Z", - "createdBy": "test@test.test", - "etag": "a96f7781920c2890c25f967e66e6ee91", - "lastModifiedDate": "2016-10-18T15:13:44Z", - "lastModifiedBy": "test@test.test", - "state": "AVAILABLE" - }, - "properties": { - "name": "Volume two", - "type": "HDD", - "size": 10, - "availabilityZone": "AUTO", - "image": null, - "imagePassword": null, - "sshKeys": null, - "bus": "VIRTIO", - "licenceType": null, - "cpuHotPlug": false, - "cpuHotUnplug": false, - "ramHotPlug": false, - "ramHotUnplug": false, - "nicHotPlug": false, - "nicHotUnplug": false, - "discVirtioHotPlug": false, - "discVirtioHotUnplug": false, - "discScsiHotPlug": false, - "discScsiHotUnplug": false, "deviceNumber": 2 } }, { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -86,7 +51,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Volume three", + "name": "libcloud Test", "type": "HDD", "size": 10, "availabilityZone": "AUTO", diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_datacenters.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_datacenters.json index 912c0fcf1d..d13ff6b6f1 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_datacenters.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_datacenters.json @@ -1,12 +1,12 @@ { "id": "datacenters", "type": "collection", - "href": "/cloudapi/v3/datacenters/", + "href": "/cloudapi/v4/datacenters/", "items": [ { "id": "dc-1", "type": "datacenter", - "href": "/cloudapi/v3/datacenters/dc-1", + "href": "/cloudapi/v4/datacenters/dc-1", "metadata": { "createdDate": "2016-10-14T07:24:59Z", "createdBy": "test@test.test", @@ -16,9 +16,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test One.", - "description": "A test data center", - "location": "de/fra", + "name": "libcloud Test", + "description": "libcloud test datacenter", + "location": "us/las", "version": 3, "features": [ "SSD", @@ -29,22 +29,22 @@ "servers": { "id": "983a45be-a9aa-427a-8117-271ce9f392bb/servers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers" + "href": "/cloudapi/v4/datacenters/dc-1/servers" }, "volumes": { "id": "983a45be-a9aa-427a-8117-271ce9f392bb/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/volumes" + "href": "/cloudapi/v4/datacenters/dc-1/volumes" }, "loadbalancers": { "id": "983a45be-a9aa-427a-8117-271ce9f392bb/loadbalancers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/loadbalancers" + "href": "/cloudapi/v4/datacenters/dc-1/loadbalancers" }, "lans": { "id": "983a45be-a9aa-427a-8117-271ce9f392bb/lans", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans" + "href": "/cloudapi/v4/datacenters/dc-1/lans" } } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_firewall_rules.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_firewall_rules.json index 71288772f3..bd31786a2d 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_firewall_rules.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_firewall_rules.json @@ -1,12 +1,12 @@ { "id": "nic-2/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules", "items": [ { "id": "fwr-1", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fwr-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fwr-1", "metadata": { "createdDate": "2016-10-19T11:08:10Z", "createdBy": "test@test.te", @@ -30,7 +30,7 @@ { "id": "fw2", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", "metadata": { "createdDate": "2016-10-19T09:55:10Z", "createdBy": "test@test.te", @@ -54,7 +54,7 @@ { "id": "6238b1e2-c706-4dc9-80a9-307fa0bd4287", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/6238b1e2-c706-4dc9-80a9-307fa0bd4287", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/6238b1e2-c706-4dc9-80a9-307fa0bd4287", "metadata": { "createdDate": "2016-10-19T09:55:10Z", "createdBy": "test@test.te", diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_ip_blocks.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_ip_blocks.json index df3c9cbab4..a935adb440 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_ip_blocks.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_ip_blocks.json @@ -1,12 +1,12 @@ { "id": "ipblocks", "type": "collection", - "href": "/cloudapi/v3/ipblocks", + "href": "/cloudapi/v4/ipblocks", "items": [ { "id": "ipb-1", "type": "ipblock", - "href": "/cloudapi/v3/ipblocks/ipb-1", + "href": "/cloudapi/v4/ipblocks/ipb-1", "metadata": { "createdDate": "2016-10-26T15:05:36Z", "createdBy": "test@test.te", @@ -20,7 +20,7 @@ "78.137.101.252", "78.137.101.251" ], - "location": "de/fkb", + "location": "us/las", "size": 2, "name": "Test IP Block One" } @@ -28,7 +28,7 @@ { "id": "ipb-2", "type": "ipblock", - "href": "/cloudapi/v3/ipblocks/ipb-2", + "href": "/cloudapi/v4/ipblocks/ipb-2", "metadata": { "createdDate": "2016-10-26T15:05:12Z", "createdBy": "test@test.te", @@ -41,7 +41,7 @@ "ips": [ "78.137.101.250" ], - "location": "de/fkb", + "location": "us/las", "size": 1, "name": "Test IP Block One" } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_lans.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_lans.json index ede4187be8..569538859a 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_lans.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_lans.json @@ -1,12 +1,12 @@ { "id": "dc-1/lans", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans", + "href": "/cloudapi/v4/datacenters/dc-1/lans", "items": [ { "id": "1", "type": "lan", - "href": "/cloudapi/v3/datacenters/dc-1/lans/1", + "href": "/cloudapi/v4/datacenters/dc-1/lans/1", "metadata": { "createdDate": "2016-10-24T08:03:22Z", "createdBy": "test@test.te", @@ -16,19 +16,19 @@ "state": "AVAILABLE" }, "properties": { - "name": "Switch for LAN 1", + "name": "libcloud Test", "public": false }, "entities": { "nics": { "id": "1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans/1/nics", + "href": "/cloudapi/v4/datacenters/dc-1/lans/1/nics", "items": [ { "id": "dc5e1c66-7280-4a5c-8e13-51ce030e0980", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/d37abf6b-0980-4bf8-813b-b69863cf7b9e/nics/dc5e1c66-7280-4a5c-8e13-51ce030e0980", + "href": "/cloudapi/v4/datacenters/dc-1/servers/d37abf6b-0980-4bf8-813b-b69863cf7b9e/nics/dc5e1c66-7280-4a5c-8e13-51ce030e0980", "metadata": { "createdDate": "2016-10-21T13:00:02Z", "createdBy": "test@test.te", @@ -52,14 +52,14 @@ "firewallrules": { "id": "dc5e1c66-7280-4a5c-8e13-51ce030e0980/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/d37abf6b-0980-4bf8-813b-b69863cf7b9e/nics/dc5e1c66-7280-4a5c-8e13-51ce030e0980/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/d37abf6b-0980-4bf8-813b-b69863cf7b9e/nics/dc5e1c66-7280-4a5c-8e13-51ce030e0980/firewallrules" } } }, { "id": "912324a6-c057-445d-84dd-8fea82dfa719", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/811ab72b-f7f3-427b-8220-f031eae34f63/nics/912324a6-c057-445d-84dd-8fea82dfa719", + "href": "/cloudapi/v4/datacenters/dc-1/servers/811ab72b-f7f3-427b-8220-f031eae34f63/nics/912324a6-c057-445d-84dd-8fea82dfa719", "metadata": { "createdDate": "2016-10-21T13:00:02Z", "createdBy": "test@test.te", @@ -83,14 +83,14 @@ "firewallrules": { "id": "912324a6-c057-445d-84dd-8fea82dfa719/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/811ab72b-f7f3-427b-8220-f031eae34f63/nics/912324a6-c057-445d-84dd-8fea82dfa719/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/811ab72b-f7f3-427b-8220-f031eae34f63/nics/912324a6-c057-445d-84dd-8fea82dfa719/firewallrules" } } }, { "id": "8d9fb87c-79f7-4c3c-8f7b-e2050a881b16", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/b1a64861-5819-498a-899a-a57126050952/nics/8d9fb87c-79f7-4c3c-8f7b-e2050a881b16", + "href": "/cloudapi/v4/datacenters/dc-1/servers/b1a64861-5819-498a-899a-a57126050952/nics/8d9fb87c-79f7-4c3c-8f7b-e2050a881b16", "metadata": { "createdDate": "2016-10-21T13:00:02Z", "createdBy": "test@test.te", @@ -114,14 +114,14 @@ "firewallrules": { "id": "8d9fb87c-79f7-4c3c-8f7b-e2050a881b16/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/b1a64861-5819-498a-899a-a57126050952/nics/8d9fb87c-79f7-4c3c-8f7b-e2050a881b16/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/b1a64861-5819-498a-899a-a57126050952/nics/8d9fb87c-79f7-4c3c-8f7b-e2050a881b16/firewallrules" } } }, { "id": "76d7965d-19e5-491f-8b2f-1c4a3ef127b5", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/77ef2301-b4df-46aa-8544-2dae76c9d7b5/nics/76d7965d-19e5-491f-8b2f-1c4a3ef127b5", + "href": "/cloudapi/v4/datacenters/dc-1/servers/77ef2301-b4df-46aa-8544-2dae76c9d7b5/nics/76d7965d-19e5-491f-8b2f-1c4a3ef127b5", "metadata": { "createdDate": "2016-10-21T13:00:02Z", "createdBy": "test@test.te", @@ -145,7 +145,7 @@ "firewallrules": { "id": "76d7965d-19e5-491f-8b2f-1c4a3ef127b5/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/77ef2301-b4df-46aa-8544-2dae76c9d7b5/nics/76d7965d-19e5-491f-8b2f-1c4a3ef127b5/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/77ef2301-b4df-46aa-8544-2dae76c9d7b5/nics/76d7965d-19e5-491f-8b2f-1c4a3ef127b5/firewallrules" } } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balanced_nics.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balanced_nics.json index bdd7ec31bf..348b5216e5 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balanced_nics.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balanced_nics.json @@ -1,12 +1,12 @@ { "id": "s-3/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics", "items": [ { "id": "nic-1", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1", "metadata": { "createdDate": "2016-10-17T15:46:38Z", "createdBy": "test@test.te", @@ -16,7 +16,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test network interface", + "name": "libcloud Test", "mac": "02:01:0b:9d:4d:ce", "ips": [ "10.15.124.11" @@ -30,14 +30,14 @@ "firewallrules": { "id": "nic-1/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" } } }, { "id": "8f7ea845-cf40-49c8-9e93-68366f31d605", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/8f7ea845-cf40-49c8-9e93-68366f31d605", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/8f7ea845-cf40-49c8-9e93-68366f31d605", "metadata": { "createdDate": "2016-10-17T16:46:38Z", "createdBy": "test@test.te", @@ -61,7 +61,7 @@ "firewallrules": { "id": "8f7ea845-cf40-49c8-9e93-68366f31d605/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" } } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balancers.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balancers.json index ffb3ef0d2d..f1d0cd1e6b 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balancers.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_load_balancers.json @@ -1,12 +1,12 @@ { "id": "dc-2/loadbalancers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers", "items": [ { "id": "bal-1", "type": "loadbalancer", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/bal-1", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/bal-1", "metadata": { "createdDate": "2016-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -24,12 +24,12 @@ "balancednics": { "id": "bal-1/balancednics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/bal-1/balancednics", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/bal-1/balancednics", "items": [ { "id": "68e3bd55-55a1-4fa0-8903-8c3cf23ee30a", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-2/servers/92445f57-5378-4a5b-8b53-f0f36fb8e6ad/nics/68e3bd55-55a1-4fa0-8903-8c3cf23ee30a", + "href": "/cloudapi/v4/datacenters/dc-2/servers/92445f57-5378-4a5b-8b53-f0f36fb8e6ad/nics/68e3bd55-55a1-4fa0-8903-8c3cf23ee30a", "metadata": { "createdDate": "2016-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -53,7 +53,7 @@ "firewallrules": { "id": "68e3bd55-55a1-4fa0-8903-8c3cf23ee30a/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/servers/92445f57-5378-4a5b-8b53-f0f36fb8e6ad/nics/68e3bd55-55a1-4fa0-8903-8c3cf23ee30a/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-2/servers/92445f57-5378-4a5b-8b53-f0f36fb8e6ad/nics/68e3bd55-55a1-4fa0-8903-8c3cf23ee30a/firewallrules" } } } @@ -64,7 +64,7 @@ { "id": "24d24a20-1161-4870-8b49-434622a18875", "type": "loadbalancer", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/24d24a20-1161-4870-8b49-434622a18875", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/24d24a20-1161-4870-8b49-434622a18875", "metadata": { "createdDate": "2016-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -82,12 +82,12 @@ "balancednics": { "id": "24d24a20-1161-4870-8b49-434622a18875/balancednics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/loadbalancers/24d24a20-1161-4870-8b49-434622a18875/balancednics", + "href": "/cloudapi/v4/datacenters/dc-2/loadbalancers/24d24a20-1161-4870-8b49-434622a18875/balancednics", "items": [ { "id": "0485e083-3461-447a-8c5a-392be3c76473", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-2/servers/7571b2d9-312a-45be-8d68-58c269c3911c/nics/0485e083-3461-447a-8c5a-392be3c76473", + "href": "/cloudapi/v4/datacenters/dc-2/servers/7571b2d9-312a-45be-8d68-58c269c3911c/nics/0485e083-3461-447a-8c5a-392be3c76473", "metadata": { "createdDate": "2016-10-25T08:49:48Z", "createdBy": "test@test.te", @@ -111,14 +111,14 @@ "firewallrules": { "id": "0485e083-3461-447a-8c5a-392be3c76473/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/servers/7571b2d9-312a-45be-8d68-58c269c3911c/nics/0485e083-3461-447a-8c5a-392be3c76473/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-2/servers/7571b2d9-312a-45be-8d68-58c269c3911c/nics/0485e083-3461-447a-8c5a-392be3c76473/firewallrules" } } }, { "id": "2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-2/servers/ff3b523c-21bd-453d-80a3-c2bcdae1f509/nics/2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68", + "href": "/cloudapi/v4/datacenters/dc-2/servers/ff3b523c-21bd-453d-80a3-c2bcdae1f509/nics/2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68", "metadata": { "createdDate": "2016-10-25T14:01:03Z", "createdBy": "test@test.te", @@ -142,14 +142,14 @@ "firewallrules": { "id": "2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/servers/ff3b523c-21bd-453d-80a3-c2bcdae1f509/nics/2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-2/servers/ff3b523c-21bd-453d-80a3-c2bcdae1f509/nics/2e9c54f4-85c0-4d10-8369-cf5e3a6e7b68/firewallrules" } } }, { "id": "707d7aa4-8311-4a61-82a4-a80333e9ecc2", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-2/servers/2e77a9cc-2338-43e6-84bf-e4c2ff9be265/nics/707d7aa4-8311-4a61-82a4-a80333e9ecc2", + "href": "/cloudapi/v4/datacenters/dc-2/servers/2e77a9cc-2338-43e6-84bf-e4c2ff9be265/nics/707d7aa4-8311-4a61-82a4-a80333e9ecc2", "metadata": { "createdDate": "2016-10-25T15:36:06Z", "createdBy": "test@test.te", @@ -173,14 +173,14 @@ "firewallrules": { "id": "707d7aa4-8311-4a61-82a4-a80333e9ecc2/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/servers/2e77a9cc-2338-43e6-84bf-e4c2ff9be265/nics/707d7aa4-8311-4a61-82a4-a80333e9ecc2/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-2/servers/2e77a9cc-2338-43e6-84bf-e4c2ff9be265/nics/707d7aa4-8311-4a61-82a4-a80333e9ecc2/firewallrules" } } }, { "id": "710f6842-440d-4fdc-878e-0c329037d4a9", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-2/servers/fc0f7e86-a7de-4cee-84b5-409cc8b89ad2/nics/710f6842-440d-4fdc-878e-0c329037d4a9", + "href": "/cloudapi/v4/datacenters/dc-2/servers/fc0f7e86-a7de-4cee-84b5-409cc8b89ad2/nics/710f6842-440d-4fdc-878e-0c329037d4a9", "metadata": { "createdDate": "2016-10-25T14:01:03Z", "createdBy": "test@test.te", @@ -204,7 +204,7 @@ "firewallrules": { "id": "710f6842-440d-4fdc-878e-0c329037d4a9/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-2/servers/fc0f7e86-a7de-4cee-84b5-409cc8b89ad2/nics/710f6842-440d-4fdc-878e-0c329037d4a9/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-2/servers/fc0f7e86-a7de-4cee-84b5-409cc8b89ad2/nics/710f6842-440d-4fdc-878e-0c329037d4a9/firewallrules" } } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_list_network_interfaces.json b/libcloud/test/compute/fixtures/profitbricks/ex_list_network_interfaces.json index bdd7ec31bf..d1831113a3 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_list_network_interfaces.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_list_network_interfaces.json @@ -1,12 +1,12 @@ { "id": "s-3/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics", "items": [ { "id": "nic-1", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1", "metadata": { "createdDate": "2016-10-17T15:46:38Z", "createdBy": "test@test.te", @@ -16,7 +16,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test network interface", + "name": "libcloud Test", "mac": "02:01:0b:9d:4d:ce", "ips": [ "10.15.124.11" @@ -30,14 +30,14 @@ "firewallrules": { "id": "nic-1/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" } } }, { "id": "8f7ea845-cf40-49c8-9e93-68366f31d605", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/8f7ea845-cf40-49c8-9e93-68366f31d605", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/8f7ea845-cf40-49c8-9e93-68366f31d605", "metadata": { "createdDate": "2016-10-17T16:46:38Z", "createdBy": "test@test.te", @@ -47,7 +47,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Another test network interface", + "name": "libcloud Test", "mac": "02:01:0b:9d:4d:dd", "ips": [ "10.15.124.12" @@ -61,7 +61,7 @@ "firewallrules": { "id": "8f7ea845-cf40-49c8-9e93-68366f31d605/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" } } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_rename_datacenter.json b/libcloud/test/compute/fixtures/profitbricks/ex_rename_datacenter.json index bfb2d5bb9e..75d625e35c 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_rename_datacenter.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_rename_datacenter.json @@ -1,7 +1,7 @@ { "id": "dc-1", "type": "datacenter", - "href": "/cloudapi/v3/datacenters/dc-1", + "href": "/cloudapi/v4/datacenters/dc-1", "metadata" : { "createdDate": "2016-10-17T11:33:11Z", "createdBy": "test@test.test", @@ -11,9 +11,9 @@ "state" : "BUSY" }, "properties" : { - "name": "Test Data Center", - "description": "This is a test data center.", - "location": "de/fkb", + "name": "libcloud Test - RENAME", + "description": "libcloud test datacenter", + "location": "us/las", "version": 35, "features": [ "SSD", @@ -24,23 +24,23 @@ "servers" : { "id": "dc-1/servers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers" + "href": "/cloudapi/v4/datacenters/dc-1/servers" }, "volumes" : { "id": "dc-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/volumes" + "href": "/cloudapi/v4/datacenters/dc-1/volumes" }, "loadbalancers" : { "id": "dc-1/loadbalancers", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/loadbalancers", + "href": "/cloudapi/v4/datacenters/dc-1/loadbalancers", "items": [] }, "lans" : { "id": "dc-1/lans", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans" + "href": "/cloudapi/v4/datacenters/dc-1/lans" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_set_inet_access.json b/libcloud/test/compute/fixtures/profitbricks/ex_set_inet_access.json deleted file mode 100644 index badfd0a7ca..0000000000 --- a/libcloud/test/compute/fixtures/profitbricks/ex_set_inet_access.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "id": "nic-2", - "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2", - "metadata": { - "createdDate": "2016-10-19T08:18:55Z", - "createdBy": "test@test.te", - "etag": "56f8d8bbdc84faad4188f647a49a565b", - "lastModifiedDate": "2016-10-19T09:44:59Z", - "lastModifiedBy": "test@test.te", - "state": "BUSY" - }, - "properties": { - "name": "Updated from LibCloud", - "mac": "02:01:68:c1:e8:88", - "ips": [ - "11.12.13.14" - ], - "dhcp": true, - "lan": 1, - "firewallActive": false, - "nat": false - }, - "entities": { - "firewallrules": { - "id": "nic-2/firewallrules", - "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules" - } - } -} \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_firewall_rule.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_firewall_rule.json index f6d13ef138..4deeaa294f 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_firewall_rule.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_firewall_rule.json @@ -1,7 +1,7 @@ { "id": "fw2", "type": "firewall-rule", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules/fw2", "metadata": { "createdDate": "2016-10-19T09:55:10Z", "createdBy": "test@test.te", @@ -11,15 +11,15 @@ "state": "BUSY" }, "properties": { - "name": "HTTPs (SSL)", + "name": "SSH - RENAME", "protocol": "TCP", - "sourceMac": null, + "sourceMac": "01:23:45:67:89:00", "sourceIp": null, "targetIp": null, "icmpCode": null, "icmpType": null, - "portRangeStart": 443, - "portRangeEnd": 443 + "portRangeStart": 22, + "portRangeEnd": 22 } } diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_image.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_image.json index 32db4ce065..38eda31c95 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_image.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_image.json @@ -1,7 +1,7 @@ { "id": "img-2", "type": "image", - "href": "/cloudapi/v3/images/img-2", + "href": "/cloudapi/v4/images/img-2", "metadata": { "createdDate": "2015-10-09T12:06:34Z", "createdBy": "test@test.te", @@ -13,7 +13,7 @@ "properties": { "name": "my-updated-image.img", "description": null, - "location": "de/fkb", + "location": "us/las", "size": 2, "cpuHotPlug": false, "cpuHotUnplug": false, @@ -27,6 +27,7 @@ "discScsiHotUnplug": false, "licenceType": "UNKNOWN", "imageType": "HDD", + "imageAliases": [ ], "public": false } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_lan.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_lan.json index 27b841dd46..eb8421bd8e 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_lan.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_lan.json @@ -1,7 +1,7 @@ { "id" : "10", "type" : "lan", - "href" : "/cloudapi/v3/datacenters/dc-1/lans/10", + "href" : "/cloudapi/v4/datacenters/dc-1/lans/10", "metadata" : { "createdDate": "2016-10-17T11:33:11Z", "createdBy": "test@test.te", @@ -11,14 +11,14 @@ "state": "BUSY" }, "properties" : { - "name" : "Test Updated Lan", - "public" : true + "name" : "libcloud Test - RENAME", + "public" : false }, "entities": { "nics": { "id": "10/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/lans/10/nics" + "href": "/cloudapi/v4/datacenters/dc-1/lans/10/nics" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_load_balancer.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_load_balancer.json index 0705e68ad2..c4b4a24d63 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_load_balancer.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_load_balancer.json @@ -1,7 +1,7 @@ { "id": "bal-1", "type": "loadbalancer", - "href": "/cloudapi/v3/datacenters/dc-1/loadbalancers/bal-1", + "href": "/cloudapi/v4/datacenters/dc-1/loadbalancers/bal-1", "metadata": { "createdDate": "2019-10-26T13:02:33Z", "createdBy": "test@test.te", @@ -11,8 +11,8 @@ "state": "BUSY" }, "properties": { - "name": "Updated Load Balancer", + "name": "libcloud Test - RENAME", "ip": "123.124.125.126", - "dhcp": false + "dhcp": true } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_network_interface.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_network_interface.json index d0fb8800c7..12f0d57032 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_network_interface.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_network_interface.json @@ -1,31 +1,31 @@ { - "id": "nic-1", + "id": "nic-2", "type": "nic", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2", "metadata": { - "createdDate": "2016-10-17T15:46:38Z", + "createdDate": "2016-10-19T08:18:55Z", "createdBy": "test@test.te", - "etag": "23dd052b608b59be38cef62765af7039", - "lastModifiedDate": "2016-10-19T09:29:00Z", + "etag": "56f8d8bbdc84faad4188f647a49a565b", + "lastModifiedDate": "2016-10-19T09:44:59Z", "lastModifiedBy": "test@test.te", "state": "BUSY" }, "properties": { - "name": "Updated from LibCloud", - "mac": "02:01:0b:9d:4d:ce", + "name": "libcloud Test - RENAME", + "mac": "02:01:68:c1:e8:88", "ips": [ - "10.15.124.11" + "11.12.13.14" ], "dhcp": true, "lan": 1, - "firewallActive": true, + "firewallActive": false, "nat": false }, "entities": { "firewallrules": { - "id": "nic-1/firewallrules", + "id": "nic-2/firewallrules", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/s-3/nics/nic-1/firewallrules" + "href": "/cloudapi/v4/datacenters/dc-1/servers/s-3/nics/nic-2/firewallrules" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_node.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_node.json index 6df459db0e..76c189abf0 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_node.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_node.json @@ -1,7 +1,7 @@ { "id": "srv-1", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1", "metadata" : { "createdDate": "2016-10-18T07:28:05Z", "createdBy": "test@test.test", @@ -11,17 +11,17 @@ "state" : "BUSY" }, "properties" : { - "name" : "A test node", + "name" : "libcloud Test RENAME", "cores" : 1, - "ram" : 512, + "ram" : 1024, "bootCdrom" : null, - "availabilityZone": "AUTO", + "availabilityZone": "ZONE_1", "vmState": "RUNNING", "bootCdrom": null, "bootVolume": { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1" }, "cpuFamily" : "AMD_OPTERON" }, @@ -29,17 +29,17 @@ "cdroms": { "id": "srv-1/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/cdroms" + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/cdroms" }, "volumes": { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes" + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes" }, "nics": { "id": "srv-1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics" + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics" } } } \ No newline at end of file diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_snapshot.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_snapshot.json index f37024ebfd..829825a447 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_snapshot.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_snapshot.json @@ -1,7 +1,7 @@ { "id": "sshot", "type": "snapshot", - "href": "/cloudapi/v3/snapshots/sshot", + "href": "/cloudapi/v4/snapshots/sshot", "metadata": { "createdDate": "2016-10-26T11:38:45Z", "createdBy": "test@test.te", @@ -11,8 +11,8 @@ "state": "AVAILABLE" }, "properties": { - "name": "Updated snapshot", - "description": "Updated snapshot", + "name": "libcloud Test - RENAME", + "description": "libcloud test snapshot - RENAME", "location": "us/las", "size": 10, "cpuHotPlug": true, diff --git a/libcloud/test/compute/fixtures/profitbricks/ex_update_volume.json b/libcloud/test/compute/fixtures/profitbricks/ex_update_volume.json index d0eab6af68..19753b1a32 100644 --- a/libcloud/test/compute/fixtures/profitbricks/ex_update_volume.json +++ b/libcloud/test/compute/fixtures/profitbricks/ex_update_volume.json @@ -1,7 +1,7 @@ { "id": "vol-2", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/vol-2", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/vol-2", "metadata": { "createdDate": "2016-10-17T13:13:36Z", "createdBy": "test@test.te", @@ -11,15 +11,15 @@ "state": "AVAILABLE" }, "properties": { - "name": "Updated storage name", + "name": "libcloud Test - RENAME", "type": "HDD", - "size": 40, - "availabilityZone": "AUTO", + "size": 5, + "availabilityZone": "ZONE_3", "image": "bvol-img", "imagePassword": null, "sshKeys": null, "bus": "VIRTIO", - "licenceType": "LINUX", + "licenceType": "UNKNOWN", "cpuHotPlug": true, "cpuHotUnplug": false, "ramHotPlug": true, diff --git a/libcloud/test/compute/fixtures/profitbricks/list_images.json b/libcloud/test/compute/fixtures/profitbricks/list_images.json index f7d718cf2b..997beed8ef 100644 --- a/libcloud/test/compute/fixtures/profitbricks/list_images.json +++ b/libcloud/test/compute/fixtures/profitbricks/list_images.json @@ -1,12 +1,12 @@ { "id": "images", "type": "collection", - "href": "/cloudapi/v3/images", + "href": "/cloudapi/v4/images", "items": [ { "id": "img-2", "type": "image", - "href": "/cloudapi/v3/images/img-2", + "href": "/cloudapi/v4/images/img-2", "metadata": { "createdDate": "2016-06-02T11:33:49Z", "createdBy": "System", @@ -32,13 +32,14 @@ "discScsiHotUnplug": false, "licenceType": "LINUX", "imageType": "CDROM", + "imageAliases": [ ], "public": false } }, { "id": "img-1", "type": "image", - "href": "/cloudapi/v3/images/img-1", + "href": "/cloudapi/v4/images/img-1", "metadata": { "createdDate": "2014-11-14T15:22:19Z", "createdBy": "System", @@ -64,13 +65,14 @@ "discScsiHotUnplug": false, "licenceType": "OTHER", "imageType": "CDROM", + "imageAliases": [ ], "public": true } }, { "id": "62c525d9-b2cf-11e5-afa0-52540066fee9", "type": "image", - "href": "/cloudapi/v3/images/62c525d9-b2cf-11e5-afa0-52540066fee9", + "href": "/cloudapi/v4/images/62c525d9-b2cf-11e5-afa0-52540066fee9", "metadata": { "createdDate": "2016-01-04T10:39:08Z", "createdBy": "System", @@ -82,7 +84,7 @@ "properties": { "name": "Test-Image-Three-CDROM", "description": "", - "location": "de/fkb", + "location": "us/las", "size": 0.37, "cpuHotPlug": true, "cpuHotUnplug": false, @@ -96,13 +98,14 @@ "discScsiHotUnplug": false, "licenceType": "LINUX", "imageType": "CDROM", + "imageAliases": [ ], "public": true } }, { "id": "e2c323ba-3c6d-11e6-9336-52540005ab80", "type": "image", - "href": "/cloudapi/v3/images/e2c323ba-3c6d-11e6-9336-52540005ab80", + "href": "/cloudapi/v4/images/e2c323ba-3c6d-11e6-9336-52540005ab80", "metadata": { "createdDate": "2016-06-27T13:48:53Z", "createdBy": "System", @@ -114,7 +117,7 @@ "properties": { "name": "Test-Image-Four-HDD", "description": "", - "location": "de/fkb", + "location": "us/las", "size": 0.28, "cpuHotPlug": false, "cpuHotUnplug": false, @@ -128,13 +131,14 @@ "discScsiHotUnplug": false, "licenceType": "OTHER", "imageType": "HDD", + "imageAliases": [ ], "public": false } }, { "id": "f1d2be4a-7937-11e4-8053-52540066fee9", "type": "image", - "href": "/cloudapi/v3/images/f1d2be4a-7937-11e4-8053-52540066fee9", + "href": "/cloudapi/v4/images/f1d2be4a-7937-11e4-8053-52540066fee9", "metadata": { "createdDate": "2014-12-01T08:56:31Z", "createdBy": "System", @@ -146,7 +150,7 @@ "properties": { "name": "Test-Image-Two-HDD", "description": "", - "location": "de/fkb", + "location": "us/las", "size": 0.45, "cpuHotPlug": false, "cpuHotUnplug": false, @@ -160,13 +164,14 @@ "discScsiHotUnplug": false, "licenceType": "LINUX", "imageType": "HDD", + "imageAliases": [ ], "public": true } }, { "id": "dfa08a48-7937-11e4-8053-52540066fee9", "type": "image", - "href": "/cloudapi/v3/images/dfa08a48-7937-11e4-8053-52540066fee9", + "href": "/cloudapi/v4/images/dfa08a48-7937-11e4-8053-52540066fee9", "metadata": { "createdDate": "2014-12-01T08:56:00Z", "createdBy": "System", @@ -192,6 +197,7 @@ "discScsiHotUnplug": false, "licenceType": "LINUX", "imageType": "HDD", + "imageAliases": [ ], "public": true } } diff --git a/libcloud/test/compute/fixtures/profitbricks/list_locations.json b/libcloud/test/compute/fixtures/profitbricks/list_locations.json index 7694c22641..0e1fddea46 100644 --- a/libcloud/test/compute/fixtures/profitbricks/list_locations.json +++ b/libcloud/test/compute/fixtures/profitbricks/list_locations.json @@ -1,43 +1,42 @@ { - "id": "locations", - "type": "collection", - "href": "/cloudapi/v3/locations", - "items": [ - { - "id": "de/fkb", - "type": "location", - "href": "/cloudapi/v3/locations/de/fkb", - "properties": { - "name": "karlsruhe", - "features": [ - "SSD", - "MULTIPLE_CPU" - ] - } - }, - { - "id": "de/fra", - "type": "location", - "href": "/cloudapi/v3/locations/de/fra", - "properties": { - "name": "frankfurt", - "features": [ - "SSD", - "MULTIPLE_CPU" - ] - } - }, - { - "id": "us/las", - "type": "location", - "href": "/cloudapi/v3/locations/us/las", - "properties": { - "name": "lasvegas", - "features": [ - "SSD", - "MULTIPLE_CPU" - ] - } - } - ] -} \ No newline at end of file + "id" : "locations", + "type" : "collection", + "href" : "https://api.profitbricks.com/cloudapi/v4/locations", + "items" : [ { + "id" : "us/las", + "type" : "location", + "href" : "https://api.profitbricks.com/cloudapi/v4/locations/de/fkb", + "properties" : { + "name" : "karlsruhe", + "features" : [ "SSD", "MULTIPLE_CPU" ], + "imageAliases" : [ "centos:6_iso", "opensuse:latest", "opensuse:42.3_iso", "centos:7_iso", "clearos:latest_iso", "debian:8_iso", "clonezilla:latest_iso", "windows:latest", "centos:7", "debian:7", "fedora:25_iso", "gparted:latest_iso", "grml:latest_iso", "opensuse:13.2_iso", "opensuse:42.1_iso", "opensuse:42.2_iso", "ubuntu:14.04_iso", "ubuntu:16.04_iso", "ubuntu:17.04_iso", "zenloadbalancer:latest_iso", "mssql:2012_trial_iso", "windows:virtiodriver_iso", "windows:2008r2_iso", "windows:2012r2_iso", "windows:2013_recovery_iso", "windows:2016_iso", "windows:2008r2", "windows:2012r2", "centos:6", "debian:9", "debian:latest", "ubuntu:16.04", "windows:2016", "centos:latest", "debian:8", "debian:testing", "fedora:25", "fedora:latest", "ubuntu:14.04", "ubuntu:latest", "debian:9_iso", "fedora:26_iso", "opensuse:13.2" ] + } + }, { + "id" : "de/fra", + "type" : "location", + "href" : "https://api.profitbricks.com/cloudapi/v4/locations/de/fra", + "properties" : { + "name" : "frankfurt", + "features" : [ "SSD", "MULTIPLE_CPU" ], + "imageAliases" : [ "centos:6_iso", "opensuse:42.3_iso", "windows:2012r2", "centos:7_iso", "clearos:latest_iso", "windows:latest", "clonezilla:latest_iso", "debian:7", "debian:9", "fedora:25_iso", "gparted:latest_iso", "grml:latest_iso", "opensuse:13.2_iso", "ubuntu:16.04", "opensuse:42.1_iso", "opensuse:42.2_iso", "windows:2016", "ubuntu:14.04_iso", "ubuntu:16.04_iso", "ubuntu:17.04_iso", "zenloadbalancer:latest_iso", "mssql:2012_trial_iso", "windows:virtiodriver_iso", "windows:2008r2_iso", "windows:2012r2_iso", "windows:2013_recovery_iso", "windows:2016_iso", "centos:6", "debian:latest", "fedora:latest", "ubuntu:14.04", "windows:2008r2", "centos:7", "centos:latest", "debian:8", "debian:testing", "fedora:25", "ubuntu:latest", "debian:8_iso", "debian:9_iso", "fedora:26_iso", "opensuse:13.2", "opensuse:latest" ] + } + }, { + "id" : "us/las", + "type" : "location", + "href" : "https://api.profitbricks.com/cloudapi/v4/locations/us/las", + "properties" : { + "name" : "lasvegas", + "features" : [ "SSD", "MULTIPLE_CPU" ], + "imageAliases" : [ "centos:6_iso", "opensuse:latest", "opensuse:42.3_iso", "windows:2016", "centos:7_iso", "clearos:latest_iso", "windows:latest", "clonezilla:latest_iso", "centos:7", "centos:latest", "debian:latest", "fedora:25_iso", "gparted:latest_iso", "grml:latest_iso", "opensuse:13.2_iso", "ubuntu:latest", "opensuse:42.1_iso", "opensuse:42.2_iso", "windows:2008r2", "opensuse:13.2", "ubuntu:14.04_iso", "ubuntu:16.04_iso", "ubuntu:17.04_iso", "zenloadbalancer:latest_iso", "mssql:2012_trial_iso", "windows:virtiodriver_iso", "windows:2008r2_iso", "windows:2012r2_iso", "windows:2013_recovery_iso", "windows:2016_iso", "debian:9", "debian:testing", "ubuntu:16.04", "windows:2012r2", "centos:6", "debian:7", "debian:8", "fedora:25", "fedora:latest", "ubuntu:14.04", "debian:8_iso", "debian:9_iso", "fedora:26_iso" ] + } + }, { + "id" : "us/ewr", + "type" : "location", + "href" : "https://api.profitbricks.com/cloudapi/v4/locations/us/ewr", + "properties" : { + "name" : "newark", + "features" : [ "SSD", "MULTIPLE_CPU" ], + "imageAliases" : [ "centos:6_iso", "opensuse:13.2", "opensuse:latest", "opensuse:42.3_iso", "windows:2008r2", "centos:7_iso", "clearos:latest_iso", "debian:9_iso", "fedora:26_iso", "clonezilla:latest_iso", "windows:2012r2", "windows:2016", "windows:latest", "centos:6", "centos:7", "centos:latest", "debian:latest", "fedora:25_iso", "gparted:latest_iso", "grml:latest_iso", "opensuse:13.2_iso", "fedora:latest", "ubuntu:14.04", "ubuntu:16.04", "opensuse:42.1_iso", "opensuse:42.2_iso", "ubuntu:14.04_iso", "ubuntu:16.04_iso", "ubuntu:17.04_iso", "zenloadbalancer:latest_iso", "mssql:2012_trial_iso", "windows:virtiodriver_iso", "windows:2008r2_iso", "windows:2012r2_iso", "windows:2013_recovery_iso", "windows:2016_iso", "debian:testing", "fedora:25", "debian:7", "debian:8", "debian:9", "ubuntu:latest", "debian:8_iso" ] + } + } ] +} diff --git a/libcloud/test/compute/fixtures/profitbricks/list_nodes.json b/libcloud/test/compute/fixtures/profitbricks/list_nodes.json index 1f30a8c29b..553b2f50ad 100644 --- a/libcloud/test/compute/fixtures/profitbricks/list_nodes.json +++ b/libcloud/test/compute/fixtures/profitbricks/list_nodes.json @@ -1,12 +1,12 @@ { "id": "dc-1/servers", "type": "collection", - "href": "/cloudapi/v3/datacenters/9e9cb896-e8e7-4f52-a808-ac808baac814/servers", + "href": "/cloudapi/v4/datacenters/9e9cb896-e8e7-4f52-a808-ac808baac814/servers", "items": [ { "id": "srv-1", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1", "metadata": { "createdDate": "2016-10-18T07:28:05Z", "createdBy": "test@test.te", @@ -16,16 +16,16 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Node.", - "cores": 2, - "ram": 4096, + "name": "libcloud Test", + "cores": 1, + "ram": 1024, "availabilityZone": "AUTO", "vmState": "RUNNING", "bootCdrom": null, "bootVolume": { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "matfin@stackpointcloud.com", @@ -35,9 +35,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Node Volume", + "name": "libcloud Test", "type": "HDD", - "size": 10, + "size": 2, "image": "bvol-img", "imagePassword": null, "bus": "VIRTIO", @@ -61,25 +61,25 @@ "cdroms": { "id": "srv-1/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/cdroms", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/cdroms", "items": [] }, "volumes": { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes", "items": [ { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1" } ] }, "nics": { "id": "srv-1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics", "items": [] } } @@ -87,7 +87,7 @@ { "id": "srv-1", "type": "server", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1", "metadata": { "createdDate": "2016-10-18T07:28:05Z", "createdBy": "test@test.te", @@ -97,16 +97,16 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Node.", - "cores": 2, - "ram": 4096, + "name": "libcloud Test", + "cores": 1, + "ram": 1024, "availabilityZone": "AUTO", "vmState": "RUNNING", "bootCdrom": null, "bootVolume": { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "matfin@stackpointcloud.com", @@ -116,9 +116,9 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Node Volume", + "name": "libcloud Test", "type": "HDD", - "size": 10, + "size": 2, "image": "bvol-img", "imagePassword": null, "bus": "VIRTIO", @@ -142,25 +142,25 @@ "cdroms": { "id": "srv-1/cdroms", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/cdroms", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/cdroms", "items": [] }, "volumes": { "id": "srv-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/volumes", "items": [ { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1" + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1" } ] }, "nics": { "id": "srv-1/nics", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/servers/srv-1/nics", + "href": "/cloudapi/v4/datacenters/dc-1/servers/srv-1/nics", "items": [] } } diff --git a/libcloud/test/compute/fixtures/profitbricks/list_snapshots.json b/libcloud/test/compute/fixtures/profitbricks/list_snapshots.json index 615dcb43c4..6902477bf4 100644 --- a/libcloud/test/compute/fixtures/profitbricks/list_snapshots.json +++ b/libcloud/test/compute/fixtures/profitbricks/list_snapshots.json @@ -1,12 +1,12 @@ { "id": "snapshots", "type": "collection", - "href": "/cloudapi/v3/snapshots", + "href": "/cloudapi/v4/snapshots", "items": [ { "id": "sshot", "type": "snapshot", - "href": "/cloudapi/v3/snapshots/sshot", + "href": "/cloudapi/v4/snapshots/sshot", "metadata": { "createdDate": "2016-10-26T11:38:45Z", "createdBy": "test@test.te", diff --git a/libcloud/test/compute/fixtures/profitbricks/list_volumes.json b/libcloud/test/compute/fixtures/profitbricks/list_volumes.json index 6111ca1080..7866ed86fa 100644 --- a/libcloud/test/compute/fixtures/profitbricks/list_volumes.json +++ b/libcloud/test/compute/fixtures/profitbricks/list_volumes.json @@ -1,12 +1,12 @@ { "id": "dc-1/volumes", "type": "collection", - "href": "/cloudapi/v3/datacenters/dc-1/volumes", + "href": "/cloudapi/v4/datacenters/dc-1/volumes", "items": [ { "id": "bvol-1", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/bvol-1", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/bvol-1", "metadata": { "createdDate": "2016-10-18T07:20:41Z", "createdBy": "test@test.test", @@ -16,7 +16,7 @@ "state": "AVAILABLE" }, "properties": { - "name": "Test Volume", + "name": "Test", "type": "HDD", "size": 10, "availabilityZone": "AUTO", @@ -41,7 +41,7 @@ { "id": "d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/d6688ced-700d-4c9c-a3a7-9f7170c5edc3", "metadata": { "createdDate": "2016-10-17T13:13:36Z", "createdBy": "test@test.test", @@ -76,7 +76,7 @@ { "id": "21d7e7de-5054-4041-b691-717aa8b3c799", "type": "volume", - "href": "/cloudapi/v3/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", + "href": "/cloudapi/v4/datacenters/dc-1/volumes/21d7e7de-5054-4041-b691-717aa8b3c799", "metadata": { "createdDate": "2016-10-17T11:33:20Z", "createdBy": "test@test.test", diff --git a/libcloud/test/compute/test_profitbricks.py b/libcloud/test/compute/test_profitbricks.py index 62c892bd1c..da79b26f99 100644 --- a/libcloud/test/compute/test_profitbricks.py +++ b/libcloud/test/compute/test_profitbricks.py @@ -14,15 +14,18 @@ # limitations under the License. import sys +from six import assertRegex from libcloud.utils.py3 import httplib from libcloud.test import MockHttp from libcloud.test.file_fixtures import ComputeFileFixtures from libcloud.compute.types import Provider from libcloud.compute.types import NodeState +from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey from libcloud.compute.providers import get_driver from libcloud.test import unittest from libcloud.test.secrets import PROFIT_BRICKS_PARAMS +from libcloud.common.exceptions import BaseHTTPError class ProfitBricksTests(unittest.TestCase): @@ -96,20 +99,21 @@ def test_list_images(self): self.assertEqual(extra['image_type'], 'CDROM') self.assertEqual(extra['public'], True) + self.assertIsInstance(extra['image_aliases'], list) def test_list_locations(self): locations = self.driver.list_locations() - self.assertEqual(len(locations), 3) + self.assertTrue(len(locations) > 0) ''' Standard properties ''' - location = locations[0] - self.assertEqual(location.id, 'de/fkb') - self.assertEqual(location.name, 'karlsruhe') - self.assertEqual(location.country, 'de') + location = locations[2] + self.assertEqual(location.id, 'us/las') + self.assertEqual(location.name, 'lasvegas') + self.assertEqual(location.country, 'us') def test_list_nodes(self): @@ -129,7 +133,7 @@ def test_list_nodes(self): ) self.assertEqual( node.name, - 'Test Node.' + 'libcloud Test' ) self.assertEqual( node.state, @@ -190,13 +194,13 @@ def test_list_nodes(self): self.assertEqual( extra['boot_volume']['href'], ( - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' '/volumes/bvol-1' ) ) self.assertEqual( extra['boot_volume']['properties']['name'], - 'Test Node Volume' + 'libcloud Test' ) self.assertEqual( extra['boot_volume']['properties']['type'], @@ -204,7 +208,7 @@ def test_list_nodes(self): ) self.assertEqual( extra['boot_volume']['properties']['size'], - 10 + 2 ) self.assertEqual( extra['boot_volume']['properties']['image'], @@ -239,152 +243,12 @@ def test_ex_list_availability_zones(self): def test_list_volumes(self): volumes = self.driver.list_volumes() - self.assertEqual(len(volumes), 3) - - volume = volumes[0] - extra = volume.extra - - ''' - Standard properties - ''' - self.assertEqual( - volume.id, - 'bvol-1' - ) - self.assertEqual( - volume.name, - 'Test Volume' - ) - self.assertEqual( - volume.size, - 10 - ) - - ''' - Extra - ''' - self.assertEqual( - extra['provisioning_state'], - NodeState.RUNNING) - - ''' - Extra metadata - ''' - self.assertEqual( - extra['created_by'], - 'test@test.test' - ) - self.assertEqual( - extra['created_date'], - '2016-10-18T07:20:41Z' - ) - self.assertEqual( - extra['etag'], - '33f6b8d506e7ad756e8554b915f29c61' - ) - self.assertEqual( - extra['last_modified_date'], - '2016-10-18T07:20:41Z' - ) - self.assertEqual( - extra['last_modified_by'], - 'test@test.test' - ) - self.assertEqual( - extra['state'], - 'AVAILABLE' - ) - - ''' - Extra properties - ''' - self.assertEqual( - extra['name'], - 'Test Volume' - ) - self.assertEqual( - extra['type'], - 'HDD' - ) - self.assertEqual( - extra['size'], - 10 - ) - self.assertEqual( - extra['availability_zone'], - 'AUTO' - ) - self.assertEqual( - extra['image'], - 'bvol-img' - ) - self.assertEqual( - extra['image_password'], - None - ) - self.assertEqual( - extra['ssh_keys'], - None - ) - self.assertEqual( - extra['bus'], - 'VIRTIO' - ) - self.assertEqual( - extra['licence_type'], - 'LINUX' - ) - self.assertEqual( - extra['cpu_hot_plug'], - True - ) - - self.assertEqual( - extra['cpu_hot_unplug'], - False - ) - self.assertEqual( - extra['ram_hot_plug'], - True - ) - self.assertEqual( - extra['ram_hot_unplug'], - False - ) - self.assertEqual( - extra['nic_hot_plug'], - True - ) - self.assertEqual( - extra['nic_hot_unplug'], - True - ) - - self.assertEqual( - extra['disc_virtio_hot_plug'], - True - ) - self.assertEqual( - extra['disc_virtio_hot_unplug'], - True - ) - self.assertEqual( - extra['disc_scsi_hot_plug'], - False - ) - self.assertEqual( - extra['disc_scsi_hot_unplug'], - False - ) - self.assertEqual( - extra['device_number'], - 1 - ) + self.assertTrue(len(volumes) > 0) def test_ex_list_datacenters(self): datacenters = self.driver.ex_list_datacenters() - self.assertEqual(len(datacenters), 1) + self.assertTrue(len(datacenters) > 0) datacenter = datacenters[0] extra = datacenter.extra @@ -398,11 +262,11 @@ def test_ex_list_datacenters(self): ) self.assertEqual( datacenter.href, - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' ) self.assertEqual( datacenter.name, - 'Test One.' + 'libcloud Test' ) self.assertEqual( datacenter.version, @@ -414,15 +278,15 @@ def test_ex_list_datacenters(self): ''' self.assertEqual( extra['name'], - 'Test One.' + 'libcloud Test' ) self.assertEqual( extra['description'], - 'A test data center' + 'libcloud test datacenter' ) self.assertEqual( extra['location'], - 'de/fra' + 'us/las' ) self.assertEqual( extra['version'], @@ -477,7 +341,7 @@ def test_ex_list_datacenters(self): def test_list_snapshots(self): volume_snapshots = self.driver.list_snapshots() - self.assertEqual(len(volume_snapshots), 1) + self.assertTrue(len(volume_snapshots) > 0) snapshot = volume_snapshots[0] @@ -606,7 +470,7 @@ def test_list_snapshots(self): def test_create_volume_snapshot(self): volume = self.driver.ex_describe_volume( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/vol-2' ) @@ -634,7 +498,7 @@ def test_create_volume_snapshot(self): ) self.assertEqual( snapshot.name, - 'Test Created Snapshot' + 'libcloud Test' ) ''' @@ -642,11 +506,11 @@ def test_create_volume_snapshot(self): ''' self.assertEqual( snapshot.extra['name'], - 'Test Created Snapshot' + 'libcloud Test' ) self.assertEqual( snapshot.extra['description'], - 'Test Created Snapshot' + 'libcloud test snapshot' ) self.assertEqual( snapshot.extra['location'], @@ -730,9 +594,14 @@ def test_create_volume_snapshot(self): 'BUSY' ) + def test_create_volume_snapshot_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no volume' + self.driver.create_volume_snapshot(volume=None) + def test_ex_describe_snapshot(self): snapshot_w_href = self.driver.ex_describe_snapshot( - ex_href='/cloudapi/v3/snapshots/sshot' + ex_href='/cloudapi/v4/snapshots/sshot' ) snapshot_w_id = self.driver.ex_describe_snapshot( ex_snapshot_id='sshot' @@ -740,6 +609,13 @@ def test_ex_describe_snapshot(self): self._verify_snapshot(snapshot=snapshot_w_href) self._verify_snapshot(snapshot=snapshot_w_id) + def test_ex_describe_snapshot_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_snapshot( + ex_snapshot_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_snapshot(self, snapshot): ''' Standard properties @@ -762,7 +638,7 @@ def _verify_snapshot(self, snapshot): ) self.assertEqual( snapshot.name, - 'Test Snapshot' + 'libcloud Test' ) ''' @@ -770,11 +646,11 @@ def _verify_snapshot(self, snapshot): ''' self.assertEqual( snapshot.extra['name'], - 'Test Snapshot' + 'libcloud Test' ) self.assertEqual( snapshot.extra['description'], - 'Test Snapshot' + 'libcloud test snapshot' ) self.assertEqual( snapshot.extra['location'], @@ -859,31 +735,40 @@ def _verify_snapshot(self, snapshot): def test_ex_update_snapshot(self): snapshot = self.driver.ex_describe_snapshot( - ex_href='/cloudapi/v3/snapshots/sshot' + ex_href='/cloudapi/v4/snapshots/sshot' ) updated = self.driver.ex_update_snapshot( snapshot=snapshot, - name='Updated snapshot', - description='Upated snapshot', - cpu_hot_unplug=True + name='libcloud Test - RENAME', + description='libcloud test snapshot - RENAME' ) self.assertEqual( updated.name, - 'Updated snapshot' + 'libcloud Test - RENAME' ) self.assertEqual( updated.extra['description'], - 'Updated snapshot' + 'libcloud test snapshot - RENAME' ) - self.assertEqual( - updated.extra['cpu_hot_unplug'], - True + + def test_restore_volume_snapshot(self): + volume = self.driver.ex_describe_volume( + ex_datacenter_id='dc-1', + ex_volume_id='vol-2' + ) + snapshot = self.driver.ex_describe_snapshot( + ex_snapshot_id='sshot' ) + restored = self.driver.ex_restore_volume_snapshot( + volume=volume, + snapshot=snapshot + ) + self.assertTrue(restored) def test_destroy_volume_snapshot(self): snapshot = self.driver.ex_describe_snapshot( - ex_href='/cloudapi/v3/snapshots/sshot' + ex_href='/cloudapi/v4/snapshots/sshot' ) destroyed = self.driver.destroy_volume_snapshot(snapshot) self.assertTrue(destroyed) @@ -895,7 +780,7 @@ def test_destroy_volume_snapshot(self): def test_reboot_node(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' '/servers/srv-1' ) ) @@ -904,55 +789,27 @@ def test_reboot_node(self): def test_create_node(self): image = self.driver.ex_describe_image( - ex_href='/cloudapi/v3/images/img-2' + ex_href='/cloudapi/v4/images/img-2' ) datacenter = self.driver.ex_describe_datacenter( - ex_href='/cloudapi/v3/datacenters/dc-1' + ex_href='/cloudapi/v4/datacenters/dc-1' ) - sizes = self.driver.list_sizes() - - with self.assertRaises(ValueError): - 'Raises value error if no size or ex_ram' - self.driver.create_node( - name='Test', - image=image, - ex_disk=40, - ex_cores=1 - ) - - with self.assertRaises(ValueError): - 'Raises value error if no size or ex_cores' - self.driver.create_node( - name='Test', - image=image, - ex_disk=40, - ex_ram=1024 - ) - - with self.assertRaises(ValueError): - 'Raises value error if no size or ex_disk' - self.driver.create_node( - name='Test', - image=image, - ex_cores=2, - ex_ram=1024 - ) - with self.assertRaises(ValueError): - 'Raises value error if no ssh keys or password' - self.driver.create_node( - name='Test', - image=image, - size=sizes[1], - datacenter=datacenter - ) + ssh_key = NodeAuthSSHKey('ssh-rsa AAAAB3NzaC1') + password = NodeAuthPassword('secretpassword1233') node = self.driver.create_node( - name='Test', + name='libcloud Test', image=image, - size=sizes[1], - ex_password='dummy1234', - datacenter=datacenter + ex_ram=1024, + ex_cores=1, + ex_disk=2, + ex_bus_type='VIRTIO', + ex_disk_type='HDD', + ex_cpu_family='INTEL_XEON', + ex_password=password, + ex_ssh_keys=[ssh_key], + ex_datacenter=datacenter ) extra = node.extra @@ -966,7 +823,7 @@ def test_create_node(self): ) self.assertEqual( node.name, - 'Test' + 'libcloud Test' ) self.assertEqual( node.state, @@ -1006,7 +863,7 @@ def test_create_node(self): ''' self.assertEqual( extra['name'], - 'Test' + 'libcloud Test' ) self.assertEqual( extra['cores'], @@ -1014,7 +871,7 @@ def test_create_node(self): ) self.assertEqual( extra['ram'], - 512 + 1024 ) self.assertEqual( extra['availability_zone'], @@ -1046,17 +903,61 @@ def test_create_node(self): 1 ) + def test_create_node_failure(self): + image = self.driver.ex_describe_image( + ex_href='/cloudapi/v4/images/img-2' + ) + datacenter = self.driver.ex_describe_datacenter( + ex_href='/cloudapi/v4/datacenters/dc-1' + ) + sizes = self.driver.list_sizes() + + with self.assertRaises(ValueError): + 'Raises value error if no size or ex_ram' + self.driver.create_node( + name='libcloud Test', + image=image, + ex_disk=40, + ex_cores=1 + ) + + with self.assertRaises(ValueError): + 'Raises value error if no size or ex_cores' + self.driver.create_node( + name='libcloud Test', + image=image, + ex_disk=40, + ex_ram=1024 + ) + + with self.assertRaises(ValueError): + 'Raises value error if no size or ex_disk' + self.driver.create_node( + name='libcloud Test', + image=image, + ex_cores=2, + ex_ram=1024 + ) + + with self.assertRaises(ValueError): + 'Raises value error if no ssh keys or password' + self.driver.create_node( + name='libcloud Test', + image=image, + size=sizes[1], + ex_datacenter=datacenter + ) + def test_destroy_node(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) ) destroyed = self.driver.destroy_node( - node=node, - ex_remove_attached_disks=False + node=node ) self.assertTrue(destroyed) @@ -1064,27 +965,27 @@ def test_ex_list_attached_volumes(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/servers/' 'srv-1' ) ) attached_volumes = self.driver.ex_list_attached_volumes(node) - self.assertEqual(len(attached_volumes), 3) + self.assertTrue(len(attached_volumes) > 0) def test_attach_volume(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) ) volume = self.driver.ex_describe_volume( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/vol-2' ) @@ -1102,11 +1003,11 @@ def test_attach_volume(self): ) self.assertEqual( attached.name, - 'Updated storage name' + 'libcloud Test' ) self.assertEqual( attached.size, - 40 + 2 ) ''' @@ -1142,7 +1043,7 @@ def test_attach_volume(self): ''' self.assertEqual( extra['name'], - 'Updated storage name' + 'libcloud Test' ) self.assertEqual( extra['type'], @@ -1150,7 +1051,7 @@ def test_attach_volume(self): ) self.assertEqual( extra['size'], - 40 + 2 ) self.assertEqual( extra['image'], @@ -1171,7 +1072,7 @@ def test_attach_volume(self): ) self.assertEqual( extra['licence_type'], - 'LINUX' + 'UNKNOWN' ) self.assertEqual( extra['cpu_hot_plug'], @@ -1217,7 +1118,7 @@ def test_attach_volume(self): ) self.assertEqual( extra['device_number'], - 3 + 2 ) self.assertNotIn( @@ -1229,14 +1130,14 @@ def test_detach_volume(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) ) volume = self.driver.ex_describe_volume( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/vol-2' ) @@ -1251,7 +1152,7 @@ def test_ex_stop_node(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) @@ -1262,7 +1163,7 @@ def test_ex_stop_node(self): def test_ex_start_node(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) @@ -1273,7 +1174,7 @@ def test_ex_start_node(self): def test_ex_describe_node(self): node_w_href = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) @@ -1285,6 +1186,15 @@ def test_ex_describe_node(self): self._verify_node(node=node_w_href) self._verify_node(node=node_w_id) + def test_ex_describe_node_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_node( + ex_datacenter_id='dc-1', + ex_node_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + + def _verify_node(self, node): extra = node.extra @@ -1297,7 +1207,7 @@ def _verify_node(self, node): ) self.assertEqual( node.name, - 'A test node' + 'libcloud Test' ) self.assertEqual( node.state, @@ -1344,7 +1254,7 @@ def _verify_node(self, node): ''' self.assertEqual( extra['availability_zone'], - 'AUTO' + 'ZONE_1' ) self.assertEqual( extra['boot_cdrom'], @@ -1357,14 +1267,14 @@ def _verify_node(self, node): self.assertEqual( extra['boot_volume']['href'], ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/bvol-1' ) ) self.assertEqual( extra['boot_volume']['properties']['name'], - 'A test node boot volume' + 'libcloud Test' ) self.assertEqual( @@ -1373,7 +1283,7 @@ def _verify_node(self, node): ) self.assertEqual( extra['boot_volume']['properties']['size'], - 10 + 2 ) self.assertEqual( extra['boot_volume']['properties']['image'], @@ -1400,101 +1310,23 @@ def test_ex_update_node(self): node = self.driver.ex_describe_node( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) ) - zones = self.driver.ex_list_availability_zones() updated = self.driver.ex_update_node( node=node, - name='Test update', - cores=4, - ram=4096, - availability_zone=zones[0], - ex_cpu_family='INTEL_XEON' + name='libcloud Test RENAME' ) - extra = updated.extra - - ''' - Standard properties - ''' self.assertEqual( updated.id, 'srv-1' ) self.assertEqual( updated.name, - 'A test node' - ) - self.assertEqual( - updated.state, - NodeState.RUNNING - ) - self.assertEqual( - updated.public_ips, - [] - ) - self.assertEqual( - updated.private_ips, - [] - ) - - ''' - Extra metadata - ''' - self.assertEqual( - extra['created_date'], - '2016-10-18T07:28:05Z' - ) - self.assertEqual( - extra['created_by'], - 'test@test.test' - ) - self.assertEqual( - extra['etag'], - 'e7cf186125f51f3d9511754a40dcd12c' - ) - self.assertEqual( - extra['last_modified_date'], - '2016-10-18T07:28:05Z' - ) - self.assertEqual( - extra['last_modified_by'], - 'test@test.test' - ) - self.assertEqual( - extra['state'], - 'BUSY' - ) - - ''' - Extra properties - ''' - self.assertEqual( - extra['availability_zone'], - 'AUTO' - ) - self.assertEqual( - extra['boot_cdrom'], - None - ) - self.assertEqual( - extra['boot_volume']['id'], - 'bvol-1' - ) - self.assertEqual( - extra['boot_volume']['href'], - ( - '/cloudapi/v3/datacenters/' - 'dc-1/' - 'volumes/bvol-1' - ) - ) - self.assertEqual( - extra['cpu_family'], - 'AMD_OPTERON' + 'libcloud Test RENAME' ) ''' @@ -1505,30 +1337,47 @@ def test_create_volume(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) image = self.driver.ex_describe_image( - ex_href='/cloudapi/v3/images/img-2' + ex_href='/cloudapi/v4/images/img-2' ) created = self.driver.create_volume( size=30, name='Test volume', ex_type='HDD', - ex_bus_type='IDE', ex_datacenter=datacenter, image=image, - ex_password='dummyP8ssw0rdl33t' + ex_ssh_keys=[NodeAuthSSHKey('ssh-rsa AAAAB3NzaC1')] ) self.assertTrue(created) + def test_create_volume_failure(self): + datacenter = self.driver.ex_describe_datacenter( + ex_href=( + '/cloudapi/v4/datacenters/' + 'dc-1' + ) + ) + with self.assertRaises(ValueError): + 'Raises value error if no size' + self.driver.create_volume( + size=30, + name='libcloud Test', + ex_type='HDD', + ex_bus_type='IDE', + ex_datacenter=datacenter, + image=None + ) + def test_destroy_volume(self): volume = self.driver.ex_describe_volume( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/volumes/' 'vol-2' ) @@ -1541,7 +1390,7 @@ def test_ex_update_volume(self): volume = self.driver.ex_describe_volume( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/vol-2' ) @@ -1565,11 +1414,11 @@ def test_ex_update_volume(self): ) self.assertEqual( updated.name, - 'Updated storage name' + 'libcloud Test - RENAME' ) self.assertEqual( updated.size, - 40 + 5 ) ''' @@ -1605,7 +1454,7 @@ def test_ex_update_volume(self): ''' self.assertEqual( extra['name'], - 'Updated storage name' + 'libcloud Test - RENAME' ) self.assertEqual( extra['type'], @@ -1613,11 +1462,11 @@ def test_ex_update_volume(self): ) self.assertEqual( extra['size'], - 40 + 5 ) self.assertEqual( extra['availability_zone'], - 'AUTO' + 'ZONE_3' ) self.assertEqual( extra['image'], @@ -1638,7 +1487,7 @@ def test_ex_update_volume(self): ) self.assertEqual( extra['licence_type'], - 'LINUX' + 'UNKNOWN' ) self.assertEqual( extra['cpu_hot_plug'], @@ -1692,7 +1541,7 @@ def test_ex_update_volume(self): def test_ex_describe_volume(self): volume_w_href = self.driver.ex_describe_volume( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'volumes/vol-2' ) @@ -1704,6 +1553,14 @@ def test_ex_describe_volume(self): self._verify_volume(volume=volume_w_href) self._verify_volume(volume=volume_w_id) + def test_ex_describe_volume_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_volume( + ex_datacenter_id='dc-1', + ex_volume_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_volume(self, volume): extra = volume.extra @@ -1716,11 +1573,11 @@ def _verify_volume(self, volume): ) self.assertEqual( volume.name, - 'Updated storage name' + 'libcloud Test' ) self.assertEqual( volume.size, - 40 + 2 ) ''' @@ -1756,7 +1613,7 @@ def _verify_volume(self, volume): ''' self.assertEqual( extra['name'], - 'Updated storage name' + 'libcloud Test' ) self.assertEqual( extra['type'], @@ -1764,11 +1621,11 @@ def _verify_volume(self, volume): ) self.assertEqual( extra['size'], - 40 + 2 ) self.assertEqual( extra['availability_zone'], - 'AUTO' + 'ZONE_3' ) self.assertEqual( extra['image'], @@ -1789,7 +1646,7 @@ def _verify_volume(self, volume): ) self.assertEqual( extra['licence_type'], - 'LINUX' + 'UNKNOWN' ) self.assertEqual( extra['cpu_hot_plug'], @@ -1848,11 +1705,11 @@ def _verify_volume(self, volume): ''' def test_ex_create_datacenter(self): - location = self.driver.ex_describe_location(ex_location_id='de/fkb') + location = self.driver.ex_describe_location(ex_location_id='us/las') datacenter = self.driver.ex_create_datacenter( - name='Test Data Center', + name='libcloud Test', location=location, - description='Test Data Center.' + description='libcloud test datacenter' ) extra = datacenter.extra @@ -1866,11 +1723,11 @@ def test_ex_create_datacenter(self): ) self.assertEqual( datacenter.href, - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' ) self.assertEqual( datacenter.name, - 'Test Data Center' + 'libcloud Test' ) self.assertEqual( datacenter.version, @@ -1910,11 +1767,11 @@ def test_ex_create_datacenter(self): ''' self.assertEqual( extra['name'], - 'Test Data Center' + 'libcloud Test' ) self.assertEqual( extra['description'], - 'Test Data Center.' + 'libcloud test datacenter' ) self.assertEqual( extra['location'], @@ -1941,11 +1798,20 @@ def test_ex_create_datacenter(self): NodeState.PENDING ) + def test_ex_create_datacenter_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no location' + self.driver.ex_create_datacenter( + name='libcloud Test', + location=None, + description='libcloud test datacenter' + ) + def test_ex_destroy_datacenter(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) @@ -1957,7 +1823,7 @@ def test_ex_destroy_datacenter(self): def test_ex_describe_datacenter(self): datacenter_w_href = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) @@ -1967,6 +1833,11 @@ def test_ex_describe_datacenter(self): self._verify_datacenter(datacenter=datacenter_w_href) self._verify_datacenter(datacenter=datacenter_w_id) + def test_ex_describe_datacenter_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_datacenter(ex_datacenter_id='00000000') + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_datacenter(self, datacenter): extra = datacenter.extra @@ -1979,11 +1850,11 @@ def _verify_datacenter(self, datacenter): ) self.assertEqual( datacenter.href, - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' ) self.assertEqual( datacenter.name, - 'Test Data Center' + 'libcloud Test' ) self.assertEqual( datacenter.version, @@ -2023,15 +1894,15 @@ def _verify_datacenter(self, datacenter): ''' self.assertEqual( extra['name'], - 'Test Data Center' + 'libcloud Test' ) self.assertEqual( extra['description'], - 'This is a test data center.' + 'libcloud test datacenter' ) self.assertEqual( extra['location'], - 'de/fkb' + 'us/las' ) self.assertEqual( extra['version'], @@ -2059,13 +1930,13 @@ def test_ex_rename_datacenter(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) renamed = self.driver.ex_rename_datacenter( datacenter=datacenter, - name='Renamed data center' + name='libcloud Test - RENAME' ) extra = renamed.extra @@ -2078,11 +1949,11 @@ def test_ex_rename_datacenter(self): ) self.assertEqual( renamed.href, - '/cloudapi/v3/datacenters/dc-1' + '/cloudapi/v4/datacenters/dc-1' ) self.assertEqual( renamed.name, - 'Test Data Center' + 'libcloud Test - RENAME' ) self.assertEqual( renamed.version, @@ -2122,15 +1993,15 @@ def test_ex_rename_datacenter(self): ''' self.assertEqual( extra['name'], - 'Test Data Center' + 'libcloud Test - RENAME' ) self.assertEqual( extra['description'], - 'This is a test data center.' + 'libcloud test datacenter' ) self.assertEqual( extra['location'], - 'de/fkb' + 'us/las' ) self.assertEqual( extra['version'], @@ -2160,7 +2031,7 @@ def test_ex_rename_datacenter(self): def test_ex_describe_image(self): image_w_href = self.driver.ex_describe_image( ex_href=( - '/cloudapi/v3/images/' + '/cloudapi/v4/images/' 'img-2' ) ) @@ -2170,6 +2041,11 @@ def test_ex_describe_image(self): self._verify_image(image=image_w_href) self._verify_image(image=image_w_id) + def test_ex_describe_image_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_image(ex_image_id='00000000') + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_image(self, image): extra = image.extra @@ -2226,7 +2102,7 @@ def _verify_image(self, image): ) self.assertEqual( extra['location'], - 'de/fkb' + 'us/las' ) self.assertEqual( extra['size'], @@ -2289,13 +2165,18 @@ def _verify_image(self, image): ) self.assertEqual( extra['href'], - '/cloudapi/v3/images/img-2' + '/cloudapi/v4/images/img-2' + ) + + self.assertIsInstance( + extra['image_aliases'], + list ) def test_ex_update_image(self): image = self.driver.ex_describe_image( ex_href=( - '/cloudapi/v3/images/' + '/cloudapi/v4/images/' 'img-2' ) ) @@ -2317,7 +2198,7 @@ def test_ex_update_image(self): def test_ex_delete_image(self): image = self.driver.ex_describe_image( ex_href=( - '/cloudapi/v3/images/' + '/cloudapi/v4/images/' 'img-2' ) ) @@ -2331,10 +2212,7 @@ def test_ex_delete_image(self): def test_ex_list_network_interfaces(self): network_interfaces = self.driver.ex_list_network_interfaces() - self.assertEqual( - len(network_interfaces), - 4 - ) + self.assertTrue(len(network_interfaces) > 0) network_interface = network_interfaces[0] extra = network_interface.extra @@ -2348,12 +2226,12 @@ def test_ex_list_network_interfaces(self): ) self.assertEqual( network_interface.name, - 'Test network interface' + 'libcloud Test' ) self.assertEqual( network_interface.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/servers/' 's-3/nics/' 'nic-1' @@ -2397,7 +2275,7 @@ def test_ex_list_network_interfaces(self): ''' self.assertEqual( extra['name'], - 'Test network interface' + 'libcloud Test' ) self.assertEqual( extra['mac'], @@ -2427,7 +2305,7 @@ def test_ex_list_network_interfaces(self): def test_ex_describe_network_interface(self): nic_w_href = self.driver.ex_describe_network_interface( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -2441,6 +2319,15 @@ def test_ex_describe_network_interface(self): self._verify_network_interface(network_interface=nic_w_href) self._verify_network_interface(network_interface=nic_w_id) + def test_ex_describe_network_interface_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_network_interface( + ex_datacenter_id='dc-1', + ex_server_id='s-3', + ex_nic_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_network_interface(self, network_interface): extra = network_interface.extra @@ -2453,12 +2340,12 @@ def _verify_network_interface(self, network_interface): ) self.assertEqual( network_interface.name, - 'Updated from LibCloud' + 'libcloud Test' ) self.assertEqual( network_interface.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' @@ -2502,7 +2389,7 @@ def _verify_network_interface(self, network_interface): ''' self.assertEqual( extra['name'], - 'Updated from LibCloud' + 'libcloud Test' ) self.assertEqual( extra['mac'], @@ -2514,7 +2401,7 @@ def _verify_network_interface(self, network_interface): ) self.assertEqual( extra['dhcp'], - False + True ) self.assertEqual( extra['lan'], @@ -2541,7 +2428,7 @@ def test_ex_create_network_interface(self): node = self.driver.ex_describe_node( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' ) @@ -2550,7 +2437,7 @@ def test_ex_create_network_interface(self): node=node, lan_id=1, dhcp_active=True, - nic_name='Creating a test network interface.' + nic_name='libcloud Test' ) extra = network_interface.extra @@ -2563,12 +2450,12 @@ def test_ex_create_network_interface(self): ) self.assertEqual( network_interface.name, - 'Creating a test network interface.' + 'libcloud Test' ) self.assertEqual( network_interface.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/srv-1' '/nics/nic-2' @@ -2612,7 +2499,7 @@ def test_ex_create_network_interface(self): ''' self.assertEqual( extra['name'], - 'Creating a test network interface.' + 'libcloud Test' ) self.assertEqual( extra['mac'], @@ -2620,7 +2507,7 @@ def test_ex_create_network_interface(self): ) self.assertEqual( extra['ips'], - [] + ['10.0.0.1'] ) self.assertEqual( extra['dhcp'], @@ -2639,11 +2526,20 @@ def test_ex_create_network_interface(self): None ) + def test_ex_create_network_interface_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no node' + self.driver.ex_create_network_interface( + node=None, + lan_id=1, + nic_name='libcloud Test' + ) + def test_ex_update_network_interface(self): network_interface = self.driver.ex_describe_network_interface( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -2651,7 +2547,7 @@ def test_ex_update_network_interface(self): ) updated = self.driver.ex_update_network_interface( network_interface=network_interface, - name='New network interface', dhcp_active=False + name='libcloud Test - RENAME' ) extra = updated.extra @@ -2665,89 +2561,31 @@ def test_ex_update_network_interface(self): ) self.assertEqual( updated.name, - 'Updated from LibCloud' + 'libcloud Test - RENAME' ) self.assertEqual( updated.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' ) ) - self.assertEqual( - updated.state, - NodeState.PENDING - ) - - ''' - Extra metadata - ''' - self.assertEqual( - extra['created_date'], - '2016-10-19T08:18:55Z' - ) - self.assertEqual( - extra['created_by'], - 'test@test.te' - ) - self.assertEqual( - extra['etag'], - '56f8d8bbdc84faad4188f647a49a565b' - ) - self.assertEqual( - extra['last_modified_date'], - '2016-10-19T09:44:59Z' - ) - self.assertEqual( - extra['last_modified_by'], - 'test@test.te' - ) - self.assertEqual( - extra['state'], - 'BUSY' - ) ''' Extra properties ''' self.assertEqual( extra['name'], - 'Updated from LibCloud' - ) - self.assertEqual( - extra['mac'], - '02:01:68:c1:e8:88' - ) - self.assertEqual( - extra['ips'], - ['11.12.13.14'] - ) - self.assertEqual( - extra['dhcp'], - True - ) - self.assertEqual( - extra['lan'], - 1 - ) - self.assertEqual( - extra['firewall_active'], - False - ) - self.assertEqual( - extra['nat'], - False + 'libcloud Test - RENAME' ) - self.assertTrue(updated) - def test_ex_destroy_network_interface(self): network_interface = self.driver.ex_describe_network_interface( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -2762,7 +2600,7 @@ def test_ex_destroy_network_interface(self): def test_ex_set_inet_access(self): network_interface = self.driver.ex_describe_network_interface( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -2783,27 +2621,32 @@ def test_ex_set_inet_access(self): def test_ex_describe_location(self): location_w_href = self.driver.ex_describe_location( ex_href=( - '/cloudapi/v3/locations/de/fkb' + '/cloudapi/v4/locations/us/las' ) ) location_w_id = self.driver.ex_describe_location( - ex_location_id='de/fkb' + ex_location_id='us/las' ) self._verify_location(location=location_w_href) self._verify_location(location=location_w_id) + def test_ex_describe_location_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_location(ex_location_id='us/000') + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_location(self, location): self.assertEqual( location.id, - 'de/fkb' + 'us/las' ) self.assertEqual( location.name, - 'karlsruhe' + 'lasvegas' ) self.assertEqual( location.country, - 'de' + 'us' ) ''' @@ -2813,16 +2656,15 @@ def _verify_location(self, location): def test_ex_list_firewall_rules(self): network_interface = self.driver.ex_describe_network_interface( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' ) ) firewall_rules = self.driver.ex_list_firewall_rules(network_interface) - self.assertEqual( - len(firewall_rules), - 3 + self.assertTrue( + len(firewall_rules) > 0 ) firewall_rule = firewall_rules[0] @@ -2842,7 +2684,7 @@ def test_ex_list_firewall_rules(self): self.assertEqual( firewall_rule.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2/' @@ -2926,7 +2768,7 @@ def test_ex_list_firewall_rules(self): def test_ex_describe_firewall_rule(self): firewall_rule_w_href = self.driver.ex_describe_firewall_rule( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/servers/' 's-3/nics/' 'nic-2/firewallrules' @@ -2942,6 +2784,16 @@ def test_ex_describe_firewall_rule(self): self._verify_firewall_rule(firewall_rule=firewall_rule_w_href) self._verify_firewall_rule(firewall_rule=firewall_rule_w_id) + def test_ex_describe_firewall_rule_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_firewall_rule( + ex_datacenter_id='dc-1', + ex_server_id='s-3', + ex_nic_id='nic-2', + ex_firewall_rule_id='00' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_firewall_rule(self, firewall_rule): extra = firewall_rule.extra @@ -2954,12 +2806,12 @@ def _verify_firewall_rule(self, firewall_rule): ) self.assertEqual( firewall_rule.name, - 'HTTPs (SSL)' + 'SSH' ) self.assertEqual( firewall_rule.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/servers/' 's-3/nics/' 'nic-2/' @@ -3004,7 +2856,7 @@ def _verify_firewall_rule(self, firewall_rule): ''' self.assertEqual( extra['name'], - 'HTTPs (SSL)' + 'SSH' ) self.assertEqual( extra['protocol'], @@ -3012,7 +2864,7 @@ def _verify_firewall_rule(self, firewall_rule): ) self.assertEqual( extra['source_mac'], - None + '01:23:45:67:89:00' ) self.assertEqual( extra['source_ip'], @@ -3033,18 +2885,18 @@ def _verify_firewall_rule(self, firewall_rule): ) self.assertEqual( extra['port_range_start'], - 443 + 22 ) self.assertEqual( extra['port_range_end'], - 443 + 22 ) def test_ex_create_firewall_rule(self): network_interface = self.driver.ex_describe_network_interface( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' @@ -3054,9 +2906,9 @@ def test_ex_create_firewall_rule(self): firewall_rule = self.driver.ex_create_firewall_rule( network_interface=network_interface, protocol='TCP', - name='Test created firewall rule', - port_range_start=80, - port_range_end=80 + name='SSH', + port_range_start=22, + port_range_end=22 ) extra = firewall_rule.extra @@ -3070,135 +2922,20 @@ def test_ex_create_firewall_rule(self): ) self.assertEqual( firewall_rule.name, - 'Test created firewall rule' - ) - self.assertEqual( - firewall_rule.href, - ( - '/cloudapi/v3/datacenters/' - 'dc-1/' - 'servers/s-3/' - 'nics/nic-2/' - 'firewallrules/fwr-1' - ) - ) - self.assertEqual( - firewall_rule.state, - NodeState.PENDING - ) - - ''' - Extra metadata - ''' - self.assertEqual( - extra['created_date'], - '2016-10-19T11:08:04Z' - ) - self.assertEqual( - extra['created_by'], - 'test@test.te' - ) - self.assertEqual( - extra['etag'], - '2a21551ba4adf85d9fb04b05a6938bcc' - ) - self.assertEqual( - extra['last_modified_date'], - '2016-10-19T11:08:04Z' - ) - self.assertEqual( - extra['last_modified_by'], - 'test@test.te' - ) - self.assertEqual( - extra['state'], - 'BUSY' + 'SSH' ) - - ''' - Extra properties - ''' self.assertEqual( - extra['name'], - 'Test created firewall rule' - ) - self.assertEqual( - extra['protocol'], - 'TCP' - ) - self.assertEqual( - extra['source_mac'], - None - ) - self.assertEqual( - extra['source_ip'], - None - ) - self.assertEqual( - extra['target_ip'], - None - ) - - self.assertEqual( - extra['icmp_code'], - None - ) - self.assertEqual( - extra['icmp_type'], - None - ) - self.assertEqual( - extra['port_range_start'], - 80 - ) - self.assertEqual( - extra['port_range_end'], - 80 - ) - - def test_ex_update_firewall_rule(self): - - firewall_rule = self.driver.ex_describe_firewall_rule( - ex_href=( - '/cloudapi/v3/datacenters/' - 'dc-1/' - 'servers/s-3/' - 'nics/nic-2/' - 'firewallrules/fw2' - ) - ) - updated = self.driver.ex_update_firewall_rule( - firewall_rule=firewall_rule, - name='Test updated firewall rule', - port_range_start=8080, - port_range_end=8080 - ) - - extra = updated.extra - - ''' - Standard properties - ''' - self.assertEqual( - updated.id, - 'fw2' - ) - self.assertEqual( - updated.name, - 'HTTPs (SSL)' - ) - self.assertEqual( - updated.href, + firewall_rule.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' - 'servers/s-3' - '/nics/nic-2/' - 'firewallrules/fw2' + 'servers/s-3/' + 'nics/nic-2/' + 'firewallrules/fwr-1' ) ) self.assertEqual( - updated.state, + firewall_rule.state, NodeState.PENDING ) @@ -3207,7 +2944,7 @@ def test_ex_update_firewall_rule(self): ''' self.assertEqual( extra['created_date'], - '2016-10-19T09:55:10Z' + '2016-10-19T11:08:04Z' ) self.assertEqual( extra['created_by'], @@ -3215,11 +2952,11 @@ def test_ex_update_firewall_rule(self): ) self.assertEqual( extra['etag'], - '00bb5b86562db1ed19ca38697e485160' + '2a21551ba4adf85d9fb04b05a6938bcc' ) self.assertEqual( extra['last_modified_date'], - '2016-10-19T09:55:10Z' + '2016-10-19T11:08:04Z' ) self.assertEqual( extra['last_modified_by'], @@ -3235,7 +2972,7 @@ def test_ex_update_firewall_rule(self): ''' self.assertEqual( extra['name'], - 'HTTPs (SSL)' + 'SSH' ) self.assertEqual( extra['protocol'], @@ -3243,7 +2980,7 @@ def test_ex_update_firewall_rule(self): ) self.assertEqual( extra['source_mac'], - None + '01:23:45:67:89:00' ) self.assertEqual( extra['source_ip'], @@ -3264,18 +3001,62 @@ def test_ex_update_firewall_rule(self): ) self.assertEqual( extra['port_range_start'], - 443 + 22 ) self.assertEqual( extra['port_range_end'], - 443 + 22 + ) + + def test_ex_create_network_interface_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no network interface' + self.driver.ex_create_firewall_rule( + network_interface=None, + protocol='TCP', + name='SSH' + ) + + def test_ex_update_firewall_rule(self): + + firewall_rule = self.driver.ex_describe_firewall_rule( + ex_href=( + '/cloudapi/v4/datacenters/' + 'dc-1/' + 'servers/s-3/' + 'nics/nic-2/' + 'firewallrules/fw2' + ) + ) + updated = self.driver.ex_update_firewall_rule( + firewall_rule=firewall_rule, + name='SSH - RENAME' + ) + + extra = updated.extra + + ''' + Standard properties + ''' + self.assertEqual( + updated.id, + 'fw2' + ) + self.assertEqual( + updated.name, + 'SSH - RENAME' + ) + + self.assertEqual( + extra['name'], + 'SSH - RENAME' ) def test_ex_delete_firewall_rule(self): firewall_rule = self.driver.ex_describe_firewall_rule( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2/' @@ -3293,7 +3074,7 @@ def test_ex_delete_firewall_rule(self): def test_ex_list_lans(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) @@ -3317,13 +3098,13 @@ def test_ex_list_lans(self): self.assertEqual( lan.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/1' ) ) self.assertEqual( lan.name, - 'Switch for LAN 1' + 'libcloud Test' ) self.assertEqual( lan.is_public, @@ -3363,7 +3144,7 @@ def test_ex_list_lans(self): ''' self.assertEqual( extra['name'], - 'Switch for LAN 1' + 'libcloud Test' ) self.assertEqual( extra['is_public'], @@ -3381,7 +3162,7 @@ def test_ex_list_lans(self): def test_ex_create_lan(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) @@ -3401,13 +3182,13 @@ def test_ex_create_lan(self): self.assertEqual( lan.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) self.assertEqual( lan.name, - 'Test Created Lan' + 'libcloud Test' ) self.assertEqual( lan.is_public, @@ -3451,17 +3232,24 @@ def test_ex_create_lan(self): ''' self.assertEqual( extra['name'], - 'Test Created Lan' + 'libcloud Test' ) self.assertEqual( extra['is_public'], True ) + def test_ex_create_lan_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no datacenter' + self.driver.ex_create_lan( + datacenter=None + ) + def test_ex_describe_lan(self): lan_w_href = self.driver.ex_describe_lan( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) @@ -3472,6 +3260,14 @@ def test_ex_describe_lan(self): self._verify_lan(lan=lan_w_href) self._verify_lan(lan=lan_w_id) + def test_ex_describe_lan_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_lan( + ex_datacenter_id='dc-1', + ex_lan_id='0' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_lan(self, lan): extra = lan.extra @@ -3485,13 +3281,13 @@ def _verify_lan(self, lan): self.assertEqual( lan.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) self.assertEqual( lan.name, - 'Test Created Lan' + 'libcloud Test' ) self.assertEqual( lan.is_public, @@ -3535,7 +3331,7 @@ def _verify_lan(self, lan): ''' self.assertEqual( extra['name'], - 'Test Created Lan' + 'libcloud Test' ) self.assertEqual( extra['is_public'], @@ -3545,14 +3341,14 @@ def _verify_lan(self, lan): def test_ex_update_lan(self): lan = self.driver.ex_describe_lan( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) updated = self.driver.ex_update_lan( lan=lan, - is_public=True, - name='Updated Lan' + is_public=False, + name='libcloud Test - RENAME' ) extra = updated.extra @@ -3566,17 +3362,17 @@ def test_ex_update_lan(self): self.assertEqual( updated.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) self.assertEqual( updated.name, - 'Test Updated Lan' + 'libcloud Test - RENAME' ) self.assertEqual( updated.is_public, - True + False ) self.assertEqual( updated.state, @@ -3616,17 +3412,17 @@ def test_ex_update_lan(self): ''' self.assertEqual( extra['name'], - 'Test Updated Lan' + 'libcloud Test - RENAME' ) self.assertEqual( extra['is_public'], - True + False ) def test_ex_delete_lan(self): lan = self.driver.ex_describe_lan( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/lans/10' ) ) @@ -3639,85 +3435,14 @@ def test_ex_delete_lan(self): def test_ex_list_load_balancers(self): load_balancers = self.driver.ex_list_load_balancers() - self.assertEqual( - len(load_balancers), - 2 - ) - - balancer = load_balancers[0] - - ''' - Standard properties - ''' - self.assertEqual( - balancer.id, - 'bal-1' - ) - self.assertEqual( - balancer.href, - ( - '/cloudapi/v3/datacenters/' - 'dc-2/' - 'loadbalancers/bal-1' - ) - ) - self.assertEqual( - balancer.name, - 'Test One' - ) - self.assertEqual( - balancer.state, - NodeState.RUNNING - ) - - ''' - Extra metadata - ''' - self.assertEqual( - balancer.extra['created_date'], - '2016-10-26T13:02:33Z' - ) - self.assertEqual( - balancer.extra['created_by'], - 'test@test.te' - ) - self.assertEqual( - balancer.extra['etag'], - '71e8df57a58615b9e15400ede4138b41' - ) - self.assertEqual( - balancer.extra['last_modified_date'], - '2016-10-26T13:02:33Z' - ) - self.assertEqual( - balancer.extra['last_modified_by'], - 'test@test.te' - ) - self.assertEqual( - balancer.extra['state'], - 'AVAILABLE' - ) - - ''' - Extra properties - ''' - self.assertEqual( - balancer.extra['name'], - 'Test One' - ) - self.assertEqual( - balancer.extra['ip'], - '111.112.113.114' - ) - self.assertEqual( - balancer.extra['dhcp'], - True + self.assertTrue( + len(load_balancers) > 0 ) def test_ex_describe_load_balancer(self): load_balancer_w_href = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -3730,6 +3455,14 @@ def test_ex_describe_load_balancer(self): self._verify_load_balancer(load_balancer=load_balancer_w_href) self._verify_load_balancer(load_balancer=load_balancer_w_id) + def test_ex_describe_load_balancer_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_load_balancer( + ex_datacenter_id='dc-2', + ex_load_balancer_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_load_balancer(self, load_balancer): ''' Standard properties @@ -3741,14 +3474,14 @@ def _verify_load_balancer(self, load_balancer): self.assertEqual( load_balancer.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) ) self.assertEqual( load_balancer.name, - 'Test One' + 'libcloud Test' ) self.assertEqual( load_balancer.state, @@ -3788,11 +3521,10 @@ def _verify_load_balancer(self, load_balancer): ''' self.assertEqual( load_balancer.extra['name'], - 'Test One' + 'libcloud Test' ) - self.assertEqual( - load_balancer.extra['ip'], - '111.112.113.114' + self.assertIsNotNone( + load_balancer.extra['ip'] ) self.assertEqual( load_balancer.extra['dhcp'], @@ -3802,16 +3534,18 @@ def _verify_load_balancer(self, load_balancer): def test_ex_create_load_balancer(self): datacenter = self.driver.ex_describe_datacenter( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1' ) ) + nics = self.driver.ex_list_network_interfaces() + created = self.driver.ex_create_load_balancer( datacenter=datacenter, - name='Test load balancer', - ip='10.11.12.13', - dhcp=True + name='libcloud Test', + dhcp=True, + nics=[nics[0]] ) ''' @@ -3824,14 +3558,14 @@ def test_ex_create_load_balancer(self): self.assertEqual( created.href, ( - '/cloudapi/v3/datacenters' + '/cloudapi/v4/datacenters' '/dc-1' '/loadbalancers/bal-1' ) ) self.assertEqual( created.name, - 'Test load balancer' + 'libcloud Test' ) self.assertEqual( created.state, @@ -3871,7 +3605,7 @@ def test_ex_create_load_balancer(self): ''' self.assertEqual( created.extra['name'], - 'Test load balancer' + 'libcloud Test' ) self.assertEqual( created.extra['ip'], @@ -3881,11 +3615,22 @@ def test_ex_create_load_balancer(self): created.extra['dhcp'], True ) + self.assertIsNotNone( + created.extra['entities']['balancednics'] + ) + + def test_ex_create_load_balancer_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no datacenter' + self.driver.ex_create_load_balancer( + datacenter=None, + name='libcloud Test' + ) def test_ex_update_load_balancer(self): load_balancer = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -3893,28 +3638,18 @@ def test_ex_update_load_balancer(self): updated = self.driver.ex_update_load_balancer( load_balancer=load_balancer, - name='Updated Load Balancer', - ip='123.124.125.126', - dhcp=False + name='libcloud Test - RENAME' ) self.assertEqual( updated.name, - 'Updated Load Balancer' - ) - self.assertEqual( - updated.extra['ip'], - '123.124.125.126' - ) - self.assertEqual( - updated.extra['dhcp'], - False + 'libcloud Test - RENAME' ) def test_ex_list_load_balanced_nics(self): load_balancer = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -3923,6 +3658,11 @@ def test_ex_list_load_balanced_nics(self): network_interfaces = self.driver.ex_list_load_balanced_nics( load_balancer ) + + self.assertTrue( + len(network_interfaces) > 0 + ) + network_interface = network_interfaces[0] extra = network_interface.extra @@ -3935,12 +3675,12 @@ def test_ex_list_load_balanced_nics(self): ) self.assertEqual( network_interface.name, - 'Test network interface' + 'libcloud Test' ) self.assertEqual( network_interface.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-1' @@ -3984,7 +3724,7 @@ def test_ex_list_load_balanced_nics(self): ''' self.assertEqual( extra['name'], - 'Test network interface' + 'libcloud Test' ) self.assertEqual( extra['mac'], @@ -4014,7 +3754,7 @@ def test_ex_list_load_balanced_nics(self): def test_ex_describe_load_balanced_nic(self): network_interface_w_href = self.driver.ex_describe_network_interface( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' @@ -4044,12 +3784,12 @@ def _verify_load_balanced_nic(self, network_interface): ) self.assertEqual( network_interface.name, - 'Updated from LibCloud' + 'libcloud Test' ) self.assertEqual( network_interface.href, ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -4093,23 +3833,23 @@ def _verify_load_balanced_nic(self, network_interface): ''' self.assertEqual( extra['name'], - 'Updated from LibCloud' + 'libcloud Test' ) - self.assertEqual( + assertRegex( + self, extra['mac'], - '02:01:0b:9d:4d:ce' + '^([0-9a-f]{2}[:]){5}([0-9a-f]{2})$' ) - self.assertEqual( - extra['ips'], - ['10.15.124.11'] + self.assertTrue( + len(extra['ips']) > 0 ) self.assertEqual( extra['dhcp'], - False + True ) - self.assertEqual( + self.assertIsInstance( extra['lan'], - 2 + int ) self.assertEqual( extra['firewall_active'], @@ -4123,7 +3863,7 @@ def _verify_load_balanced_nic(self, network_interface): def test_ex_attach_nic_to_load_balancer(self): network_interface = self.driver.ex_describe_network_interface( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3' '/nics/nic-2' @@ -4131,7 +3871,7 @@ def test_ex_attach_nic_to_load_balancer(self): ) load_balancer = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -4146,7 +3886,7 @@ def test_ex_remove_nic_from_load_balancer(self): network_interface = self.driver.ex_describe_network_interface( ex_href=( ( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-1/' 'servers/s-3/' 'nics/nic-2' @@ -4155,7 +3895,7 @@ def test_ex_remove_nic_from_load_balancer(self): ) load_balancer = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -4169,7 +3909,7 @@ def test_ex_remove_nic_from_load_balancer(self): def test_ex_delete_load_balancer(self): load_balancer = self.driver.ex_describe_load_balancer( ex_href=( - '/cloudapi/v3/datacenters/' + '/cloudapi/v4/datacenters/' 'dc-2/' 'loadbalancers/bal-1' ) @@ -4183,80 +3923,16 @@ def test_ex_delete_load_balancer(self): def test_ex_list_ip_blocks(self): ip_blocks = self.driver.ex_list_ip_blocks() - self.assertEqual( - len(ip_blocks), - 2 - ) - - ip_block = ip_blocks[0] - extra = ip_block.extra - - ''' - Standard properties - ''' - self.assertEqual( - ip_block.id, - 'ipb-1' - ) - self.assertEqual( - ip_block.name, - 'Test IP Block One' - ) - self.assertEqual( - ip_block.href, - '/cloudapi/v3/ipblocks/ipb-1' - ) - self.assertEqual( - ip_block.location, - 'de/fkb' - ) - self.assertEqual( - ip_block.size, - 2 - ) - self.assertEqual( - ip_block.ips, - ['78.137.101.252', '78.137.101.251'] - ) - self.assertEqual( - ip_block.state, - NodeState.RUNNING - ) - - ''' - Extra metadata - ''' - self.assertEqual( - extra['created_date'], - '2016-10-26T15:05:36Z' - ) - self.assertEqual( - extra['created_by'], - 'test@test.te' - ) - self.assertEqual( - extra['etag'], - 'acbf00bacf7ee48d4b8bc4e7413e1f30' - ) - self.assertEqual( - extra['last_modified_date'], - '2016-10-26T15:05:36Z' - ) - self.assertEqual( - extra['last_modified_by'], - 'test@test.te' - ) - self.assertEqual( - extra['state'], - 'AVAILABLE' + self.assertTrue( + len(ip_blocks) > 0 ) def test_ex_create_ip_block(self): - location = self.driver.ex_describe_location(ex_location_id='de/fkb') + location = self.driver.ex_describe_location(ex_location_id='us/las') created = self.driver.ex_create_ip_block( location=location, size=2, - name='Test Created IP Block' + name='libcloud Test' ) extra = created.extra @@ -4269,23 +3945,23 @@ def test_ex_create_ip_block(self): ) self.assertEqual( created.name, - 'Test Created IP Block' + 'libcloud Test' ) self.assertEqual( created.href, - '/cloudapi/v3/ipblocks/ipb-1' + '/cloudapi/v4/ipblocks/ipb-1' ) self.assertEqual( created.location, - 'de/fkb' + 'us/las' ) self.assertEqual( created.size, 2 ) self.assertEqual( - created.ips, - ['11.12.13.14', '15.16.17.18'] + len(created.ips), + 2 ) self.assertEqual( created.state, @@ -4320,10 +3996,19 @@ def test_ex_create_ip_block(self): 'BUSY' ) + def test_ex_create_ip_block_failure(self): + with self.assertRaises(AttributeError): + 'Raises attribute error if no location' + self.driver.ex_create_ip_block( + location=None, + size=2, + name='libcloud Test' + ) + def test_ex_describe_ip_block(self): ip_block_w_href = self.driver.ex_describe_ip_block( ex_href=( - '/cloudapi/v3/ipblocks/' + '/cloudapi/v4/ipblocks/' 'ipb-2' ) ) @@ -4333,6 +4018,13 @@ def test_ex_describe_ip_block(self): self._verify_ip_block(ip_block=ip_block_w_href) self._verify_ip_block(ip_block=ip_block_w_id) + def test_ex_describe_ip_block_failure(self): + with self.assertRaises(BaseHTTPError) as cm: + self.driver.ex_describe_ip_block( + ex_ip_block_id='00000000' + ) + self.assertIn('Resource does not exist', cm.exception.message.value) + def _verify_ip_block(self, ip_block): extra = ip_block.extra @@ -4345,25 +4037,25 @@ def _verify_ip_block(self, ip_block): ) self.assertEqual( ip_block.name, - 'Test IP Block One' + 'libcloud Test' ) self.assertEqual( ip_block.href, ( - '/cloudapi/v3/ipblocks/ipb-2' + '/cloudapi/v4/ipblocks/ipb-2' ) ) self.assertEqual( ip_block.location, - 'de/fkb' + 'us/las' ) self.assertEqual( ip_block.size, - 1 + 2 ) self.assertEqual( - ip_block.ips, - ['78.137.101.250'] + len(ip_block.ips), + 2 ) self.assertEqual( ip_block.state, @@ -4401,7 +4093,7 @@ def _verify_ip_block(self, ip_block): def test_ex_delete_ip_block(self): ip_block = self.driver.ex_describe_ip_block( ex_href=( - '/cloudapi/v3/ipblocks/' + '/cloudapi/v4/ipblocks/' 'ipb-2' ) ) @@ -4418,7 +4110,7 @@ class ProfitBricksMockHttp(MockHttp): GET - fetches images ''' - def _cloudapi_v3_images( + def _cloudapi_v4_images( self, method, url, body, headers ): body = self.fixtures.load('list_images.json') @@ -4434,7 +4126,7 @@ def _cloudapi_v3_images( GET - fetches locations ''' - def _cloudapi_v3_locations( + def _cloudapi_v4_locations( self, method, url, body, headers ): body = self.fixtures.load('list_locations.json') @@ -4451,7 +4143,7 @@ def _cloudapi_v3_locations( GET - fetches data centers PATCH - creates a data center ''' - def _cloudapi_v3_datacenters( + def _cloudapi_v4_datacenters( self, method, url, body, headers ): if method == 'GET': @@ -4479,7 +4171,7 @@ def _cloudapi_v3_datacenters( DELETE - destroys a data center PATCH - updates a data center ''' - def _cloudapi_v3_datacenters_dc_1( + def _cloudapi_v4_datacenters_dc_1( self, method, url, body, headers ): if method == 'GET': @@ -4508,13 +4200,18 @@ def _cloudapi_v3_datacenters_dc_1( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on data center nodes (servers) GET - fetches a list of nodes (servers) for a data center POST - creates a node (server) for a data center ''' - def _cloudapi_v3_datacenters_dc_1_servers( + def _cloudapi_v4_datacenters_dc_1_servers( self, method, url, body, headers ): if method == 'GET': @@ -4541,7 +4238,7 @@ def _cloudapi_v3_datacenters_dc_1_servers( GET - fetches a list of volumes for a data center POST - creates a volume for a data center ''' - def _cloudapi_v3_datacenters_dc_1_volumes( + def _cloudapi_v4_datacenters_dc_1_volumes( self, method, url, body, headers ): if method == 'GET': @@ -4569,7 +4266,7 @@ def _cloudapi_v3_datacenters_dc_1_volumes( DELETE - destroys a node (server) PATCH - updates a node ''' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1( self, method, url, body, headers ): if method == 'GET': @@ -4597,13 +4294,19 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1( {}, httplib.responses[httplib.ACCEPTED] ) + + def _cloudapi_v4_datacenters_dc_1_servers_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on a node (server) POST - reboots, then starts and stops a node ''' 'reboot a node' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_reboot( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_reboot( self, method, url, body, headers ): return ( @@ -4613,7 +4316,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_reboot( httplib.responses[httplib.ACCEPTED] ) 'start a node' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_stop( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_stop( self, method, url, body, headers ): return ( @@ -4624,7 +4327,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_stop( ) 'stop a node' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_start( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_start( self, method, url, body, headers ): return ( @@ -4641,7 +4344,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_start( DELETE - deletes an image PATCH - updates an image """ - def _cloudapi_v3_images_img_2( + def _cloudapi_v4_images_img_2( self, method, url, body, headers ): if method == 'GET': @@ -4670,6 +4373,11 @@ def _cloudapi_v3_images_img_2( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_images_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on a volume @@ -4677,7 +4385,7 @@ def _cloudapi_v3_images_img_2( DELETE - destroys a volume PATCH - updates a volume ''' - def _cloudapi_v3_datacenters_dc_1_volumes_vol_2( + def _cloudapi_v4_datacenters_dc_1_volumes_vol_2( self, method, url, body, headers ): if method == 'GET': @@ -4705,13 +4413,18 @@ def _cloudapi_v3_datacenters_dc_1_volumes_vol_2( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_1_volumes_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on a volume connected to a node (server) DELETE - destroys the link between a volume and a server but does delete the volume. ''' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_volumes_vol_2( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_volumes_vol_2( self, method, url, body, headers ): return ( @@ -4726,7 +4439,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_volumes_vol_2( GET - fetches a location ''' - def _cloudapi_v3_locations_de_fkb( + def _cloudapi_v4_locations_us_las( self, method, url, body, headers ): body = self.fixtures.load('ex_describe_location.json') @@ -4737,13 +4450,18 @@ def _cloudapi_v3_locations_de_fkb( httplib.responses[httplib.OK] ) + def _cloudapi_v4_locations_us_000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on volumes connected to nodes (servers) GET - fetch volumes connected to a server POST - attach a volume to a node (server) ''' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_volumes( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_volumes( self, method, url, body, headers ): if(method == 'GET'): @@ -4770,7 +4488,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_volumes( GET - fetch network interfaces for a node (server) POST - create a network interface for a node (server) ''' - def _cloudapi_v3_datacenters_dc_1_servers_srv_1_nics( + def _cloudapi_v4_datacenters_dc_1_servers_srv_1_nics( self, method, url, body, headers ): if method == 'GET': @@ -4798,7 +4516,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_srv_1_nics( DELETE - destroy a network interface PATCH - update a network interface ''' - def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2( + def _cloudapi_v4_datacenters_dc_1_servers_s_3_nics_nic_2( self, method, url, body, headers ): if method == 'GET': @@ -4819,7 +4537,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2( ) elif method == 'PATCH': - body = self.fixtures.load('ex_set_inet_access.json') + body = self.fixtures.load('ex_update_network_interface.json') return ( httplib.ACCEPTED, body, @@ -4827,6 +4545,11 @@ def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_1_servers_s_3_nics_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on firewall rules @@ -4834,7 +4557,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2( DELETE - destroy a firewall rule PATCH - update a firewall rule ''' - def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules_fw2( + def _cloudapi_v4_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules_fw2( self, method, url, @@ -4867,13 +4590,18 @@ def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules_fw2( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules_00( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on firewall rules connected to a network interface GET - fetch a list of firewall rules connected to a network interface POST - create a firewall rule for a network interface ''' - def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules( + def _cloudapi_v4_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules( self, method, url, body, headers ): if method == 'GET': @@ -4900,7 +4628,7 @@ def _cloudapi_v3_datacenters_dc_1_servers_s_3_nics_nic_2_firewallrules( GET - fetch a list of lans POST - create a lan ''' - def _cloudapi_v3_datacenters_dc_1_lans( + def _cloudapi_v4_datacenters_dc_1_lans( self, method, url, body, headers ): if method == 'GET': @@ -4928,7 +4656,7 @@ def _cloudapi_v3_datacenters_dc_1_lans( DELETE - Destroy a lan PATCH - update a lan ''' - def _cloudapi_v3_datacenters_dc_1_lans_10( + def _cloudapi_v4_datacenters_dc_1_lans_10( self, method, url, body, headers ): if method == 'GET': @@ -4957,12 +4685,17 @@ def _cloudapi_v3_datacenters_dc_1_lans_10( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_1_lans_0( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on snapshots GET - fetch a list of snapshots ''' - def _cloudapi_v3_snapshots( + def _cloudapi_v4_snapshots( self, method, url, body, headers ): if method == 'GET': @@ -4978,8 +4711,9 @@ def _cloudapi_v3_snapshots( Operations on volume snapshots POST - create a volume snapshot + POST - restore a volume snapshot ''' - def _cloudapi_v3_datacenters_dc_1_volumes_vol_2_create_snapshot( + def _cloudapi_v4_datacenters_dc_1_volumes_vol_2_create_snapshot( self, method, url, body, headers ): if method == 'POST': @@ -4991,6 +4725,17 @@ def _cloudapi_v3_datacenters_dc_1_volumes_vol_2_create_snapshot( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_1_volumes_vol_2_restore_snapshot( + self, method, url, body, headers + ): + if method == 'POST': + return ( + httplib.ACCEPTED, + '', + {}, + httplib.responses[httplib.ACCEPTED] + ) + ''' Operations on a single snapshot @@ -4998,7 +4743,7 @@ def _cloudapi_v3_datacenters_dc_1_volumes_vol_2_create_snapshot( DELETE - delete a snapshot PATCH - update a snapshot ''' - def _cloudapi_v3_snapshots_sshot( + def _cloudapi_v4_snapshots_sshot( self, method, url, body, headers ): if method == 'GET': @@ -5027,13 +4772,18 @@ def _cloudapi_v3_snapshots_sshot( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_snapshots_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on load balancers GET - list load balancers POST - create a load balancer for this datacenter ''' - def _cloudapi_v3_datacenters_dc_1_loadbalancers( + def _cloudapi_v4_datacenters_dc_1_loadbalancers( self, method, url, body, headers ): if method == 'GET': @@ -5061,7 +4811,7 @@ def _cloudapi_v3_datacenters_dc_1_loadbalancers( DELETE - delete a load balancer PATCH - update a load balancer ''' - def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1( + def _cloudapi_v4_datacenters_dc_2_loadbalancers_bal_1( self, method, url, body, headers ): if method == 'GET': @@ -5090,12 +4840,17 @@ def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_datacenters_dc_2_loadbalancers_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + ''' Operations on a load balancers nics GET - get load balanced nics ''' - def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1_balancednics( + def _cloudapi_v4_datacenters_dc_2_loadbalancers_bal_1_balancednics( self, method, url, body, headers ): if method == 'GET': @@ -5120,7 +4875,7 @@ def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1_balancednics( DELETE - remove the nic from a load balancer ''' - def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1_balancednics_nic_2( + def _cloudapi_v4_datacenters_dc_2_loadbalancers_bal_1_balancednics_nic_2( self, method, url, body, headers ): if method == 'DELETE': @@ -5137,7 +4892,7 @@ def _cloudapi_v3_datacenters_dc_2_loadbalancers_bal_1_balancednics_nic_2( GET - list IP blocks POST - create an IP block ''' - def _cloudapi_v3_ipblocks( + def _cloudapi_v4_ipblocks( self, method, url, body, headers ): if method == 'GET': @@ -5164,7 +4919,7 @@ def _cloudapi_v3_ipblocks( GET - fetch an IP block DELETE - delete an IP block ''' - def _cloudapi_v3_ipblocks_ipb_2( + def _cloudapi_v4_ipblocks_ipb_2( self, method, url, body, headers ): if method == 'GET': @@ -5184,5 +4939,19 @@ def _cloudapi_v3_ipblocks_ipb_2( httplib.responses[httplib.ACCEPTED] ) + def _cloudapi_v4_ipblocks_00000000( + self, method, url, body, headers + ): + return self._get_not_found() + + def _get_not_found(self): + body = self.fixtures.load('error_resource_not_found.json') + return ( + httplib.NOT_FOUND, + body, + {}, + httplib.responses[httplib.NOT_FOUND] + ) + if __name__ == '__main__': sys.exit(unittest.main()) From 32178ac10086e23615f15e64881475861e085d78 Mon Sep 17 00:00:00 2001 From: nurfet-becirevic Date: Mon, 4 Sep 2017 09:18:39 -0400 Subject: [PATCH 2/4] merge from upstream 'trunk' --- .gitignore | 6 ++ CHANGES.rst | 14 ++++ doap_libcloud.rdf | 7 ++ libcloud/__init__.py | 2 +- libcloud/compute/drivers/ec2.py | 81 ++++++++++++++++--- libcloud/compute/drivers/libvirt_driver.py | 2 +- .../ec2/describe_reserved_instances.xml | 1 + libcloud/test/compute/test_ec2.py | 17 ++-- libcloud/test/conftest.py | 25 ++++++ 9 files changed, 132 insertions(+), 23 deletions(-) create mode 100644 libcloud/test/conftest.py diff --git a/.gitignore b/.gitignore index e5db6ec5b4..36902da8b4 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,9 @@ apache_libcloud.egg-info/ .eggs/ .cache/ .vscode/ +.Python +bin/ +include/ +lib/ +pip-selfcheck.json +report.html diff --git a/CHANGES.rst b/CHANGES.rst index fc6aa72917..75dbf52739 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,6 +4,20 @@ Changes in current version of Apache Libcloud --------------------------------------------- +Compute +~~~~~~~ + +- [EC2] add g3 instance types + [GITHUB-1101] + (@zulupro) + +- [EC2] add 'end' to ec2 reserved_node + [GITHUB-1099] + (@xofer) + +Changes in Apache Libcloud 2.2.0 +-------------------------------- + Common ~~~~~~ diff --git a/doap_libcloud.rdf b/doap_libcloud.rdf index 2c8341ce65..815feed860 100644 --- a/doap_libcloud.rdf +++ b/doap_libcloud.rdf @@ -363,6 +363,13 @@ 2017-07-17 v2.1.0 + + + + 2.2.0 + 2017-09-04 + v2.2.0 + diff --git a/libcloud/__init__.py b/libcloud/__init__.py index bf2ef2d691..24d4a68dcd 100644 --- a/libcloud/__init__.py +++ b/libcloud/__init__.py @@ -36,7 +36,7 @@ '__version__', 'enable_debug' ] -__version__ = '2.1.0' +__version__ = '2.2.0' def enable_debug(fo): diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py index efb62750de..126d3624cc 100644 --- a/libcloud/compute/drivers/ec2.py +++ b/libcloud/compute/drivers/ec2.py @@ -322,6 +322,42 @@ def GiB(value): 'cpu': 32 } }, + 'g3.4xlarge': { + 'id': 'g3.4xlarge', + 'name': 'Cluster GPU G3 Four Extra Large Instance', + 'ram': GiB(122), + 'disk': 0, # EBS only + 'bandwidth': None, + 'extra': { + 'cpu': 16, + 'gpu': 1, + 'gpu_ram': GiB(8) + } + }, + 'g3.8xlarge': { + 'id': 'g3.8xlarge', + 'name': 'Cluster GPU G3 Eight Extra Large Instance', + 'ram': GiB(244), + 'disk': 0, # EBS only + 'bandwidth': None, + 'extra': { + 'cpu': 32, + 'gpu': 2, + 'gpu_ram': GiB(16) + } + }, + 'g3.16xlarge': { + 'id': 'g3.16xlarge', + 'name': 'Cluster GPU G3 16 Extra Large Instance', + 'ram': GiB(488), + 'disk': 0, # EBS only + 'bandwidth': None, + 'extra': { + 'cpu': 64, + 'gpu': 4, + 'gpu_ram': GiB(32) + } + }, 'p2.xlarge': { 'id': 'p2.xlarge', 'name': 'Cluster GPU P2 Large Instance', @@ -869,6 +905,9 @@ def GiB(value): 'cg1.4xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'cr1.8xlarge', 'hs1.8xlarge', 'i2.xlarge', @@ -933,6 +972,9 @@ def GiB(value): 'c1.xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'c3.large', 'c3.xlarge', 'c3.2xlarge', @@ -1012,6 +1054,9 @@ def GiB(value): 'cg1.4xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'cr1.8xlarge', 'hs1.8xlarge', 'i2.xlarge', @@ -1076,6 +1121,9 @@ def GiB(value): 'c1.xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'p2.xlarge', 'p2.8xlarge', 'p2.16xlarge', @@ -1153,6 +1201,9 @@ def GiB(value): 'c1.xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'c3.large', 'c3.xlarge', 'c3.2xlarge', @@ -1747,6 +1798,7 @@ def GiB(value): 'x1.32xlarge' ] }, + # GovCloud Region 'us-gov-west-1': { 'endpoint': 'ec2.us-gov-west-1.amazonaws.com', 'api_name': 'ec2_us_govwest', @@ -1775,6 +1827,9 @@ def GiB(value): 'c1.xlarge', 'g2.2xlarge', 'g2.8xlarge', + 'g3.4xlarge', + 'g3.8xlarge', + 'g3.16xlarge', 'c3.large', 'c3.xlarge', 'c3.2xlarge', @@ -2765,6 +2820,10 @@ def GiB(value): 'xpath': 'start', 'transform_func': str }, + 'end': { + 'xpath': 'end', + 'transform_func': str + }, 'duration': { 'xpath': 'duration', 'transform_func': int @@ -3765,19 +3824,23 @@ def create_node(self, **kwargs): if subnet_id: params['SubnetId'] = subnet_id + # Specify tags at instance creation time + tags = {'Name': kwargs['name']} + if 'ex_metadata' in kwargs: + tags.update(kwargs['ex_metadata']) + tagspec_root = 'TagSpecification.1.' + params[tagspec_root + 'ResourceType'] = 'instance' + tag_nr = 1 + for k, v in tags.items(): + tag_root = tagspec_root + 'Tag.%d.' % tag_nr + params[tag_root + 'Key'] = k + params[tag_root + 'Value'] = v + tag_nr += 1 + object = self.connection.request(self.path, params=params).object nodes = self._to_nodes(object, 'instancesSet/item') for node in nodes: - tags = {'Name': kwargs['name']} - if 'ex_metadata' in kwargs: - tags.update(kwargs['ex_metadata']) - - try: - self.ex_create_tags(resource=node, tags=tags) - except Exception: - continue - node.name = kwargs['name'] node.extra.update({'tags': tags}) diff --git a/libcloud/compute/drivers/libvirt_driver.py b/libcloud/compute/drivers/libvirt_driver.py index a914c5e613..f2ccfc5f1f 100644 --- a/libcloud/compute/drivers/libvirt_driver.py +++ b/libcloud/compute/drivers/libvirt_driver.py @@ -411,7 +411,7 @@ def _parse_ip_table_neigh(self, ip_output): Sets up the regexp for parsing out IP addresses from the 'ip neighbor' command and pass it along to the parser function. - :return: Dictionary from the parsing funtion + :return: Dictionary from the parsing function :rtype: ``dict`` """ ip_regex = re.compile('(.*?)\s+.*lladdr\s+(.*?)\s+') diff --git a/libcloud/test/compute/fixtures/ec2/describe_reserved_instances.xml b/libcloud/test/compute/fixtures/ec2/describe_reserved_instances.xml index 29d7f3fad9..6c5ac71e7b 100644 --- a/libcloud/test/compute/fixtures/ec2/describe_reserved_instances.xml +++ b/libcloud/test/compute/fixtures/ec2/describe_reserved_instances.xml @@ -6,6 +6,7 @@ t1.micro us-east-1b 2013-06-18T12:07:53.161Z + 2014-06-18T12:07:53.161Z 31536000 23.0 0.012 diff --git a/libcloud/test/compute/test_ec2.py b/libcloud/test/compute/test_ec2.py index 2766fc7ad8..3209ac4ae0 100644 --- a/libcloud/test/compute/test_ec2.py +++ b/libcloud/test/compute/test_ec2.py @@ -282,6 +282,7 @@ def test_ex_list_reserved_nodes(self): self.assertEqual(node.extra['instance_type'], 't1.micro') self.assertEqual(node.extra['availability'], 'us-east-1b') self.assertEqual(node.extra['start'], '2013-06-18T12:07:53.161Z') + self.assertEqual(node.extra['end'], '2014-06-18T12:07:53.161Z') self.assertEqual(node.extra['duration'], 31536000) self.assertEqual(node.extra['usage_price'], 0.012) self.assertEqual(node.extra['fixed_price'], 23.0) @@ -444,21 +445,21 @@ def test_list_sizes(self): self.assertTrue('m2.4xlarge' in ids) if region_name == 'us-east-1': - self.assertEqual(len(sizes), 67) + self.assertEqual(len(sizes), 70) self.assertTrue('cg1.4xlarge' in ids) self.assertTrue('cc2.8xlarge' in ids) self.assertTrue('cr1.8xlarge' in ids) self.assertTrue('x1.32xlarge' in ids) elif region_name == 'us-west-1': - self.assertEqual(len(sizes), 58) + self.assertEqual(len(sizes), 61) if region_name == 'us-west-2': - self.assertEqual(len(sizes), 68) + self.assertEqual(len(sizes), 71) elif region_name == 'ap-southeast-1': self.assertEqual(len(sizes), 57) elif region_name == 'ap-southeast-2': self.assertEqual(len(sizes), 61) elif region_name == 'eu-west-1': - self.assertEqual(len(sizes), 65) + self.assertEqual(len(sizes), 68) elif region_name == 'ap-south-1': self.assertEqual(len(sizes), 41) @@ -1526,10 +1527,6 @@ def _ModifySnapshotAttribute(self, method, url, body, headers): body = self.fixtures.load('modify_snapshot_attribute.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) - def _idempotent_CreateTags(self, method, url, body, headers): - body = self.fixtures.load('create_tags.xml') - return (httplib.OK, body, {}, httplib.responses[httplib.OK]) - def _CreateVolume(self, method, url, body, headers): body = self.fixtures.load('create_volume.xml') return (httplib.OK, body, {}, httplib.responses[httplib.OK]) @@ -1741,10 +1738,6 @@ def _services_Eucalyptus_RunInstances(self, method, url, body, headers): return self._RunInstances(method, url, body, headers) - def _services_Eucalyptus_CreateTags(self, method, url, body, - headers): - return self._CreateTags(method, url, body, headers) - def _services_Eucalyptus_DescribeInstanceTypes(self, method, url, body, headers): body = self.fixtures.load('describe_instance_types.xml') diff --git a/libcloud/test/conftest.py b/libcloud/test/conftest.py new file mode 100644 index 0000000000..505c5709da --- /dev/null +++ b/libcloud/test/conftest.py @@ -0,0 +1,25 @@ +import os.path +import pytest + + +def pytest_configure(config): + """Check that secrets.py is valid""" + + this_dir = os.path.abspath(os.path.split(__file__)[0]) + secrets_current = os.path.join(this_dir, 'secrets.py') + secrets_dist = os.path.join(this_dir, 'secrets.py-dist') + + if not os.path.isfile(secrets_current): + print("Missing " + secrets_current) + print("Maybe you forgot to copy it from -dist:") + print("cp libcloud/test/secrets.py-dist libcloud/test/secrets.py") + pytest.exit('') + + mtime_current = os.path.getmtime(secrets_current) + mtime_dist = os.path.getmtime(secrets_dist) + + if mtime_dist > mtime_current: + print("It looks like test/secrets.py file is out of date.") + print("Please copy the new secrets.py-dist file over otherwise" + + " tests might fail") + pytest.exit('') From 85de9c1967dc8b98939265f8f92440f08f4910eb Mon Sep 17 00:00:00 2001 From: nurfet-becirevic Date: Tue, 5 Sep 2017 13:35:11 +0200 Subject: [PATCH 3/4] fix flake8 linting --- libcloud/compute/drivers/profitbricks.py | 1 - libcloud/test/compute/test_profitbricks.py | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libcloud/compute/drivers/profitbricks.py b/libcloud/compute/drivers/profitbricks.py index f2d44cb6e1..b310f09157 100644 --- a/libcloud/compute/drivers/profitbricks.py +++ b/libcloud/compute/drivers/profitbricks.py @@ -26,7 +26,6 @@ from libcloud.common.base import ConnectionUserAndKey, JsonResponse from libcloud.compute.base import Node, NodeDriver, NodeLocation, NodeSize from libcloud.compute.base import NodeImage, StorageVolume, VolumeSnapshot -from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey from libcloud.compute.base import UuidMixin from libcloud.compute.types import NodeState from libcloud.common.types import LibcloudError, MalformedResponseError diff --git a/libcloud/test/compute/test_profitbricks.py b/libcloud/test/compute/test_profitbricks.py index da79b26f99..0ece89d315 100644 --- a/libcloud/test/compute/test_profitbricks.py +++ b/libcloud/test/compute/test_profitbricks.py @@ -1194,7 +1194,6 @@ def test_ex_describe_node_failure(self): ) self.assertIn('Resource does not exist', cm.exception.message.value) - def _verify_node(self, node): extra = node.extra @@ -3008,7 +3007,7 @@ def test_ex_create_firewall_rule(self): 22 ) - def test_ex_create_network_interface_failure(self): + def test_ex_create_firewall_rule_failure(self): with self.assertRaises(AttributeError): 'Raises attribute error if no network interface' self.driver.ex_create_firewall_rule( From 5d76cf6dfa015c27d3dfb69620a36f90d7797c8f Mon Sep 17 00:00:00 2001 From: nurfet-becirevic Date: Mon, 11 Sep 2017 12:49:44 +0200 Subject: [PATCH 4/4] fix urlencode for Python 3 & retain back compatibility for Node and Volume create --- libcloud/compute/drivers/profitbricks.py | 41 ++++++++++++++++-------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/libcloud/compute/drivers/profitbricks.py b/libcloud/compute/drivers/profitbricks.py index b310f09157..9477a09e02 100644 --- a/libcloud/compute/drivers/profitbricks.py +++ b/libcloud/compute/drivers/profitbricks.py @@ -19,13 +19,14 @@ import json import copy import time -import urllib from libcloud.utils.py3 import b +from libcloud.utils.py3 import urlencode from libcloud.compute.providers import Provider from libcloud.common.base import ConnectionUserAndKey, JsonResponse from libcloud.compute.base import Node, NodeDriver, NodeLocation, NodeSize from libcloud.compute.base import NodeImage, StorageVolume, VolumeSnapshot +from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey from libcloud.compute.base import UuidMixin from libcloud.compute.types import NodeState from libcloud.common.types import LibcloudError, MalformedResponseError @@ -695,10 +696,11 @@ def create_node( :type ex_disk: ``int`` :param ex_password: The password for the volume. - :type ex_password: :class:`NodeAuthPassword` + :type ex_password: :class:`NodeAuthPassword` or ``str`` :param ex_ssh_keys: Optional SSH keys for the volume. - :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` + :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` or + ``list`` of ``str`` :param ex_bus_type: Volume bus type (VIRTIO, IDE). :type ex_bus_type: ``str`` @@ -832,12 +834,18 @@ def create_node( } if ex_password is not None: - new_volume['properties']['imagePassword'] = \ - ex_password.password + if isinstance(ex_password, NodeAuthPassword): + new_volume['properties']['imagePassword'] = \ + ex_password.password + else: + new_volume['properties']['imagePassword'] = ex_password if ex_ssh_keys is not None: - new_volume['properties']['sshKeys'] = \ - [ssh_key.pubkey for ssh_key in ex_ssh_keys] + if isinstance(ex_ssh_keys[0], NodeAuthSSHKey): + new_volume['properties']['sshKeys'] = \ + [ssh_key.pubkey for ssh_key in ex_ssh_keys] + else: + new_volume['properties']['sshKeys'] = ex_ssh_keys body['entities']['volumes']['items'].append(new_volume) @@ -1072,10 +1080,11 @@ def create_volume( :type ex_bus_type: ``str`` :param ex_ssh_keys: Optional SSH keys. - :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` + :type ex_ssh_keys: ``list`` of :class:`NodeAuthSSHKey` or + ``list`` of ``str`` :param ex_password: Optional password for root. - :type ex_password: :class:`NodeAuthPassword` + :type ex_password: :class:`NodeAuthPassword` or ``str`` :param ex_availability_zone: Volume Availability Zone. :type ex_availability_zone: ``str`` @@ -1132,10 +1141,16 @@ def create_volume( if ex_bus_type is not None: body['properties']['bus'] = ex_bus_type if ex_ssh_keys is not None: - body['properties']['sshKeys'] = \ - [ssh_key.pubkey for ssh_key in ex_ssh_keys] + if isinstance(ex_ssh_keys[0], NodeAuthSSHKey): + body['properties']['sshKeys'] = \ + [ssh_key.pubkey for ssh_key in ex_ssh_keys] + else: + body['properties']['sshKeys'] = ex_ssh_keys if ex_password is not None: - body['properties']['imagePassword'] = ex_password.password + if isinstance(ex_password, NodeAuthPassword): + body['properties']['imagePassword'] = ex_password.password + else: + body['properties']['imagePassword'] = ex_password if ex_availability_zone is not None: body['properties']['availabilityZone'] = ex_availability_zone @@ -2697,7 +2712,7 @@ def ex_restore_volume_snapshot(self, volume, snapshot): action = volume.extra['href'] + '/restore-snapshot' data = {'snapshotId': snapshot.id} - body = urllib.urlencode(data) + body = urlencode(data) self.connection.request( action=action,