9. APIs code

9.1. Command Specifications

9.1.1. astakos

Features: user, project, quota, resource, commission, endpoint, service

9.1.2. cyclades

Features server, flavor

9.1.3. pithos

Features file, container, sharer, group

9.1.4. image

Features (image, imagecompute)

9.1.5. network

Features network, port, subnet, ip

9.1.6. Kamaki commands

9.1.6.1. config

9.1.7. errors

9.2. The clients API

9.2.1. compute

class kamaki.clients.compute.rest_api.ComputeRestClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.Client

flavors_get(flavor_id='', detail=False, changes_since=None, minDisk=None, minRam=None, marker=None, limit=None, success=200, **kwargs)[source]

GET endpoint_url[/flavor_id][/command]

Parameters:
  • flavor_id – ignored if detail
  • detail – (bool)

— Parameters —

Parameters:
  • changes_since – when the flavor last changed
  • minDisk – minimum disk space in GB filter
  • minRam – minimum RAM filter
  • marker – UUID of the flavor at which to set a marker
  • limit – limit the number of returned values
Returns:

request response

floating_ip_pools_get(success=200, **kwargs)[source]
floating_ips_delete(ip='', success=204, **kwargs)[source]
floating_ips_get(ip='', success=200, **kwargs)[source]
floating_ips_post(json_data, ip='', success=200, **kwargs)[source]
images_delete(image_id='', success=204, **kwargs)[source]

DEL ETE endpoint_url/images/<image_id>

Returns:request response
images_get(image_id='', detail=False, changes_since=None, server_name=None, name=None, status=None, marker=None, limit=None, type=None, success=200, **kwargs)[source]

GET endpoint_url[/image_id][/command]

Parameters:
  • image_id – (str) ignored if detail
  • detail – (bool)

— Parameters — :param changes_since: when the image last changed status

Parameters:
  • server_name – Name of the server in URL format
  • name – Name of the image
  • status – Status of the image (e.g. filter on “ACTIVE”)
  • marker – UUID of the image at which you want to set a marker
  • limit – Integer value for the limit of values to return
  • type – Type of image (e.g. BASE, SERVER, or ALL)
Returns:

request response

images_metadata_delete(image_id, key, success=204, **kwargs)[source]

DEL ETE endpoint_url/images/<image_id>/metadata/key

Returns:request response
images_metadata_get(image_id, key=None, success=200, **kwargs)[source]

GET endpoint_url/<image_id>/metadata[/key]

Returns:request response
images_metadata_post(image_id, json_data=None, success=201, **kwargs)[source]

POST endpoint_url/images/<image_id>/metadata

Returns:request response
images_metadata_put(image_id, key=None, json_data=None, success=201, **kwargs)[source]

PUT endpoint_url/images/<image_id>/metadata

Returns:request response
limits_get(success=200, **kwargs)[source]

GET endpoint_url/limits

Parameters:success – success code or list or tupple of accepted success codes. if server response code is not in this list, a ClientError raises
Returns:request response
servers_action_post(server_id, json_data=None, success=202, **kwargs)[source]

POST endpoint_url/servers/<server_id>/action

Returns:request response
servers_delete(server_id, success=204, **kwargs)[source]

DEL ETE endpoint_url/servers/<server_id>

Parameters:
  • json_data – a json-formated dict that will be send as data
  • success – success code (iterable of) codes
Raises ClientError:
 

if returned code not in success list

Returns:

request response

servers_get(server_id='', detail=False, changes_since=None, image=None, flavor=None, name=None, marker=None, limit=None, status=None, host=None, success=200, **kwargs)[source]

GET endpoint_url/servers/[‘detail’ | <server_id>]

Parameters:
  • server_id – (int or int str) ignored if detail
  • detail – (boolean)
  • changes-since – A time/date stamp for when the server last changed status
  • image – Name of the image in URL format
  • flavor – Name of the flavor in URL format
  • name – Name of the server as a string
  • marker – UUID of the server at which you want to set a marker
  • limit – (int) limit of values to return
  • status – Status of the server (e.g. filter on “ACTIVE”)
  • host – Name of the host as a string
Returns:

request response

servers_ips_get(server_id, network_id=None, changes_since=None, success=(304, 200), **kwargs)[source]

GET endpoint_url/servers/<server_id>/ips[/network_id]

Parameters:changes_since – time/date stamp in UNIX/epoch time. Checks for changes since a previous request.
Returns:request response
servers_metadata_delete(server_id, key, success=204, **kwargs)[source]

DEL ETE endpoint_url/servers/<server_id>/metadata[/key]

Returns:request response
servers_metadata_get(server_id, key=None, success=200, **kwargs)[source]

GET endpoint_url/servers/<server_id>/metadata[/key]

Returns:request response
servers_metadata_post(server_id, json_data=None, success=202, **kwargs)[source]

POST endpoint_url/servers/<server_id>/metadata

Returns:request response
servers_metadata_put(server_id, key=None, json_data=None, success=204, **kwargs)[source]

PUT endpoint_url/servers/<server_id>/metadata[/key]

Returns:request response
servers_post(security_group=None, user_data=None, availability_zone=None, json_data=None, success=202, **kwargs)[source]

POST endpoint_url/servers

Parameters:
  • json_data – a json-formated dict that will be send as data
  • security_group – (str)
  • user_data – Use to pass configuration information or scripts upon launch. Must be Base64 encoded.
  • availability_zone – (str)
Returns:

request response

servers_put(server_id, server_name=None, json_data=None, success=204, **kwargs)[source]

PUT endpoint_url/servers/<server_id>

Parameters:
  • json_data – a json-formated dict that will be send as data
  • success – success code (iterable of) codes
Raises ClientError:
 

if returned code not in success list

Returns:

request response

service_type = 'compute'
class kamaki.clients.compute.ComputeClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.compute.rest_api.ComputeRestClient

OpenStack Compute API 1.1 client

alloc_floating_ip(tenant_id, pool=None)[source]
Parameters:
  • tenant_id – (str)
  • pool – (str) pool of ips to allocate from
Returns:

(dict) {fixed_ip: . id: . instance_id: . ip: . pool: .}

change_admin_password(server_id, new_password)[source]
Parameters:
  • server_id – (int)
  • new_password – (str)
confirm_resize_server(server_id)[source]

OS

create_server(name, flavor_id, image_id, security_group=None, user_data=None, availability_zone=None, metadata=None, personality=None, networks=None, response_headers={'location': None})[source]

Submit request to create a new server

Parameters:
  • name – (str)
  • flavor_id – integer id denoting a preset hardware configuration
  • image_id – (str) id of the image of the virtual server
  • metadata – (dict) vm metadata
  • personality – a list of (file path, file contents) tuples, describing files to be injected into virtual server upon creation
  • networks – (list of dicts) Networks to connect to, list this: [ {“uuid”: <network_uuid>}, {“uuid”: <network_uuid>, “fixed_ip”: address}, {“port”: <port_id>}, ...] ATTENTION: Empty list is different to None.
Returns:

a dict with the new virtual server details

Raises ClientError:
 

wraps request errors

create_server_image(server_id, image_name, **metadata)[source]

OpenStack method for taking snapshots

create_server_metadata(server_id, key, val)[source]
delete_floating_ip(tenant_id, fip_id=None)[source]
Parameters:
  • tenant_id – (str)
  • fip_id – (str) floating ip id (if None, all ips are deleted)
Returns:

(dict) request headers

delete_image(image_id)[source]
Parameters:image_id – (str)
delete_image_metadata(image_id, key)[source]
Parameters:
  • image_id – (str)
  • key – (str) metadatum key
Returns:

(dict) response headers

delete_server(server_id)[source]

Submit a deletion request for a server specified by id

Parameters:server_id – integer (str or int)
Returns:(dict) response headers
delete_server_metadata(server_id, key)[source]
get_flavor_details(flavor_id)[source]
get_floating_ip(tenant_id, fip_id=None)[source]
Parameters:
  • tenant_id – (str)
  • fip_id – (str) floating ip id (if None, all ips are returned)
Returns:

(list) [ {fixed_ip: ..., id: ..., instance_id: ..., ip: ..., pool: ...}, ... ]

get_floating_ip_pools(tenant_id)[source]
Parameters:tenant_id – (str)
Returns:(dict) {floating_ip_pools:[{name: ...}, ...]}
get_floating_ips(tenant_id)[source]
Parameters:tenant_id – (str)
Returns:(dict) {floating_ips:[ {fixed_ip: ..., id: ..., instance_id: ..., ip: ..., pool: ...}, ... ]}
get_image_details(image_id, **kwargs)[source]
Returns:dict
Raises ClientError:
 404 if image not available
get_image_metadata(image_id, key='', response_headers={'next': None, 'previous': None})[source]
Parameters:
  • image_id – (str)
  • key – (str) the metadatum key

:returns (dict) metadata if key not set, specific metadatum otherwise

get_server_details(server_id, changes_since=None, image=None, flavor=None, name=None, marker=None, limit=None, status=None, host=None, response_headers={'next': None, 'previous': None}, **kwargs)[source]

Return detailed info for a server

Parameters:server_id – integer (int or str)
Returns:dict with server details
get_server_metadata(server_id, key='', response_headers={'next': None, 'previous': None})[source]
get_server_network_nics(server_id, network_id, changes_since=None)[source]
get_server_nics(server_id, changes_since=None)[source]
list_flavors(detail=False, response_headers={'next': None, 'previous': None})[source]
list_images(detail=False, response_headers={'previous': None, 'next': None})[source]
list_servers(detail=False, changes_since=None, image=None, flavor=None, name=None, marker=None, limit=None, status=None, host=None, response_headers={'next': None, 'previous': None})[source]
Parameters:
  • detail – if true, append full server details to each item
  • response_headers – (dict) use it to get previous/next responses Keep the existing dict format to actually get the server responses Use it with very long lists or with marker
Returns:

list of server ids and names

reboot_server(server_id, hard=False)[source]
Parameters:
  • server_id – integer (str or int)
  • hard – perform a hard reboot if true, soft reboot otherwise
rebuild_server(server_id, response_headers={'location': None})[source]

OS

resize_server(server_id, flavor_id)[source]
Parameters:
  • server_id – (str)
  • flavor_id – (int)
Returns:

(dict) request headers

revert_resize_server(server_id)[source]

OS

shutdown_server(server_id)[source]

OS Extentions

start_server(server_id)[source]

OS Extentions

update_image_metadata(image_id, response_headers={'next': None, 'previous': None}, **metadata)[source]
Parameters:
  • image_id – (str)
  • metadata – dict
Returns:

updated metadata

update_server_metadata(server_id, response_headers={'next': None, 'previous': None}, **metadata)[source]
update_server_name(server_id, new_name)[source]

Update the name of the server as reported by the API (does not modify the hostname used inside the virtual server)

Parameters:
  • server_id – integer (str or int)
  • new_name – (str)
Returns:

(dict) response headers

9.2.2. cyclades

class kamaki.clients.cyclades.rest_api.CycladesBlockStorageRestClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.blockstorage.BlockStorageClient

Synnefo Cyclades Block Storage REST API Client

volumes_action_post(volume_id, json_data, success=200, **kwargs)[source]
volumes_post(size, display_name, server_id=None, display_description=None, snapshot_id=None, imageRef=None, volume_type=None, metadata=None, project=None, success=202, **kwargs)[source]
class kamaki.clients.cyclades.rest_api.CycladesComputeRestClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.compute.ComputeClient

Synnefo Cyclades REST API Client

servers_diagnostics_get(server_id, **kwargs)[source]

GET endpoint_url/servers/<server_id>/diagnostics

servers_stats_get(server_id, **kwargs)[source]

GET endpoint_url/servers/<server_id>/stats

volume_attachment_delete(server_id, attachment_id, **kwargs)[source]
volume_attachment_get(server_id, attachment_id=None, **kwargs)[source]
volume_attachment_post(server_id, volume_id, **kwargs)[source]
kamaki.clients.cyclades.rest_api.CycladesRestClient

alias of CycladesComputeRestClient

class kamaki.clients.cyclades.CycladesBlockStorageClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.cyclades.rest_api.CycladesBlockStorageRestClient

Cyclades Block Storage REST API Client

create_snapshot(volume_id, display_name=None, display_description=None)[source]
Returns:(dict) new snapshots’ details
create_volume(size, display_name, server_id=None, display_description=None, snapshot_id=None, imageRef=None, volume_type=None, metadata=None, project=None)[source]
Returns:(dict) new volumes’ details
reassign_volume(volume_id, project)[source]
kamaki.clients.cyclades.CycladesClient

alias of CycladesComputeClient

class kamaki.clients.cyclades.CycladesComputeClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.cyclades.rest_api.CycladesComputeRestClient, kamaki.clients.Waiter

Synnefo Cyclades Compute API client

CONSOLE_TYPES = ('vnc', 'vnc-ws', 'vnc-wss')
attach_volume(server_id, volume_id)[source]

Attach volume on server :param server_id: (str) :volume_id: (str) :returns: (dict) information on attachment (contains volumeId)

create_server(name, flavor_id, image_id, metadata=None, personality=None, networks=None, project_id=None, response_headers={'location': None})[source]

Submit request to create a new server

Parameters:
  • name – (str)
  • flavor_id – integer id denoting a preset hardware configuration
  • image_id – (str) id denoting the OS image to run on virt. server
  • metadata – (dict) vm metadata updated by os/users image metadata
  • personality – a list of (file path, file contents) tuples, describing files to be injected into virtual server upon creation
  • networks – (list of dicts) Networks to connect to, list this: “networks”: [ {“uuid”: <network_uuid>}, {“uuid”: <network_uuid>, “fixed_ip”: address}, {“port”: <port_id>}, ...] ATTENTION: Empty list is different to None. None means ‘apply the default server policy’, empty list means ‘do not attach a network’
  • project_id – the project where to assign the server
Returns:

a dict with the new virtual server details

Raises ClientError:
 

wraps request errors

delete_volume_attachment(server_id, attachment_id)[source]

Delete a volume attachment. The volume will not be deleted. :param server_id: (str) :param attachment_id: (str) :returns: (dict) HTTP response headers

detach_volume(server_id, volume_id)[source]

Remove volume attachment(s) for this volume and server This is not an atomic operation. Use “delete_volume_attachment” for an atomic operation with similar semantics. :param server_id: (str) :param volume_id: (str) :returns: (list) the deleted attachments

get_server_console(server_id, console_type='vnc')[source]
Parameters:
  • server_id – integer (str or int)
  • console_type – str (vnc, vnc-ws, vnc-wss, default: vnc)
Returns:

(dict) info to set a VNC connection to virtual server

get_server_diagnostics(server_id)[source]
Parameters:server_id – integer (str or int)
Returns:(list)
get_server_stats(server_id)[source]
Parameters:server_id – integer (str or int)
Returns:(dict) auto-generated graphs of statistics (urls)
get_server_status(server_id)[source]

Deprecated - will be removed in version 0.15 :returns: (current status, progress percentile if available)

get_volume_attachment(server_id, attachment_id)[source]
Parameters:
  • server_id – (str)
  • attachment_id – (str)
Returns:

(dict) details on the volume attachment

list_volume_attachments(server_id)[source]
Parameters:server_id – (str)
Returns:(list) all volume attachments for this server
reassign_server(server_id, project)[source]
set_firewall_profile(server_id, profile, port_id)[source]

Set the firewall profile for the public interface of a server :param server_id: integer (str or int) :param profile: (str) ENABLED | DISABLED | PROTECTED :param port_id: (str) This port must connect to a public network :returns: (dict) response headers

shutdown_server(server_id)[source]

Submit a shutdown request

Parameters:server_id – integer (str or int)
Returns:(dict) response headers
start_server(server_id)[source]

Submit a startup request

Parameters:server_id – integer (str or int)
Returns:(dict) response headers
wait_server(server_id, current_status='BUILD', delay=1, max_wait=100, wait_cb=None)

Wait for server WHILE its status is current_status :param server_id: integer (str or int) :param current_status: (str) BUILD|ACTIVE|STOPPED|DELETED|REBOOT :param delay: time interval between retries :max_wait: (int) timeout in secconds :param wait_cb: if set a progressbar is used to show progress :returns: (str) the new mode if succesfull, (bool) False if timed out

wait_server_until(server_id, target_status='ACTIVE', delay=1, max_wait=100, wait_cb=None)[source]

Wait for server WHILE its status is target_status :param server_id: integer (str or int) :param target_status: (str) BUILD|ACTIVE|STOPPED|DELETED|REBOOT :param delay: time interval between retries :max_wait: (int) timeout in secconds :param wait_cb: if set a progressbar is used to show progress :returns: (str) the new mode if succesfull, (bool) False if timed out

wait_server_while(server_id, current_status='BUILD', delay=1, max_wait=100, wait_cb=None)[source]

Wait for server WHILE its status is current_status :param server_id: integer (str or int) :param current_status: (str) BUILD|ACTIVE|STOPPED|DELETED|REBOOT :param delay: time interval between retries :max_wait: (int) timeout in secconds :param wait_cb: if set a progressbar is used to show progress :returns: (str) the new mode if succesfull, (bool) False if timed out

class kamaki.clients.cyclades.CycladesNetworkClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.network.NetworkClient

Cyclades Network API extentions

create_floatingip(floating_network_id=None, floating_ip_address='', project_id=None)[source]
Parameters:
  • floating_network_id – if not provided, it is assigned automatically by the service
  • floating_ip_address – only if the IP is availabel in network pool
  • project_id – specific project to get resource quotas from
create_network(type, name=None, shared=None, project_id=None)[source]
create_port(network_id, device_id=None, security_groups=None, name=None, fixed_ips=None)[source]
Parameters:fixed_ips – (list of dicts) [{“ip_address”: IPv4}, ...]
list_networks(detail=None)[source]
list_ports(detail=None)[source]
network_types = ('CUSTOM', 'MAC_FILTERED', 'IP_LESS_ROUTED', 'PHYSICAL_VLAN')
reassign_floating_ip(floating_network_id, project_id)[source]

Change the project where this ip is charged

reassign_network(network_id, project_id, **kwargs)[source]

POST endpoint_url/networks/<network_id>/action

Returns:request response

9.2.3. storage

class kamaki.clients.storage.StorageClient(endpoint_url, token, account=None, container=None)[source]

Bases: kamaki.clients.Client

OpenStack Object Storage API 1.0 client

copy_object(src_container, src_object, dst_container, dst_object=False)[source]

Copy an objects from src_contaier:src_object to dst_container[:dst_object]

Parameters:
  • src_container – (str)
  • src_object – (str)
  • dst_container – (str)
  • dst_object – (str)
create_container(container)[source]
Parameters:container – (str)
Raises ClientError:
 202 Container already exists
create_directory(obj)[source]
Parameters:obj – (str) directory-object name
Returns:(dict) request headers
create_object(obj, content_type='application/octet-stream', content_length=0)[source]
Parameters:
  • obj – (str) directory-object name
  • content_type – (str) explicitly set content_type
  • content_length – (int) explicitly set content length
Returns:

(dict) object creation headers

del_account_meta(metakey)[source]
Parameters:metakey – (str) metadatum key
del_object_meta(obj, metakey)[source]
Parameters:
  • obj – (str)
  • metakey – (str) the metadatum key
delete_container(container)[source]
Parameters:

container – (str)

Raises:
  • ClientError – 404 Container does not exist
  • ClientError – 409 Container not empty
delete_object(obj)[source]
Parameters:obj – (str)
Raises ClientError:
 404 Object not found
get_account_info()[source]
Returns:(dict)
get_container_info(container)[source]
Parameters:container – (str)
Returns:(dict)
Raises ClientError:
 404 Container does not exist
get_object_info(obj)[source]
Parameters:obj – (str)
Returns:(dict)
get_object_meta(obj)[source]
Parameters:obj – (str)
Returns:(dict)
list_containers()[source]
Returns:(dict)
list_objects(limit=None, marker=None, prefix=None, format=None, delimiter=None, path=None)[source]
Parameters:
  • limit – (integer) The amount of results requested
  • marker – (string) Return containers with name lexicographically after marker
  • prefix – (string) Return objects starting with prefix
  • format – (string) reply format can be json or xml (default:json)
  • delimiter – (string) Return objects up to the delimiter
  • path – (string) assume prefix = path and delimiter = / (overwrites prefix and delimiter)
Returns:

(dict)

Raises ClientError:
 

404 Invalid account

list_objects_in_path(path_prefix)[source]
Parameters:path_prefix – (str)
Raises ClientError:
 404 Invalid account
Returns:(dict)
move_object(src_container, src_object, dst_container, dst_object=False)[source]

Move an objects from src_contaier:src_object to dst_container[:dst_object]

Parameters:
  • src_container – (str)
  • src_object – (str)
  • dst_container – (str)
  • dst_object – (str)
replace_account_meta(metapairs)[source]
Parameters:metapais – (dict) key:val metadata pairs
replace_object_meta(metapairs)[source]
Parameters:metapairs – (dict) key:val metadata
upload_object(obj, f, size=None)[source]

A simple (naive) implementation.

Parameters:
  • obj – (str)
  • f – an open for reading file descriptor
  • size – (int) number of bytes to upload

9.2.4. pithos

class kamaki.clients.pithos.rest_api.PithosRestClient(endpoint_url, token, account=None, container=None)[source]

Bases: kamaki.clients.storage.StorageClient

account_get(limit=None, marker=None, format='json', show_only_shared=False, public=False, until=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ GET at account level

— request parameters —

Parameters:
  • limit – (integer) The amount of results requested (server will use default value if None)
  • marker – string Return containers with name lexicographically after marker
  • format – (string) reply format can be json or xml (default: json)
  • shared – (bool) If true, only shared containers will be included in results
  • until – (string) optional timestamp

— request headers —

Parameters:
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not changed since provided timestamp
Returns:

ConnectionResponse

account_head(until=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ HEAD at account level

— request parameters —

Parameters:until – (string) optional timestamp

— request headers —

Parameters:
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not change since provided timestamp
Returns:

ConnectionResponse

account_post(update=True, groups={}, metadata=None, quota=None, versioning=None, *args, **kwargs)[source]

Full Pithos+ POST at account level

— request parameters —

Parameters:update – (bool) if True, Do not replace metadata/groups

— request headers —

Parameters:
  • groups – (dict) Optional user defined groups in the form { ‘group1’:[‘user1’, ‘user2’, ...], ‘group2’:[‘userA’, ‘userB’, ...], }
  • metadata – (dict) Optional user defined metadata in the form { ‘name1’: ‘value1’, ‘name2’: ‘value2’, ... }
  • quota – (integer) If supported, sets the Account quota
  • versioning – (string) If supported, sets the Account versioning to ‘auto’ or some other supported versioning string
Returns:

ConnectionResponse

container_delete(until=None, delimiter=None, *args, **kwargs)[source]

Full Pithos+ DELETE at container level

— request parameters —

Parameters:until – (timestamp string) if defined, container is purged up to that time
Returns:ConnectionResponse
container_get(limit=None, marker=None, prefix=None, delimiter=None, path=None, format='json', meta=[], show_only_shared=False, public=False, until=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ GET at container level

— request parameters —

Parameters:
  • limit – (integer) The amount of results requested (server will use default value if None)
  • marker – (string) Return containers with name lexicographically after marker
  • prefix – (string) Return objects starting with prefix
  • delimiter – (string) Return objects up to the delimiter
  • path – (string) assume prefix = path and delimiter = / (overwrites prefix and delimiter)
  • format – (string) reply format can be json or xml (default:json)
  • meta – (list) Return objects that satisfy the key queries in the specified comma separated list (use <key>, !<key> for existence queries, <key><op><value> for value queries, where <op> can be one of =, !=, <=, >=, <, >)
  • show_only_shared – (bool) If true, only shared containers will be included in results
  • until – (string) optional timestamp

— request headers —

Parameters:
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not changed since provided timestamp
Returns:

ConnectionResponse

container_head(until=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ HEAD at container level

— request params —

Parameters:until – (string) optional timestamp

— request headers —

Parameters:
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not changed since provided timestamp
Returns:

ConnectionResponse

container_post(update=True, format='json', quota=None, versioning=None, project_id=None, metadata=None, content_type=None, content_length=None, transfer_encoding=None, *args, **kwargs)[source]

Full Pithos+ POST at container level

— request params —

Parameters:
  • update – (bool) if True, Do not replace metadata/groups
  • format – (string) json (default) or xml

— request headers —

Parameters:
  • quota – (integer) Size limit in KB
  • versioning – (string) ‘auto’ or other string supported by server
  • metadata – (dict) Optional user defined metadata in the form { ‘name1’: ‘value1’, ‘name2’: ‘value2’, ... }
  • content_type – (string) set a custom content type
  • content_length – (string) set a custrom content length
  • transfer_encoding – (string) set a custom transfer encoding
Returns:

ConnectionResponse

container_put(quota=None, versioning=None, project_id=None, metadata=None, *args, **kwargs)[source]

Full Pithos+ PUT at container level

— request headers —

Parameters:
  • quota – (integer) Size limit in KB
  • versioning – (string) ‘auto’ or other string supported by server
  • metadata – (dict) Optional user defined metadata in the form { ‘name1’: ‘value1’, ‘name2’: ‘value2’, ... }
Returns:

ConnectionResponse

object_copy(obj, destination, format='json', ignore_content_type=False, if_etag_match=None, if_etag_not_match=None, destination_account=None, content_type=None, content_encoding=None, content_disposition=None, source_version=None, permissions=None, public=None, metadata=None, *args, **kwargs)[source]

Full Pithos+ COPY at object level

— request parameters —

Parameters:
  • format – (string) json (default) or xml
  • ignore_content_type – (bool) Ignore the supplied Content-Type

— request headers —

Parameters:
  • if_etag_match – (string) if provided, copy only results with etag matching with this
  • if_etag_not_match – (string) if provided, copy only results with etag not matching with this
  • destination – (string) The destination path in the form /<container>/<object>
  • destination_account – (string) The destination account to copy to
  • content_type – (string) The MIME content type of the object
  • content_encoding – (string) The encoding of the object
  • content_disposition – (string) Object resentation style
  • source_version – (string) The source version to copy from
  • permissions – (dict) Object permissions in the form (all fields are optional) { ‘read’:[user1, group1, user2, ...], ‘write’:[‘user3, group2, group3, ...] }
  • public – (bool) If true, Object is published, False, unpublished
  • metadata – (dict) Optional user defined metadata in the form {‘meta-key-1’:’meta-value-1’, ‘meta-key-2’:’meta-value-2’, ...} Metadata are appended to the source metadata. In case of same keys, they replace the old metadata
Returns:

ConnectionResponse

object_delete(object, until=None, delimiter=None, *args, **kwargs)[source]

Full Pithos+ DELETE at object level

— request parameters —

Parameters:until – (string) Optional timestamp
Returns:ConnectionResponse
object_get(obj, format='json', hashmap=False, version=None, data_range=None, if_range=False, if_etag_match=None, if_etag_not_match=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ GET at object level

— request parameters —

Parameters:
  • format – (string) json (default) or xml
  • hashmap – (bool) Optional request for hashmap
  • version – (string) optional version identified

— request headers —

Parameters:
  • data_range – (string) Optional range of data to retrieve
  • if_range – (bool)
  • if_etag_match – (string) if provided, return only results with etag matching with this
  • if_etag_not_match – (string) if provided, return only results with etag not matching with this
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not changed since provided timestamp
Returns:

ConnectionResponse

object_head(obj, version=None, if_etag_match=None, if_etag_not_match=None, if_modified_since=None, if_unmodified_since=None, *args, **kwargs)[source]

Full Pithos+ HEAD at object level

— request parameters —

Parameters:version – (string) optional version identified

— request headers —

Parameters:
  • if_etag_match – (string) if provided, return only results with etag matching with this
  • if_etag_not_match – (string) if provided, return only results with etag not matching with this
  • if_modified_since – (string) Retrieve if account has changed since provided timestamp
  • if_unmodified_since – (string) Retrieve if account has not changed since provided timestamp
Returns:

ConnectionResponse

object_move(object, format='json', ignore_content_type=False, if_etag_match=None, if_etag_not_match=None, destination=None, destination_account=None, content_type=None, content_encoding=None, content_disposition=None, permissions={}, public=None, metadata={}, *args, **kwargs)[source]

Full Pithos+ COPY at object level

— request parameters —

Parameters:
  • format – (string) json (default) or xml
  • ignore_content_type – (bool) Ignore the supplied Content-Type

— request headers —

Parameters:
  • if_etag_match – (string) if provided, return only results with etag matching with this
  • if_etag_not_match – (string) if provided, return only results with etag not matching with this
  • destination – (string) The destination path in the form /<container>/<object>
  • destination_account – (string) The destination account to copy to
  • content_type – (string) The MIME content type of the object
  • content_encoding – (string) The encoding of the object
  • content_disposition – (string) Object presentation style
  • source_version – (string) The source version to copy from
  • permissions – (dict) Object permissions in the form (all fields are optional) { ‘read’:[user1, group1, user2, ...], ‘write’:[‘user3, group2, group3, ...] }
  • public – (bool) If true, Object is published, False, unpublished
  • metadata – (dict) Optional user defined metadata in the form {‘meta-key-1’:’meta-value-1’, ‘meta-key-2’:’meta-value-2’, ...}
Returns:

ConnectionResponse

object_post(obj, format='json', update=True, if_etag_match=None, if_etag_not_match=None, content_length=None, content_type=None, content_range=None, transfer_encoding=None, content_encoding=None, content_disposition=None, source_object=None, source_account=None, source_version=None, object_bytes=None, manifest=None, permissions={}, public=None, metadata={}, *args, **kwargs)[source]

Full Pithos+ POST at object level

— request parameters —

Parameters:
  • format – (string) json (default) or xml
  • update – (bool) Do not replace metadata

— request headers —

Parameters:
  • if_etag_match – (string) if provided, return only results with etag matching with this
  • if_etag_not_match – (string) if provided, return only results with etag not matching with this
  • content_length – (string) The size of the data written
  • content_type – (string) The MIME content type of the object
  • content_range – (string) The range of data supplied
  • transfer_encoding – (string) Set to chunked to specify incremental uploading (if used, Content-Length is ignored)
  • content_encoding – (string) The encoding of the object
  • content_disposition – (string) Object presentation style
  • source_object – (string) Update with data from the object at path /<container>/<object>
  • source_account – (string) The source account to update from
  • source_version – (string) The source version to copy from
  • object_bytes – (integer) The updated objects final size
  • manifest – (string) Object parts prefix as /<container>/<object>
  • permissions – (dict) Object permissions in the form (all fields are optional) { ‘read’:[user1, group1, user2, ...], ‘write’:[‘user3, group2, group3, ...] }
  • public – (bool) If true, Object is published, False, unpublished
  • metadata – (dict) Optional user defined metadata in the form {‘meta-key-1’:’meta-value-1’, ‘meta-key-2’:’meta-value-2’, ...}
Returns:

ConnectionResponse

object_put(obj, format='json', hashmap=False, delimiter=None, if_etag_match=None, if_etag_not_match=None, etag=None, content_length=None, content_type=None, transfer_encoding=None, copy_from=None, move_from=None, source_account=None, source_version=None, content_encoding=None, content_disposition=None, manifest=None, permissions=None, public=None, metadata=None, *args, **kwargs)[source]

Full Pithos+ PUT at object level

— request parameters —

Parameters:
  • format – (string) json (default) or xml
  • hashmap – (bool) Optional hashmap provided instead of data

— request headers —

Parameters:
  • if_etag_match – (string) if provided, return only results with etag matching with this
  • if_etag_not_match – (string) if provided, return only results with etag not matching with this
  • etag – (string) The MD5 hash of the object (optional to check written data)
  • content_length – (integer) The size of the data written
  • content_type – (string) The MIME content type of the object
  • transfer_encoding – (string) Set to chunked to specify incremental uploading (if used, Content-Length is ignored)
  • copy_from – (string) The source path in the form /<container>/<object>
  • move_from – (string) The source path in the form /<container>/<object>
  • source_account – (string) The source account to copy/move from
  • source_version – (string) The source version to copy from
  • conent_encoding – (string) The encoding of the object
  • content_disposition – (string) Presentation style of the object
  • manifest – (string) Object parts prefix in /<container>/<object> form
  • permissions – (dict) Object permissions in the form (all fields are optional) { ‘read’:[user1, group1, user2, ...], ‘write’:[‘user3, group2, group3, ...] }
  • public – (bool) If true, Object is published, False, unpublished
  • metadata – (dict) Optional user defined metadata in the form {‘meta-key-1’:’meta-value-1’, ‘meta-key-2’:’meta-value-2’, ...}
Returns:

ConnectionResponse

service_type = 'object-store'
class kamaki.clients.pithos.PithosClient(endpoint_url, token, account=None, container=None)[source]

Bases: kamaki.clients.pithos.rest_api.PithosRestClient

Synnefo Pithos+ API client

append_object(obj, source_file, upload_cb=None)[source]
Parameters:
  • obj – (str) remote object path
  • source_file – open file descriptor
  • upload_db – progress.bar for uploading
copy_object(src_container, src_object, dst_container, dst_object=None, source_version=None, source_account=None, public=False, content_type=None, delimiter=None)[source]
Parameters:
  • src_container – (str) source container
  • src_object – (str) source object path
  • dst_container – (str) destination container
  • dst_object – (str) destination object path
  • source_version – (str) source object version
  • source_account – (str) account to copy from
  • public – (bool)
  • content_type – (str)
  • delimiter – (str)
Returns:

(dict) response headers

create_container(container=None, sizelimit=None, versioning=None, metadata=None, project_id=None, **kwargs)[source]
Parameters:
  • container – (str) if not given, self.container is used instead
  • sizelimit – (int) container total size limit in bytes
  • versioning – (str) can be auto or whatever supported by server
  • metadata – (dict) Custom user-defined metadata of the form { ‘name1’: ‘value1’, ‘name2’: ‘value2’, ... }
Returns:

(dict) response headers

create_object_by_manifestation(obj, etag=None, content_encoding=None, content_disposition=None, content_type=None, sharing=None, public=None)[source]
Parameters:
  • obj – (str) remote object path
  • etag – (str)
  • content_encoding – (str)
  • content_disposition – (str)
  • content_type – (str)
  • sharing – {‘read’:[user and/or grp names], ‘write’:[usr and/or grp names]}
  • public – (bool)
Returns:

(dict) created object metadata

del_account_group(group)[source]
Parameters:group – (str)
del_account_meta(metakey)[source]
Parameters:metakey – (str) metadatum key
del_container(until=None, delimiter=None)[source]
Parameters:
  • until – (str) formated date
  • delimiter – (str) with / empty container
Raises:
  • ClientError – 404 Container does not exist
  • ClientError – 409 Container is not empty
del_container_meta(metakey)[source]
Parameters:metakey – (str) metadatum key
Returns:(dict) response headers
del_object(obj, until=None, delimiter=None)[source]
Parameters:
  • obj – (str) remote object path
  • until – (str) formated date
  • delimiter – (str)
del_object_meta(obj, metakey)[source]
Parameters:
  • obj – (str) remote object path
  • metakey – (str) metadatum key
del_object_sharing(obj)[source]
Parameters:obj – (str) remote object path
download_object(obj, dst, download_cb=None, version=None, resume=False, range_str=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None, headers={})[source]

Download an object (multiple connections, random blocks)

Parameters:
  • obj – (str) remote object path
  • dst – open file descriptor (wb+)
  • download_cb – optional progress.bar object for downloading
  • version – (str) file version
  • resume – (bool) if set, preserve already downloaded file parts
  • range_str – (str) from, to are file positions (int) in bytes
  • if_match – (str)
  • if_none_match – (str)
  • if_modified_since – (str) formated date
  • if_unmodified_since – (str) formated date
  • headers – (dict) placeholder to gather object headers
download_to_string(obj, download_cb=None, version=None, range_str=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None, remote_block_info=None, hashmap=None, headers={})[source]

Download an object to a string (multiple connections). This method uses threads for http requests, but stores all content in memory.

Parameters:
  • obj – (str) remote object path
  • download_cb – optional progress.bar object for downloading
  • version – (str) file version
  • range_str – (str) from, to are file positions (int) in bytes
  • if_match – (str)
  • if_none_match – (str)
  • if_modified_since – (str) formated date
  • if_unmodified_since – (str) formated date
  • remote_block_info – (tuple) blocksize, blockhas, total_size and hash_list
  • hashmap – (dict) the remote object hashmap, if it is available e.g., from another call. Used for minimizing HEAD container requests
  • headers – (dict) a placeholder dict to gather object headers
Returns:

(str) the whole object contents

get_account_group()[source]
Returns:(dict)
get_account_info(until=None)[source]
Parameters:until – (str) formated date
Returns:(dict)
get_account_meta(until=None)[source]
Parameters:until – (str) formated date
Returns:(dict)
get_account_quota()[source]
Returns:(dict)
get_container_info(container=None, until=None)[source]
Parameters:until – (str) formated date
Returns:(dict)
Raises ClientError:
 404 Container not found
get_container_limit(container=None)[source]
Parameters:container – (str)
Returns:(dict)
get_container_meta(until=None)[source]
Parameters:until – (str) formated date
Returns:(dict)
get_container_object_meta(until=None)[source]
Parameters:until – (str) formated date
Returns:(dict)
get_container_versioning(container=None)[source]
Parameters:container – (str)
Returns:(dict)
get_object_hashmap(obj, version=None, if_match=None, if_none_match=None, if_modified_since=None, if_unmodified_since=None, headers={})[source]
Parameters:
  • obj – (str) remote object path
  • if_match – (str)
  • if_none_match – (str)
  • if_modified_since – (str) formated date
  • if_unmodified_since – (str) formated date
Returns:

(list)

get_object_info(obj, version=None)[source]
Parameters:
  • obj – (str) remote object path
  • version – (str)
Returns:

(dict)

get_object_meta(obj, version=None)[source]
Parameters:
  • obj – (str) remote object path
  • version – (str)
Returns:

(dict)

get_object_sharing(obj)[source]
Parameters:obj – (str) remote object path
Returns:(dict)
get_object_versionlist(obj)[source]
Parameters:obj – (str) remote object path
Returns:(list)
get_sharing_accounts(limit=None, marker=None, *args, **kwargs)[source]

Get accounts that share with self.account

Parameters:
  • limit – (str)
  • marker – (str)
Returns:

(dict)

list_containers()[source]
Returns:(dict)
move_object(src_container, src_object, dst_container, dst_object=False, source_account=None, source_version=None, public=False, content_type=None, delimiter=None)[source]
Parameters:
  • src_container – (str) source container
  • src_object – (str) source object path
  • dst_container – (str) destination container
  • dst_object – (str) destination object path
  • source_account – (str) account to move from
  • source_version – (str) source object version
  • public – (bool)
  • content_type – (str)
  • delimiter – (str)
Returns:

(dict) response headers

overwrite_object(obj, start, end, source_file, source_version=None, upload_cb=None)[source]

Overwrite a part of an object from local source file ATTENTION: content_type must always be application/octet-stream

Parameters:
  • obj – (str) remote object path
  • start – (int) position in bytes to start overwriting from
  • end – (int) position in bytes to stop overwriting at
  • source_file – open file descriptor
  • upload_db – progress.bar for uploading
publish_object(obj)[source]
Parameters:obj – (str) remote object path
Returns:(str) access url
purge_container(container=None)[source]

Delete an empty container and destroy associated blocks

reassign_container(project_id)[source]
set_account_group(group, usernames)[source]
Parameters:
  • group – (str)
  • usernames – (list)
set_account_meta(metapairs)[source]
Parameters:metapairs – (dict) {key1:val1, key2:val2, ...}
set_container_limit(limit)[source]
Parameters:limit – (int)
set_container_meta(metapairs)[source]
Parameters:metapairs – (dict) {key1:val1, key2:val2, ...}
set_container_versioning(versioning)[source]
Parameters:versioning – (str)
set_object_meta(obj, metapairs)[source]
Parameters:
  • obj – (str) remote object path
  • metapairs – (dict) {key1:val1, key2:val2, ...}
set_object_sharing(obj, read_permission=False, write_permission=False)[source]

Give read/write permisions to an object.

Parameters:
  • obj – (str) remote object path
  • read_permission – (list - bool) users and user groups that get read permission for this object - False means all previous read permissions will be removed
  • write_permission – (list - bool) of users and user groups to get write permission for this object - False means all previous write permissions will be removed
Returns:

(dict) response headers

stream_down(obj, dst, buffer_blocks=4, **kwargs)[source]
Download obj to dst as a stream. Buffer-sized chunks are downloaded
sequentially, but the blocks of each chunk are downloaded asynchronously, using the download_to_string method
Parameters:
  • obj – (str) the remote object
  • dst – a file descriptor allowing sequential writing
  • buffer_blocks – (int) the size of the buffer in blocks. If it is 1, all blocks will be downloaded sequentially
  • kwargs – (dict) keyword arguments for download_to_string method
truncate_object(obj, upto_bytes)[source]
Parameters:
  • obj – (str) remote object path
  • upto_bytes – max number of bytes to leave on file
Returns:

(dict) response headers

unpublish_object(obj)[source]
Parameters:obj – (str) remote object path
upload_from_string(obj, input_str, hash_cb=None, upload_cb=None, etag=None, if_etag_match=None, if_not_exist=None, content_encoding=None, content_disposition=None, content_type=None, sharing=None, public=None, container_info_cache=None)[source]

Upload an object using multiple connections (threads)

Parameters:
  • obj – (str) remote object path
  • input_str – (str) upload content
  • hash_cb – optional progress.bar object for calculating hashes
  • upload_cb – optional progress.bar object for uploading
  • etag – (str)
  • if_etag_match – (str) Push that value to if-match header at file creation
  • if_not_exist – (bool) If true, the file will be uploaded ONLY if it does not exist remotely, otherwise the operation will fail. Involves the case of an object with the same path is created while the object is being uploaded.
  • content_encoding – (str)
  • content_disposition – (str)
  • content_type – (str)
  • sharing – {‘read’:[user and/or grp names], ‘write’:[usr and/or grp names]}
  • public – (bool)
  • container_info_cache – (dict) if given, avoid redundant calls to server for container info (block size and hash information)
upload_object(obj, f, size=None, hash_cb=None, upload_cb=None, etag=None, if_etag_match=None, if_not_exist=None, content_encoding=None, content_disposition=None, content_type=None, sharing=None, public=None, container_info_cache=None, target_account=None)[source]

Upload an object using multiple connections (threads)

Parameters:
  • obj – (str) remote object path
  • f – open file descriptor (rb)
  • hash_cb – optional progress.bar object for calculating hashes
  • upload_cb – optional progress.bar object for uploading
  • etag – (str)
  • if_etag_match – (str) Push that value to if-match header at file creation
  • if_not_exist – (bool) If true, the file will be uploaded ONLY if it does not exist remotely, otherwise the operation will fail. Involves the case of an object with the same path is created while the object is being uploaded.
  • content_encoding – (str)
  • content_disposition – (str)
  • content_type – (str)
  • sharing – {‘read’:[user and/or grp names], ‘write’:[usr and/or grp names]}
  • public – (bool)
  • container_info_cache – (dict) if given, avoid redundant calls to server for container info (block size and hash information)
  • target_account – (str) the UUID of the account the object will be allocated at, if different to the client account (e.g., when user A uploads something to a location owned by user B)
upload_object_unchunked(obj, f, withHashFile=False, size=None, etag=None, content_encoding=None, content_disposition=None, content_type=None, sharing=None, public=None)[source]
Parameters:
  • obj – (str) remote object path
  • f – open file descriptor
  • withHashFile – (bool)
  • size – (int) size of data to upload
  • etag – (str)
  • content_encoding – (str)
  • content_disposition – (str)
  • content_type – (str)
  • sharing – {‘read’:[user and/or grp names], ‘write’:[usr and/or grp names]}
  • public – (bool)
Returns:

(dict) created object metadata

use_alternative_account(func, *args, **kwargs)[source]

Run method with an alternative account UUID, as long as kwargs contain a non-None “alternative_account” argument

9.2.5. image

class kamaki.clients.image.ImageClient(endpoint_url, token)[source]

Bases: kamaki.clients.Client

Synnefo Plankton API client

add_member(image_id, member)[source]
Parameters:
  • image_id – (str)
  • member – (str) user to allow access to current user’s images
get_meta(image_id)[source]
Parameters:image_id – (string)
Returns:(list) image metadata (key:val)
list_members(image_id)[source]
Parameters:image_id – (str)
Returns:(list) users who can use current user’s images
list_public(detail=False, filters={}, order='')[source]
Parameters:
  • detail – (bool)
  • filters – (dict) request filters
  • order – (str) order listing by field (default is ascending, - for descending)
Returns:

(list) id,name + full image info if detail

list_shared(member)[source]
Parameters:member – (str) sharers account
Returns:(list) images shared by member
register(name, location, params={}, properties={})[source]

Register an image that is uploaded at location

Parameters:
  • name – (str)
  • location – (str or iterable) if iterable, then (user_uuid, container, image_path) else if string pithos://<user_uuid>/<container>/<image object>
  • params – (dict) image metadata (X-Image-Meta) can be id, store, disc_format, container_format, size, checksum, is_public, owner
  • properties – (dict) image properties (X-Image-Meta-Property)
Returns:

(dict) metadata of the created image

remove_member(image_id, member)[source]
Parameters:
  • image_id – (str)
  • member – (str) user to deprive from current user’s images
service_type = 'image'
set_members(image_id, members)[source]
Parameters:
  • image_id – (str)
  • members – (list) user to deprive from current user’s images
unregister(image_id)[source]

Unregister an image

Parameters:image_id – (str)
Returns:(dict) response headers
update_image(image_id, name=None, disk_format=None, container_format=None, status=None, public=None, owner_id=None, **properties)[source]

9.2.6. network

Warning

For synnefo, the suggested network implementation is in kamaki.clients.cyclades.CycladesNetworkClient extension

class kamaki.clients.network.NetworkClient(endpoint_url, token, base_url=None)[source]

Bases: kamaki.clients.network.rest_api.NetworkRestClient, kamaki.clients.Waiter

OpenStack Network API 2.0 client

create_floatingip(floating_network_id, floating_ip_address='', port_id='', fixed_ip_address='')[source]
create_network(name, admin_state_up=None, shared=None)[source]
create_networks(networks)[source]

Atomic operation for batch network creation (all or nothing)

Parameters:

networks – (list) [ {name: ..(str).., admin_state_up: ..(bool).., shared: ..(bool)..}, {name: ..(str).., admin_state_up: ..(bool).., shared: ..(bool)..}] name is mandatory, the rest is optional e.g., create_networks([ {name: ‘net1’, admin_state_up: True}, {name: ‘net2’}])

Returns:

(list of dicts) created networks details

Raises:
  • ValueError – if networks is misformated
  • ClientError – if the request failed or didn’t return 201
create_port(network_id, name=None, status=None, admin_state_up=None, mac_address=None, fixed_ips=None, security_groups=None)[source]
Parameters:
  • network_id – (str)
  • name – (str)
  • status – (str)
  • admin_state_up – (bool) Router administrative status (UP / DOWN)
  • mac_address – (str)
  • fixed_ips – (str)
  • security_groups – (list)
create_ports(ports)[source]

Atomic operation for batch port creation (all or nothing)

Parameters:

ports – (list of dicts) {key: ...} with all parameters in the method create_port, where method mandatory / optional paramteres respond to mandatory / optional paramters in ports items

Returns:

(list of dicts) created portss details

Raises:
  • ValueError – if ports parameter is incorrectly formated
  • ClientError – if the request failed or didn’t return 201
create_subnet(network_id, cidr, name=None, allocation_pools=None, gateway_ip=None, subnet_id=None, ipv6=None, enable_dhcp=None)[source]
Parameters:
  • network_id – (str)
  • cidr – (str)
  • name – (str) The subnet name
  • allocation_pools – (list of dicts) start/end addresses of allocation pools: [{‘start’: ..., ‘end’: ...}, ...]
  • gateway_ip – (str) Special cases: None: server applies the default policy empty iterable: no gateway IP on this subnet
  • ipv6 – (bool) ip_version == 6 if true else 4 (default)
  • enable_dhcp – (bool)
create_subnets(subnets)[source]

Atomic operation for batch subnet creation (all or nothing)

Parameters:

subnets – (list of dicts) {key: ...} with all parameters in the method create_subnet, where method mandatory / optional paramteres respond to mandatory / optional paramters in subnets items

Returns:

(list of dicts) created subnetss details

Raises:
  • ValueError – if subnets parameter is incorrectly formated
  • ClientError – if the request failed or didn’t return 201
delete_floatingip(floatingip_id)[source]
delete_network(network_id)[source]
delete_port(port_id)[source]
delete_subnet(subnet_id)[source]
get_floatingip_details(floatingip_id)[source]
get_network_details(network_id)[source]
get_port_details(port_id)[source]
get_port_status(port_id)[source]

Deprecated, will be removed in version 0.15

get_subnet_details(subnet_id)[source]
list_floatingips()[source]
list_networks()[source]
list_ports()[source]
list_subnets()[source]
update_floatingip(floatingip_id, floating_ip_address='', port_id='', fixed_ip_address='')[source]

To nullify something optional, use None

update_network(network_id, name=None, admin_state_up=None, shared=None)[source]
update_port(port_id, network_id, name=None, status=None, admin_state_up=None, mac_address=None, fixed_ips=None, security_groups=None)[source]
Parameters:
  • network_id – (str)
  • name – (str)
  • status – (str)
  • admin_state_up – (bool) Router administrative status (UP / DOWN)
  • mac_address – (str)
  • fixed_ips – (str)
  • security_groups – (list)
update_subnet(subnet_id, name=None, allocation_pools=None, gateway_ip=None, ipv6=None, enable_dhcp=None)[source]
Parameters:
  • subnet_id – (str)
  • name – (str) The subnet name
  • allocation_pools – (list of dicts) start/end addresses of allocation pools: [{‘start’: ..., ‘end’: ...}, ...]
  • gateway_ip – (str)
  • ipv6 – (bool) ip_version == 6 if true, 4 if false, used as filter
  • enable_dhcp – (bool)
wait_port(port_id, current_status='BUILD', delay=1, max_wait=100, wait_cb=None)

Wait for port while in current_status

wait_port_until(port_id, target_status='BUILD', delay=1, max_wait=100, wait_cb=None)[source]

Wait for port while in current_status

wait_port_while(port_id, current_status='BUILD', delay=1, max_wait=100, wait_cb=None)[source]

Wait for port while in current_status

9.2.7. astakos

class kamaki.clients.astakos.AstakosClient(*args, **kwargs)[source]

Bases: astakosclient.AstakosClient

Wrap Original AstakosClient to ensure compatibility in kamaki clients

accept_commission(*args, **kwargs)

Accept a commission (see commission_action)

application_action(*args, **kwargs)

Perform action on a project application

Arguments: project_id – project identifier app_id – application identifier action – action to perform, one of “approve”, “deny”,

“dismiss”, “cancel”

reason – reason of performing the action

In case of success, return nothing.

authenticate(*args, **kwargs)

Authenticate and get services’ endpoints

Keyword arguments: tenant_name – user’s uniq id (optional)

It returns back the token as well as information about the token holder and the services he/she can access (in json format).

The tenant_name is optional and if it is given it must match the user’s uuid.

In case of error raise an AstakosClientException.

commission_action(*args, **kwargs)

Perform a commission action

Keyword arguments: serial – commission’s id (int) action – action to perform, currently accept/reject (string)

In case of success return nothing.

create_project(*args, **kwargs)

Submit application to create a new project

Arguments: specs – dict describing a project

In case of success, return project and application identifiers.

enroll_member(*args, **kwargs)

Enroll a user in a project

Arguments: project_id – project identifier email – user identified by email

In case of success, return membership identifier.

get_commission_info(*args, **kwargs)

Get Description of a Commission

Keyword arguments: serial – commission’s id (int)

In case of success return a dict of dicts containing informations (details) about the requested commission

get_endpoint_url(*args, **kwargs)[source]
get_endpoints(*args, **kwargs)

Get services’ endpoints

The extra parameter is to be used by _fill_endpoints. In case of error raise an AstakosClientException.

get_membership(*args, **kwargs)

Retrieve membership description, if accessible

Arguments: memb_id – membership identifier

In case of success, return membership description.

get_memberships(*args, **kwargs)

Retrieve all accessible memberships

Arguments: project_id – filter by project (optional) project – backwards compatibility

In case of success, return a list of membership descriptions.

get_pending_commissions(*args, **kwargs)

Get Pending Commissions

In case of success return a list of pending commissions’ ids (list of integers)

get_project(*args, **kwargs)

Retrieve project description, if accessible

Arguments: project_id – project identifier

In case of success, return project description.

get_projects(*args, **kwargs)

Retrieve all accessible projects

Arguments: name – filter by name (optional) state – filter by state (optional) owner – filter by owner (optional) mode – if value is ‘member’, return only active projects in which

the request user is an active member

In case of success, return a list of project descriptions.

get_quotas(*args, **kwargs)

Get user’s quotas

In case of success return a dict of dicts with user’s current quotas. Otherwise raise an AstakosClientException

get_resources(*args, **kwargs)

Return a dict of dicts with the available resources

get_service_endpoints(*args, **kwargs)[source]
get_services(*args, **kwargs)

Return a list of dicts with the registered services

get_token(*args, **kwargs)
get_username(*args, **kwargs)

Return the user name of a uuid (see get_usernames)

get_usernames(*args, **kwargs)

Return a uuid_catalog dictionary for the given uuids

Keyword arguments: uuids – list of user ids (list of strings)

The returned uuid_catalog is a dictionary with uuids as keys and the corresponding user names as values

get_uuid(*args, **kwargs)

Return the uuid of a name (see getUUIDs)

get_uuids(*args, **kwargs)

Return a displayname_catalog for the given names

Keyword arguments: display_names – list of user names (list of strings)

The returned displayname_catalog is a dictionary with the names as keys and the corresponding uuids as values

issue_commission_generic(*args, **kwargs)

Issue commission (for multiple holder/source pairs)

keyword arguments: user_provisions – dict mapping user holdings

(user, project, resource) to integer quantities
project_provisions – dict mapping project holdings
(project, resource) to integer quantities

name – description of the commission (string) force – force this commission (boolean) auto_accept – auto accept this commission (boolean)

In case of success return commission’s id (int). Otherwise raise an AstakosClientException.

issue_one_commission(*args, **kwargs)

Issue one commission (with specific holder and source)

keyword arguments: holder – user’s id (string) provisions – (source, resource) mapping to quantity name – description of the commission (string) force – force this commission (boolean) auto_accept – auto accept this commission (boolean)

In case of success return commission’s id (int). Otherwise raise an AstakosClientException.

issue_resource_reassignment(*args, **kwargs)

Change resource assignment to another project

join_project(*args, **kwargs)

Join a project

Arguments: project_id – project identifier

In case of success, return membership identifier.

membership_action(*args, **kwargs)

Perform action on a membership

Arguments: memb_id – membership identifier action – action to perform, one of “leave”, “cancel”, “accept”,

“reject”, “remove”

reason – reason of performing the action

In case of success, return nothing.

mk_provisions(*args, **kwargs)
modify_project(*args, **kwargs)

Submit application to modify an existing project

Arguments: project_id – project identifier specs – dict describing a project

In case of success, return project and application identifiers.

project_action(*args, **kwargs)

Perform action on a project

Arguments: project_id – project identifier action – action to perform, one of “suspend”, “unsuspend”,

“terminate”, “reinstate”

reason – reason of performing the action

In case of success, return nothing.

reject_commission(*args, **kwargs)

Reject a commission (see commission_action)

resolve_commissions(*args, **kwargs)

Resolve multiple commissions at once

Keyword arguments: accept_serials – commissions to accept (list of ints) reject_serials – commissions to reject (list of ints)

In case of success return a dict of dicts describing which commissions accepted, which rejected and which failed to resolved.

send_feedback(*args, **kwargs)

Send feedback to astakos service

keyword arguments: message – Feedback message data – Additional information about service client status

In case of success return nothing. Otherwise raise an AstakosClientException

service_get_project_quotas(*args, **kwargs)

Get all project quotas for resources associated with the service

Keyword arguments: project – optionally, the uuid of a specific project, or a list

thereof

In case of success return a dict of dicts with current quotas for all projects, or of a specified project, if project argument is set. Otherwise raise an AstakosClientException

service_get_quotas(*args, **kwargs)

Get all quotas for resources associated with the service

Keyword arguments: user – optionally, the uuid of a specific user, or a list thereof project_id – optionally, the uuid of a specific project, or a list

thereof

project – backwards compatibility (replaced by “project_id”)

In case of success return a dict of dicts of dicts with current quotas for all users, or of a specified user, if user argument is set. Otherwise raise an AstakosClientException

service_get_username(*args, **kwargs)

Return the displayName of a uuid using a service’s token

service_get_usernames(*args, **kwargs)

Return a uuid_catalog dict using a service’s token

service_get_uuid(*args, **kwargs)

Return the uuid of a name using a service’s token

service_get_uuids(*args, **kwargs)

Return a display_name catalog using a service’s token

user_info[source]
user_term(*args, **kwargs)[source]
validate_token(*args, **kwargs)

Validate a temporary access token (oath2)

Keyword arguments: belongsTo – confirm that token belongs to tenant

It returns back the token as well as information about the token holder.

The belongs_to is optional and if it is given it must be inside the token’s scope.

In case of error raise an AstakosClientException.

exception kamaki.clients.astakos.AstakosClientError(message, status=0, details=None)[source]

Bases: kamaki.clients.ClientError

class kamaki.clients.astakos.CachedAstakosClient(*args, **kwargs)[source]

Bases: kamaki.clients.Client

Synnefo Astakos cached client wraper

authenticate(*args, **kwargs)[source]

Get authentication information and store it in this client As long as the CachedAstakosClient instance is alive, the latest authentication information for this token will be available

Parameters:token – (str) custom token to authenticate
get_client(token=None)[source]

Get the Synnefo AstakosClient instance used by client

get_endpoint_url(service_type, version=None, token=None)[source]
get_service_details(service_type, token=None)[source]
Parameters:service_type – (str) compute, object-store, image, account, etc.
Returns:(dict) {name:..., type:..., endpoints:[...]}
Raises AstakosClientError:
 if service_type not in service catalog
get_service_endpoints(service_type, version=None, token=None)[source]
Parameters:
  • service_type – (str) can be compute, object-store, etc.
  • version – (str) the version id of the service
Returns:

(dict) {SNF:uiURL, adminURL, internalURL, publicURL, ...}

Raises AstakosClientError:
 

if service_type not in service catalog, or if #matching endpoints != 1

get_services(token=None)[source]
Returns:(list) [{name:..., type:..., endpoints:[...]}, ...]
get_token(uuid)[source]
list_users()[source]

list cached users information

post_user_catalogs(uuids=None, displaynames=None, token=None)[source]

POST endpoint_url/user_catalogs

Parameters:
  • uuids – (list or tuple) user uuids
  • displaynames – (list or tuple) usernames (mut. excl. to uuids)
Returns:

(dict) {uuid1: name1, uuid2: name2, ...} or oposite

remove_user(uuid)[source]
service_type = 'identity'
term(key, token=None)[source]

Get (cached) term, from user credentials

user_info(token=None)[source]

Get (cached) user information

user_term(key, token=None)[source]

Get (cached) term, from user credentials

usernames2uuids(*args, **kwargs)[source]
uuids2usernames(*args, **kwargs)[source]
class kamaki.clients.astakos.LoggedAstakosClient(*args, **kwargs)[source]

Bases: kamaki.clients.astakos.AstakosClient, kamaki.clients.Logged

An AstakosClient wrapper with modified logging

Logs are adjusted to appear similar to the ones of kamaki clients. No other changes are made to the parent class.

kamaki.clients.astakos.mk_astakosclienterror(sace)[source]

Make an AstakosClientError from an AstakosClientException