Commit e0cf9031 authored by Romain Olivo's avatar Romain Olivo

pnode functions add

parent cc8738a3
......@@ -10,13 +10,89 @@ class Distem:
self.port = port
self.client = requests.Session()
def 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.
Args:
target (Str|List): target The hostname(s)/address(es)
of the physical node(n)
desc (dict): Hash structured as described in
:desc:`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 :desc:`resources description <>`.
'''
if desc is None:
desc = {}
data = {"target": target, "desc": desc, "async": asynch}
return self.post_json("/pnodes/", data=data)
def pnode_quit(target="localhost"):
'''
Quit distem on a physical machine
Args:
target (str): The hostname/address of the physical node
Returns:
dict of the physical node description
see :desc:`resources description <>`.
'''
return self.delete_json("/pnodes/%s" % target)
def pnodes_quit():
'''
# Retrieve informations about every physical nodes currently set on the platform
Returns:
list of physical node descriptions
see :desc:`resources description <>`.
'''
return self.delete_json("/pnodes")
def pnode_info(target="localhost"):
'''
Retrieve informations about a physical node
Args:
target (str): The address/name of the physical node
Returns:
dict of the physical node description
see :desc:`resources description <>`.
'''
return self.get_json("/pnodes/%s" % target)
def pnodes_info():
'''
Retrieve informations about every physical nodes
currently set on the platform
Returns:
list of physical node descriptions
see :desc:`resources description <>`.
'''
return self.get_json("/pnodes")
def vnetwork_create(self, name, address, opts=None):
"""
Create a new virtual network
Args:
name (str): The name of the virtual network (unique) address(str) The
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)
......@@ -30,7 +106,7 @@ class Distem:
return self.post_json("/vnetworks",
data={"name": name,
"address": address,})
"address": address})
def vnetwork_remove(self, vnetname):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment