Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ Common
Compute
~~~~~~~

- [Compute] Unify ``NodeDriver`` method signatures across drivers.

Driver implementations now preserve the standard argument order and
optionality declared by ``NodeDriver``. Provider-specific arguments follow
the standard arguments and are optional. ``list_nodes`` is excluded because
its ``*args, **kwargs`` contract is intentionally unrestricted.

This can be a backward-incompatible change for code which passes arguments
positionally to affected methods.

(#2170)
[Miguel Caballer - @micafer]

- [SSH] Support paramiko 4

RSA key support has been removed as of paramiko 4, so only import it
Expand Down
4 changes: 2 additions & 2 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ For example:
def list_nodes(self):
pass

def list_images(self):
def list_images(self, location=None):
pass

def create_node(self):
def create_node(self, name, size, image, location=None, auth=None):
pass

def reboot_node(self):
Expand Down
7 changes: 4 additions & 3 deletions docs/examples/compute/nttcis/Nodes_Create_mcp2_Customized.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
vlans = driver.ex_list_vlans()
vlan = [v for v in vlans if v.name == vlan_name][0]
new_node = driver.create_node(
"Suse_12",
image,
psswd,
name="Suse_12",
size=None,
image=image,
auth=psswd,
ex_description="Customized_Suse server",
ex_network_domain=net_domain,
ex_primary_nic_vlan=vlan,
Expand Down
2 changes: 2 additions & 0 deletions docs/examples/compute/onapp/functionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

node = driver.create_node(
name=name,
size=None,
image=None,
ex_memory=memory,
ex_cpus=cpus,
ex_cpu_shares=cpu_shares,
Expand Down
16 changes: 11 additions & 5 deletions docs/examples/compute/vmware_vcloud_1.5.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,23 @@
image = [i for i in images if i.name == "natty-server-cloudimg-amd64"][0]

# Create node with minimum set of parameters
node = driver.create_node(name="test node 1", image=image)
node = driver.create_node(name="test node 1", size=None, image=image)
# Destroy the node
driver.destroy_node(node)

# Create node without deploying and powering it on
node = driver.create_node(name="test node 2", image=image, ex_deploy=False)
node = driver.create_node(name="test node 2", size=None, image=image, ex_deploy=False)

# Create node with custom CPU & Memory values
node = driver.create_node(name="test node 3", image=image, ex_vm_cpu=3, ex_vm_memory=1024)
node = driver.create_node(
name="test node 3", size=None, image=image, ex_vm_cpu=3, ex_vm_memory=1024
)

# Create node with customised networking parameters (eg. for OVF
# imported images)
node = driver.create_node(
name="test node 4",
size=None,
image=image,
ex_vm_network="your vm net name",
ex_network="your org net name",
Expand All @@ -48,9 +51,12 @@
)

# Create node in a custom virtual data center
node = driver.create_node(name="test node 4", image=image, ex_vdc="your vdc name")
node = driver.create_node(name="test node 4", size=None, image=image, ex_vdc="your vdc name")

# Create node with guest OS customisation script to be run at first boot
node = driver.create_node(
name="test node 5", image=image, ex_vm_script="filesystem path to your script"
name="test node 5",
size=None,
image=image,
ex_vm_script="filesystem path to your script",
)
26 changes: 26 additions & 0 deletions docs/upgrade_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ This page describes how to upgrade from a previous version to a new version
which contains backward incompatible or semi-incompatible changes and how to
preserve the old behavior when this is possible.

Libcloud 3.9.2
--------------

Compute driver implementations now use the same argument order and optionality
as the corresponding methods on ``NodeDriver``. Provider-specific arguments
are optional and appear after the standard arguments. ``list_nodes`` is not
affected because its ``*args, **kwargs`` contract is intentionally
unrestricted.

This affects methods including ``create_node``, ``list_sizes``,
``list_images``, image management, key pair management, and block storage
operations. Code which passes arguments positionally may need to be updated.
Using keyword arguments for provider-specific options is recommended.

For example, the standard node creation signature is:

.. sourcecode:: python

def create_node(self, name, size, image, location=None, auth=None, ...)

The standard volume creation signature is:

.. sourcecode:: python

def create_volume(self, size, name, location=None, snapshot=None, ...)

Libcloud 3.9.0
--------------

Expand Down
2 changes: 1 addition & 1 deletion libcloud/compute/drivers/abiquo.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, user_id, secret, endpoint, **kwargs):
super().__init__(key=user_id, secret=secret, secure=False, host=None, port=None, **kwargs)
self.ex_populate_cache()

def create_node(self, image, name=None, size=None, location=None, ex_group_name=None):
def create_node(self, name, size, image, location=None, auth=None, ex_group_name=None):
"""
Create a new node instance in Abiquo

Expand Down
41 changes: 33 additions & 8 deletions libcloud/compute/drivers/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,10 @@ def __init__(self, subscription_id=None, key_file=None, **kwargs):
self.follow_redirects = kwargs.get("follow_redirects", True)
super().__init__(self.subscription_id, self.key_file, secure=True, **kwargs)

def list_sizes(self):
def list_sizes(
self,
location=None,
):
"""
Lists all sizes

Expand Down Expand Up @@ -481,7 +484,9 @@ def create_node(
name,
size,
image,
ex_cloud_service_name,
location=None,
auth=None,
ex_cloud_service_name=None,
ex_storage_service_name=None,
ex_new_deployment=False,
ex_deployment_slot="Production",
Expand All @@ -490,7 +495,6 @@ def create_node(
ex_custom_data=None,
ex_virtual_network_name=None,
ex_network_config=None,
auth=None,
**kwargs,
):
"""
Expand Down Expand Up @@ -1004,19 +1008,40 @@ def ex_destroy_storage_service(self, name):
Functions not implemented
"""

def create_volume_snapshot(self):
def create_volume_snapshot(
self,
volume,
name=None,
):
raise NotImplementedError("You cannot create snapshots of " "Azure VMs at this time.")

def attach_volume(self):
def attach_volume(
self,
node,
volume,
device=None,
):
raise NotImplementedError("attach_volume is not supported " "at this time.")

def create_volume(self):
def create_volume(
self,
size,
name,
location=None,
snapshot=None,
):
raise NotImplementedError("create_volume is not supported " "at this time.")

def detach_volume(self):
def detach_volume(
self,
volume,
):
raise NotImplementedError("detach_volume is not supported " "at this time.")

def destroy_volume(self):
def destroy_volume(
self,
volume,
):
raise NotImplementedError("destroy_volume is not supported " "at this time.")

"""
Expand Down
8 changes: 4 additions & 4 deletions libcloud/compute/drivers/azure_arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ def create_node(
name,
size,
image,
auth,
ex_resource_group,
location=None,
auth=None,
ex_resource_group=None,
ex_storage_account=None,
ex_blob_container="vhds",
location=None,
ex_user_name="azureuser",
ex_network=None,
ex_subnet=None,
Expand Down Expand Up @@ -1082,10 +1082,10 @@ def attach_volume(
self,
node,
volume,
device=None,
ex_lun=None,
ex_vhd_uri=None,
ex_vhd_create=False,
**ex_kwargs,
):
"""
Attach a volume to node.
Expand Down
9 changes: 7 additions & 2 deletions libcloud/compute/drivers/brightbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ def _put(self, path, data={}):
headers = {"Content-Type": "application/json"}
return self.connection.request(path, data=data, headers=headers, method="PUT")

def create_node(self, name, size, image, location=None, ex_userdata=None, ex_servergroup=None):
def create_node(
self, name, size, image, location=None, auth=None, ex_userdata=None, ex_servergroup=None
):
"""Create a new Brightbox node

Reference: https://api.gb1.brightbox.com/1.0/#server_create_server
Expand Down Expand Up @@ -216,7 +218,10 @@ def list_images(self, location=None):
data = self.connection.request("/%s/images" % self.api_version).object
return list(map(self._to_image, data))

def list_sizes(self):
def list_sizes(
self,
location=None,
):
data = self.connection.request("/%s/server_types" % self.api_version).object
return list(map(self._to_size, data))

Expand Down
12 changes: 9 additions & 3 deletions libcloud/compute/drivers/cloudscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,19 @@ def list_nodes(self):
"""
return self._list_resources("/v1/servers", self._to_node)

def list_sizes(self):
def list_sizes(
self,
location=None,
):
"""
Lists all available sizes. On cloudscale these are known as flavors.
"""
return self._list_resources("/v1/flavors", self._to_size)

def list_images(self):
def list_images(
self,
location=None,
):
"""
List all images.

Expand All @@ -110,7 +116,7 @@ def list_images(self):
"""
return self._list_resources("/v1/images", self._to_image)

def create_node(self, name, size, image, location=None, ex_create_attr=None):
def create_node(self, name, size, image, location=None, auth=None, ex_create_attr=None):
"""
Create a node.

Expand Down
Loading