API

class distem.Distem(*, serveraddr='localhost', port=4567)
delete_json(route, data)
get_json(route)
pnode_info(target='localhost')

Retrieve informations about a physical node

Parameters:target – The address/name of the physical node
pnode_init(target='localhost', desc=None, asynch=False)

Initialize a physical machine (launching daemon, creating cgroups, …). This step have to be performed to be able to create virtual nodes on a machine.

Parameters:
  • target (Str|List) – target The hostname(s)/address(es) of the physical node(n)
  • desc (dict) – Hash structured as described in resources description
  • asynch (bool) – Asynchronious mode, check the physical node status to know when the configuration is done (see {#pnode_info})
Returns:

dict of the physical node description

see resources description.

pnode_quit(target='localhost')

Quit distem on a physical machine

Parameters:target (str) – The hostname/address of the physical node
Returns:
dict of the physical node description
see resources description.
pnodes_info()

Retrieve informations about every physical nodes currently set on the platform

Returns:
list of physical node descriptions
see resources description.
pnodes_quit()

# Retrieve informations about every physical nodes currently set on the platform

Returns:
list of physical node descriptions
see resources description.
post_json(route, data)
put_json(route, data)
raw_request(method, route, data)
vcpu_create(vnodename, val, unit='mhz', corenb=1)

Set up a virtual CPU on the virtual node

Parameters:
  • vnodename (str) – The name of the virtual node val(float): The
  • defined as a value in MHz or as a ratio (frequency) – (percentage of the physical core frequency).
  • unit (str) – Tell if val is a frequency or a ratio (allowed values are mhz and ration)
  • corenb (Integer) – The number of cores to allocate (need to have enough free ones on the physical node)
Returns:

dict of the virtual CPU description

see resources description

vcpu_info(vnodename)

Retrive information about a virtual node CPU

Returns:
dict of the virtual CPU description
see resources description
vcpu_remove(vnodename)

Removing a virtual CPU on the virtual node

Parameters:vnodename (str) – The name of the virtual node
Returns:
dict of the virtual CPU description
see resources description
vcpu_update(vnodename, val, unit='mhz')

Update a virtual CPU on the virtual node This setting works on-the-fly (i.e. even if the virtual node is already running)

Parameters:
  • vnodename (str) – The name of the virtual node
  • val (float) – The frequency defined as a value in MHz or as a ratio (percentage of the physical core frequency).
  • unit (str) – Tell if val is a frequency or
  • ratio (a) –
Returns:

dict of the virtual CPU description

see resources description

vfilesystem_create(vnodename, desc)

Set up the filesystem of a virtual node

Parameters:
  • vnodename (str) – The name of the virtual node
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual Filesystem description

see resources description

vfilesystem_info(vnodename)

Retrieve informations about a virtual node filesystem

Parameters:vnodename (str) – The name of the virtual node
Returns:dict of the virtual node filesystem informations
vfilesystem_update(vnodename, desc)

Update the filesystem of a virtual node

Parameters:
  • vnodename (str) – The name of the virtual node
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual Filesystem description

see resources description

viface_create(vnodename, name, desc)

Create a virtual network interface on the virtual node

Parameters:
  • vnodename (str) – The name of the virtual node
  • name (str) – The name of the virtual network interface to be created (have to be unique on that virtual node)
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual network interface description

see resources description

viface_info(vnodename, vifacename)

Retrieve informations about a virtual network interface associated to a virtual node

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
Returns:

dict of the virtual network interface description

see resources description

viface_remove(vnodename, vifacename)

Remove a virtual network interface

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the network virtual interface
Returns:

dict of the virtual network interface description

see resources description

viface_update(vnodename, vifacename, desc=None)

Update a virtual network interface

Disconnect (detach): the virtual network interface from any virtual network it’s connected on if +desc+ is empty

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual network interface description

see resources description

vinput_info(vnodename, vifacename)

Retrive the traffic description on the input of a specified virtual network interface

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
Returns:

dict of the virtual traffic description

see resources description

vinput_update(vnodename, vifacename, desc=None)

Update the traffic description on the input of a specified virtual network interface The vtraffic description is updated on-the-fly (even if the virtual node is running) Reset the vtraffic description if +desc+ is empty

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual traffic description

see resources description

vmem_create(vnodename, mem, swap=None, hierarchy='v1')

Create a new memory limitation

Parameters:
  • vnodename (str) – The vnode’s name to create
  • mem (str) – The required amount of RAM
  • swap (str) – The required amount of swap
  • hierarchy (str) – The hierarchy where memory controller is mounted (default to v1)
Returns:

dict of the memory limitation

vmem_update(vnodename, desc)

Update a memory limitation

Parameters:
  • vnodename (str) – The vnode’s name to update
  • desc (dict) – The memory limitation description
vnetwork_create(name, address, opts=None)

Create a new virtual network

Parameters:
  • name (str) – The name of the virtual network (unique)
  • addres (str) – address in CIDR format (e.g 10.0.8.0/24)
  • opts (dict) – used to store vxlan_id and number of PNODES (should not be used directly)
Returns:

dict of the virtual network description

see resources description.

vnetwork_info(vnetname)

Retrieve informations about a virtual network

Parameters:vnetname (str) –
Returns:
dict of the virtual network description
see resources description
vnetwork_remove(vnetname)

Remove a virtual network, that will disconnect every virtual node connected on it and remove it’s virtual routes.

Parameters:vnetname (str) –
Returns:
dict of the virtual network description
see resources description
vnode_create(name, desc=None, ssh_key=None, asynch=False)

Create a new virtual node

Parameters:
  • name (str) – The name of the virtual node which should be unique
  • desc (dict) – Hash structured as described in resources description
  • ssh_key (dict) –

    SSH key pair to be copied on the virtual node (also adding the public key to .ssh/authorized_keys). Note that every SSH keys located on the physical node which hosts this virtual node are also copied in .ssh/ directory of the node (copied key have a specific filename prefix). The key are copied in .ssh/ directory of SSH user (see {Distem::Daemon::Admin#SSH_USER} and Distem::Node::Container::SSH_KEY_FILENAME)

    _Format_: dict.
    _Structure_:
    { “public” : “KEYHASH”, “private” : “KEYHASH” }

    Both of +public+ and +private+ parameters are optional

  • asynch (bool) – to know when node is configured (see {#vnode_info})
Returns:

dict of the virtual node description

see resources description

vnode_execute(vnodename, command)

Execute and get the result of a command on a virtual node

Parameters:
  • vnodename (str) – The name of the virtual node
  • command (str) – The command to be executed
Returns:

[String] The result of the command (Array of string if multilines)

vnode_freeze(vnodename, asynch=False)

Freeze a virtual node, but without deleting its data

Parameters:
  • vnodename (str) – The name of the virtual node
  • bool) (asynch) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

dict of the virtual node description

see resources description

vnode_info(vnodename)

Retrieve informations about a virtual node

Parameters:vnodename (str) –
Returns:
dict of the virtual node description
see resources description
vnode_remove(vnodename)

Remove the virtual node

“Cascade” removing: remove all the vroutes in which this virtual node apears as gateway

Parameters:vnodename (str) – The name of the virtual node
Returns:
dict of the virtual node description
see resources description
vnode_start(vnodename, *, asynch=False)

Start a virtual node.

A physical node (that have enough physical resources (CPU,…)) will be automatically allocated if there is none set as +host+ at the moment The filesystem archive will be copied on the hosting physical node. A filesystem image must have been set (see {#vnode_create} or {#vfilesystem_create}/{#vfilesystem_update}).

Parameters:
  • vnodename (str) – The name of the virtual node
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

dict of the virtual node description

see resources description

vnode_stop(vnodename, asynch=False)

Stopping a virtual node, deleting it’s data from the hosting physical node. The +host+ association for this virtual node will be cancelled, if you start the virtual node directcly after stopping it, the hosting physical node will be chosen randomly (to set it manually, see host field, {#vnode_update})

Parameters:
  • vnodename (str) – The name of the virtual node
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

dict of the virtual node description

see resources description

vnode_unfreeze(vnodename, asynch=False)

Unfreeze a virtual node, but without deleting its data

Parameters:
  • vnodename (str) – The name of the virtual node
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured
Returns:

dict of the virtual node description

see resources description

vnodes_create(names, desc=None, ssh_key=None, asynch=False)

Create new virtual nodes

Parameters:
  • names (Array) – The names of the virtual nodes which should be unique desc(dict) Hash structured as described in resources description ssh_key(dict) SSH key pair to be copied on the virtual node (also adding the public key to .ssh/authorized_keys). Note that every SSH keys located on the physical node which hosts this virtual node are also copied in .ssh/ directory of the node (copied key have a specific filename prefix). The key are copied in .ssh/ directory of SSH user (see {Distem::Daemon::Admin#SSH_USER} and Distem::Node::Container::SSH_KEY_FILENAME)
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

[Array] The virtual nodes description

see resources description

vnodes_execute(names, command)

Execute and get the result of a command on a set of virtual nodes

Parameters:
  • names (Array) – Array of virtual nodes
  • command (str) – The command to be executed
Returns:

dict of the result of the command (one entry by vnode)

vnodes_freeze(names=None, asynch=False)

Freeze some virtual nodes

Parameters:
  • names (Array) – The names of the virtual nodes
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

[Array] The virtual node descriptions

see resources description

vnodes_info()

Retrieve informations about every virtual nodes currently set on the platform

Returns:
[Array] Array of virtual nodes description
see resources description
vnodes_remove(names=None)

Remove the virtual vnodes, or every if names is nil

Returns:
[Array] Array of virtual nodes description
(see resources description
vnodes_start(names, asynch=False)

Start several virtual nodes

A physical node (that have enought physical resources (CPU,…)) will be automatically allocated if there is none set as +host+ at the moment The filesystem archive will be copied on the hosting physical node. A filesystem image must have been set (see {#vnode_create} or {#vfilesystem_create}/{#vfilesystem_update}).

Parameters:
  • names (Array) – The names of the virtual nodes
  • asynch (bool) – Asynchronious mode, check virtual nodes status to know when node is configured (see {#vnode_info})
Returns:

dict of the virtual nodes description

see resources description

vnodes_stop(names=None, asynch=False)

Stop given virtal nodes

Parameters:
  • names (Array) – The name of the virtual nodes
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

dict of the description of the virtual nodes

vnodes_unfreeze(names=None, asynch=False)

Unfreeze some virtual nodes

Parameters:
  • names (Array) – The names of the virtual nodes
  • asynch (bool) – Asynchronious mode, check virtual node status to know when node is configured (see {#vnode_info})
Returns:

[Array] The virtual node descriptions

see resources description

voutput_info(vnodename, vifacename)

Retrive the traffic description on the output of a specified virtual network interface

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
Returns:

dict of the virtual traffic description

see resources description

voutput_update(vnodename, vifacename, desc=None)

Update the traffic description on the output of a specified virtual network interface The vtraffic description is updated on-the-fly (even if the virtual node is running) Reset the vtraffic description if +desc+ is empty

Parameters:
  • vnodename (str) – The name of the virtual node
  • vifacename (str) – The name of the virtual network interface
  • desc (dict) – Hash structured as described in resources description
Returns:

dict of the virtual traffic description

see resources description