IBM SmartCloud Enterprise Driver Documentation¶
API Docs¶
-
class
libcloud.compute.drivers.ibm_sce.IBMNodeDriver(key, secret=None, secure=True, host=None, port=None, api_version=None, **kwargs)[source]¶ Node driver for IBM SmartCloud Enterprise
-
attach_volume(node, volume)[source]¶ Attaches volume to node.
Parameters: - node (
Node) – Node to attach volume to - volume (
StorageVolume) – Volume to attach
Return type: bool- node (
-
connectionCls¶ alias of
IBMConnection
-
copy_image(source_region, node_image, name, description=None)¶ Copies an image from a source region to the current region.
Parameters: - source_region (
str) – Region to copy the node from. - node_image (
NodeImage:) – NodeImage to copy. - name (
str) – name for new image. - description – description for new image.
Return type: Returns: NodeImage instance on success.
- source_region (
-
create_image(name, description=None, **kwargs)[source]¶ Create a new node image from an existing volume or image.
Parameters: - name (
str) – Name of the image to be created (required) - description (
str) – Description of the image to be created - image_id (
str) – The ID of the source image if cloning the image - volume_id (
str) – The ID of the storage volume if importing the image
Returns: The newly created
NodeImage.Return type: NodeImage- name (
-
create_key_pair(name)¶ Create a new key pair object.
Parameters: name ( str) – Key pair name.
-
create_node(**kwargs)[source]¶ Creates a node in the IBM SmartCloud Enterprise.
See
NodeDriver.create_nodefor more keyword args.@inherits:
NodeDriver.create_nodeParameters: - auth (
NodeAuthSSHKey) – Name of the pubkey to use. When constructingNodeAuthSSHKeyinstance, ‘pubkey’ argument must be the name of the public key to use. You chose this name when creating a new public key on the IBM server. - ex_configurationData (
dict) – Image-specific configuration parameters. Configuration parameters are defined in the parameters .xml file. The URL to this file is defined in the NodeImage at extra[parametersURL]. Note: This argument must be specified when launching a Windows instance. It must contain ‘UserName’ and ‘Password’ keys.
- auth (
-
create_volume(size, name, location, **kwargs)[source]¶ Create a new block storage volume (virtual disk)
Parameters: - size (
int) – Size of volume in gigabytes (required). Find out the possible sizes from the offerings/storage REST interface - name (
str) – Name of the volume to be created (required) - location (
NodeLocation) – Which data center to create a volume in. If empty, it will fail for IBM SmartCloud Enterprise (required) - snapshot (
str) – Not supported for IBM SmartCloud Enterprise - kwargs.format (
str) – Either RAW or EXT3 for IBM SmartCloud Enterprise (optional) - kwargs.offering_id (
str) – The storage offering ID for IBM SmartCloud Enterprise Find this from the REST interface storage/offerings. (optional) - kwargs.source_disk_id (
str) – If cloning a volume, the storage disk to make a copy from (optional) - kwargs.storage_area_id (
str) – The id of the storage availability area to create the volume in (optional) - kwargs.target_location_id (
str) – If cloning a volume, the storage disk to make a copy from (optional)
Returns: The newly created
StorageVolume.Return type: StorageVolume- size (
-
create_volume_snapshot(volume, name=None)¶ Creates a snapshot of the storage volume.
Parameters: - volume (
VolumeSnapshot) – The StorageVolume to create a VolumeSnapshot from - name (str) – Name of created snapshot (optional)
Return type: VolumeSnapshot- volume (
-
delete_image(node_image)¶ Deletes a node image from a provider.
Parameters: node_image ( NodeImage) – Node image object.Returns: Trueif delete_image was successful,Falseotherwise.Return type: bool
-
delete_key_pair(key_pair)¶ Delete an existing key pair.
Parameters: key_pair ( KeyPair) – Key pair object.
-
deploy_node(**kwargs)¶ Create a new node, and start deployment.
In order to be able to SSH into a created node access credentials are required.
A user can pass either a
NodeAuthPasswordorNodeAuthSSHKeyto theauthargument. If thecreate_nodeimplementation supports that kind if credential (as declared inself.features['create_node']) then it is passed on tocreate_node. Otherwise it is not passed on tocreate_nodeand it is only used for authentication.If the
authparameter is not supplied but the driver declares it supportsgenerates_passwordthen the password returned bycreate_nodewill be used to SSH into the server.Finally, if the
ssh_key_fileis supplied that key will be used to SSH into the server.This function may raise a
DeploymentException, if a create_node call was successful, but there is a later error (like SSH failing or timing out). This exception includes a Node object which you may want to destroy if incomplete deployments are not desirable.>>> from libcloud.compute.drivers.dummy import DummyNodeDriver >>> from libcloud.compute.deployment import ScriptDeployment >>> from libcloud.compute.deployment import MultiStepDeployment >>> from libcloud.compute.base import NodeAuthSSHKey >>> driver = DummyNodeDriver(0) >>> key = NodeAuthSSHKey('...') # read from file >>> script = ScriptDeployment("yum -y install emacs strace tcpdump") >>> msd = MultiStepDeployment([key, script]) >>> def d(): ... try: ... driver.deploy_node(deploy=msd) ... except NotImplementedError: ... print ("not implemented for dummy driver") >>> d() not implemented for dummy driver
Deploy node is typically not overridden in subclasses. The existing implementation should be able to handle most such.
Parameters: - deploy (
Deployment) – Deployment to run once machine is online and available to SSH. - ssh_username (
str) – Optional name of the account which is used when connecting to SSH server (default is root) - ssh_alternate_usernames (
list) – Optional list of ssh usernames to try to connect with if using the default one fails - ssh_port (
int) – Optional SSH server port (default is 22) - ssh_timeout (
float) – Optional SSH connection timeout in seconds (default is 10) - auth (
NodeAuthSSHKeyorNodeAuthPassword) – Initial authentication information for the node (optional) - ssh_key (
strorlistofstr) – A path (or paths) to an SSH private key with which to attempt to authenticate. (optional) - timeout (
int) – How many seconds to wait before timing out. (default is 600) - max_tries (
int) – How many times to retry if a deployment fails before giving up (default is 3) - ssh_interface (
str) – The interface to wait for. Default is ‘public_ips’, other option is ‘private_ips’.
- deploy (
-
destroy_volume(volume)[source]¶ Destroys a storage volume.
Parameters: volume ( StorageVolume) – Volume to be destroyedReturn type: bool
-
destroy_volume_snapshot(snapshot)¶ Destroys a snapshot.
Parameters: snapshot ( VolumeSnapshot) – The snapshot to deleteReturn type: bool
-
detach_volume(node, volume)[source]¶ Detaches a volume from a node.
Parameters: - node (
Node) – Node which should be used - volume (
StorageVolume) – Volume to be detached
Return type: bool- node (
-
ex_allocate_address(location_id, offering_id, vlan_id=None)[source]¶ Allocate a new reserved IP address
Parameters: - location_id (
str) – Target data center - offering_id (
str) – Offering ID for address to create - vlan_id (
str) – ID of target VLAN
Returns: AddressobjectReturn type: Address- location_id (
-
ex_copy_to(image, volume)[source]¶ Copies a node image to a storage volume
Parameters: - image (
NodeImage) – source image to copy - volume (
StorageVolume) – Target storage volume to copy to
Returns: boolThe success of the operationReturn type: bool- image (
-
ex_delete_address(resource_id)[source]¶ Delete a reserved IP address
Parameters: resource_id ( str) – The address to delete (required)Return type: bool
-
ex_destroy_image(image)[source]¶ Destroys an image.
Parameters: image ( NodeImage) – Image to be destroyedReturns: bool
-
ex_list_addresses(resource_id=None)[source]¶ List the reserved IP addresses
Parameters: resource_id ( str) – If this is supplied only a single address will be returned (optional)Return type: listofAddress
-
ex_list_storage_offerings()[source]¶ List the storage center offerings
Return type: listofVolumeOffering
-
ex_wait_storage_state(volume, state='4', wait_period=60, timeout=1200)[source]¶ Block until storage volume state changes to the given value
Parameters: - volume (
StorageVolume) – Storage volume. - state (
int) – The target state to wait for - wait_period (
int) – How many seconds to between each loop iteration (default is 3) - timeout (
int) – How many seconds to wait before timing out (default is 1200)
Return type: StorageVolume- volume (
-
get_image(image_id)¶ Returns a single node image from a provider.
Parameters: image_id ( str) – Node to run the task on.:rtype
NodeImage: :return: NodeImage instance on success.
-
get_key_pair(name)¶ Retrieve a single key pair.
Parameters: name ( str) – Name of the key pair to retrieve.Return type: KeyPair
-
import_key_pair_from_file(name, key_file_path)¶ Import a new public key from string.
Parameters: - name (
str) – Key pair name. - key_file_path (
str) – Path to the public key file.
Return type: KeyPairobject- name (
-
import_key_pair_from_string(name, key_material)¶ Import a new public key from string.
Parameters: - name (
str) – Key pair name. - key_material (
str) – Public key material.
Return type: KeyPairobject- name (
-
list_sizes(location=None)[source]¶ Returns a generic list of sizes. See list_images() for a list of supported sizes for specific images. In particular, you need to have a size that matches the architecture (32-bit vs 64-bit) of the virtual machine image operating system.
@inherits:
NodeDriver.list_sizes
-
list_volume_snapshots(volume)¶ List snapshots for a storage volume.
Return type: listofVolumeSnapshot
-
wait_until_running(nodes, wait_period=3, timeout=600, ssh_interface='public_ips', force_ipv4=True, ex_list_nodes_kwargs=None)¶ Block until the provided nodes are considered running.
Node is considered running when it’s state is “running” and when it has at least one IP address assigned.
Parameters: - nodes (
listofNode) – List of nodes to wait for. - wait_period (
int) – How many seconds to wait between each loop iteration. (default is 3) - timeout (
int) – How many seconds to wait before giving up. (default is 600) - ssh_interface (
str) – Which attribute on the node to use to obtain an IP address. Valid options: public_ips, private_ips. Default is public_ips. - force_ipv4 (
bool) – Ignore IPv6 addresses (default is True). - ex_list_nodes_kwargs (
dict) – Optional driver-specific keyword arguments which are passed to thelist_nodesmethod.
Returns: [(Node, ip_addresses)]list of tuple of Node instance and list of ip_address on success.Return type: listoftuple- nodes (
-