Mise à jour terminée. Pour connaître les apports de la version 13.8.4 par rapport à notre ancienne version vous pouvez lire les "Release Notes" suivantes :
https://about.gitlab.com/releases/2021/02/11/security-release-gitlab-13-8-4-released/
https://about.gitlab.com/releases/2021/02/05/gitlab-13-8-3-released/

parent 1a940d09
......@@ -3,14 +3,12 @@ import copy
import requests
class Distem():
class Distem:
def __init__(self, serveraddr="localhost", port=4567):
self.serveraddr = serveraddr
self.port = port
self.client = requests.Session()
def vnetwork_create(self, name, address, opts=None):
"""
Create a new virtual network
......@@ -28,8 +26,7 @@ class Distem():
if opts is None:
opts = []
return self.post_json('/vnetworks', data={'name': name, 'address': address})
return self.post_json("/vnetworks", data={"name": name, "address": address})
def vnetwork_remove(self, vnetname):
......@@ -46,8 +43,9 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Networks Resource Description - VNetworks}
"""
return self.delete_json('/vnetworks/%s' %(str(vnetname)), data={'type': "remove"})
return self.delete_json(
"/vnetworks/%s" % (str(vnetname)), data={"type": "remove"}
)
def vnetwork_info(self, vnetname):
"""
......@@ -62,8 +60,7 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Networks Resource Description - VNetworks}
"""
return self.get_json('/vnetworks/%s' %(str(vnetname)))
return self.get_json("/vnetworks/%s" % (str(vnetname)))
def vnode_info(self, vnodename):
"""
......@@ -77,8 +74,7 @@ class Distem():
{Dictionnary} The virtual node description
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
return self.get_json('/vnodes/%s' %(str(vnodename)))
return self.get_json("/vnodes/%s" % (str(vnodename)))
def vnode_create(self, name, desc=None, ssh_key=None):
"""
......@@ -118,14 +114,9 @@ class Distem():
if ssh_key is None:
ssh_key = {}
data = {
"desc": desc,
"ssh_key": ssh_key,
'async': False
}
return self.post_json('/vnodes/%s' %(name), data=data)
data = {"desc": desc, "ssh_key": ssh_key, "async": False}
return self.post_json("/vnodes/%s" % (name), data=data)
def vnode_start(self, vnodename):
"""
......@@ -149,14 +140,12 @@ class Distem():
"""
desc = {
'desc': {'name': str(vnodename),
'status': "RUNNING"},
'type': "update",
'async': False
}
return self.put_json('/vnodes/%s' % (str(vnodename)), data=desc)
"desc": {"name": str(vnodename), "status": "RUNNING"},
"type": "update",
"async": False,
}
return self.put_json("/vnodes/%s" % (str(vnodename)), data=desc)
def vnode_stop(self, vnodename):
"""
......@@ -177,14 +166,9 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
desc = {
'desc': {'status': "DOWN"},
'type': "stop",
'async': False
}
return self.put_json('/vnodes/%s' %(vnodename), data=desc)
desc = {"desc": {"status": "DOWN"}, "type": "stop", "async": False}
return self.put_json("/vnodes/%s" % (vnodename), data=desc)
def vnode_remove(self, vnodename):
......@@ -201,8 +185,7 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
return self.put_json('/vnodes/%s' %(vnodename), data={'type': "remove"})
return self.put_json("/vnodes/%s" % (vnodename), data={"type": "remove"})
def vnode_freeze(self, vnodename):
......@@ -220,8 +203,9 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
return self.put_json('/vnodes/%s' %(str(vnodename)), {'async': False, 'type': 'freeze'})
return self.put_json(
"/vnodes/%s" % (str(vnodename)), {"async": False, "type": "freeze"}
)
def vnode_unfreeze(self, vnodename):
......@@ -239,8 +223,9 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
return self.put_json('/vnodes/%s' %(str(vnodename)), {'async': False, 'type': 'unfreeze'})
return self.put_json(
"/vnodes/%s" % (str(vnodename)), {"async": False, "type": "unfreeze"}
)
def vnode_execute(self, vnodename, command):
......@@ -256,8 +241,9 @@ class Distem():
[String] The result of the command (Array of string if multilines)
"""
return self.post_json('/vnodes/%s/commands/' %(str(vnodename)), data={'command': str(command)})
return self.post_json(
"/vnodes/%s/commands/" % (str(vnodename)), data={"command": str(command)}
)
def vnodes_info(self):
......@@ -272,7 +258,6 @@ class Distem():
return self.get_json("/vnodes")
def vnodes_create(self, names, desc=None, ssh_key=None):
"""
......@@ -303,15 +288,9 @@ class Distem():
if ssh_key is None:
ssh_key = {}
data = {
"names": names,
"desc": desc,
"ssh_key": ssh_key,
'async': False
}
return self.post_json('/vnodes/', data=data)
data = {"names": names, "desc": desc, "ssh_key": ssh_key, "async": False}
return self.post_json("/vnodes/", data=data)
def vnodes_remove(self, names=None):
......@@ -326,8 +305,9 @@ class Distem():
if names is None:
names = []
return self.put_json("/vnodes", data={'names': names, 'type': 'delete', 'async': False})
return self.put_json(
"/vnodes", data={"names": names, "type": "delete", "async": False}
)
def vnodes_start(self, names):
......@@ -351,9 +331,10 @@ class Distem():
see {file:files/resources_desc.md#Virtual_Nodes Resource Description - VNodes}
"""
desc = {'status': 'RUNNING'}
return self.put_json('/vnodes', {'names': names, 'desc': desc, 'async': False, 'type': 'update'})
desc = {"status": "RUNNING"}
return self.put_json(
"/vnodes", {"names": names, "desc": desc, "async": False, "type": "update"}
)
def vnodes_stop(self, names=None):
......@@ -372,8 +353,9 @@ class Distem():
if names is None:
names = []
return self.put_json("/vnodes", {'names': names, 'async': False, 'type': 'stop'})
return self.put_json(
"/vnodes", {"names": names, "async": False, "type": "stop"}
)
def vnodes_freeze(self, names=None):
......@@ -394,8 +376,9 @@ class Distem():
if names is None:
names = []
return self.put_json("/vnodes", {'names': names, 'async': False, 'type': 'freeze'})
return self.put_json(
"/vnodes", {"names": names, "async": False, "type": "freeze"}
)
def vnodes_unfreeze(self, names=None):
......@@ -416,8 +399,9 @@ class Distem():
if names is None:
names = []
return self.put_json("/vnodes", {'names': names, 'async': False, 'type': 'unfreeze'})
return self.put_json(
"/vnodes", {"names": names, "async": False, "type": "unfreeze"}
)
def vnodes_execute(self, names, command):
......@@ -433,8 +417,7 @@ class Distem():
{Dictionnary} The result of the command (one entry by vnode)
"""
return self.post_json("/commands", {'names': names, 'command': command})
return self.post_json("/commands", {"names": names, "command": command})
def vfilesystem_info(self, vnodename):
......@@ -449,8 +432,7 @@ class Distem():
{Dictionnary} The virtual node filesystem informations
"""
return self.get_json('/vnodes/%s/filesystem/' %(str(vnodename)))
return self.get_json("/vnodes/%s/filesystem/" % (str(vnodename)))
def vfilesystem_create(self, vnodename, desc):
......@@ -468,8 +450,9 @@ class Distem():
see {file:files/resources_desc.md#File_System0 Resource Description - VFilesystem}
"""
return self.post_json('/vnodes/%s/filesystem/' %(str(vnodename)), {"desc": desc})
return self.post_json(
"/vnodes/%s/filesystem/" % (str(vnodename)), {"desc": desc}
)
def vfilesystem_update(self, vnodename, desc):
......@@ -487,8 +470,7 @@ class Distem():
see {file:files/resources_desc.md#File_System0 Resource Description - VFilesystem}
"""
return self.put_json('/vnodes/%s/filesystem/' %(str(vnodename)), data=desc)
return self.put_json("/vnodes/%s/filesystem/" % (str(vnodename)), data=desc)
def viface_info(self, vnodename, vifacename):
......@@ -505,8 +487,7 @@ class Distem():
see {file:files/resources_desc.md#Network_Interfaces Resource Description - VIfaces}
"""
return self.get_json('/vnodes/%s/ifaces/%s' %(str(vnodename), str(vifacename)))
return self.get_json("/vnodes/%s/ifaces/%s" % (str(vnodename), str(vifacename)))
def viface_create(self, vnodename, name, desc):
......@@ -526,8 +507,9 @@ class Distem():
see {file:files/resources_desc.md#Network_Interfaces Resource Description - VIfaces}
"""
return self.post_json('/vnodes/%s/ifaces/' %(str(vnodename)), {'name': name, 'desc': desc})
return self.post_json(
"/vnodes/%s/ifaces/" % (str(vnodename)), {"name": name, "desc": desc}
)
def viface_remove(self, vnodename, vifacename):
......@@ -544,10 +526,11 @@ class Distem():
see {file:files/resources_desc.md#Network_Interfaces Resource Description - VIfaces}
"""
return self.delete_json('/vnodes/%s/ifaces/%s/' %(str(vnodename), str(vifacename)), data={})
return self.delete_json(
"/vnodes/%s/ifaces/%s/" % (str(vnodename), str(vifacename)), data={}
)
def viface_update(self, vnodename, vifacename, desc = None):
def viface_update(self, vnodename, vifacename, desc=None):
"""
Update a virtual network interface
......@@ -570,10 +553,11 @@ class Distem():
if desc is None:
desc = {}
return self.put_json("/vnodes/%s/ifaces/%s" %(vnodename, vifacename), {'desc': desc})
return self.put_json(
"/vnodes/%s/ifaces/%s" % (vnodename, vifacename), {"desc": desc}
)
def vcpu_create(self, vnodename, val, unit='mhz', corenb=1):
def vcpu_create(self, vnodename, val, unit="mhz", corenb=1):
"""
Set up a virtual CPU on the virtual node
......@@ -592,11 +576,10 @@ class Distem():
see {file:files/resources_desc.md#CPU0 Resource Description - VCPU}
"""
desc = {'corenb': corenb, 'val': val, 'unit': unit}
return self.post_json("/vnodes/%s/cpu" %(vnodename), data={'desc': desc})
desc = {"corenb": corenb, "val": val, "unit": unit}
return self.post_json("/vnodes/%s/cpu" % (vnodename), data={"desc": desc})
def vcpu_update(self, vnodename, val, unit='mhz'):
def vcpu_update(self, vnodename, val, unit="mhz"):
"""
Update a virtual CPU on the virtual node
......@@ -613,9 +596,8 @@ class Distem():
see {file:files/resources_desc.md#CPU0 Resource Description - VCPU}
"""
desc = {'val': val, 'unit': unit}
return self.put_json("/vnodes/%s/cpu" %(vnodename), {'desc': desc})
desc = {"val": val, "unit": unit}
return self.put_json("/vnodes/%s/cpu" % (vnodename), {"desc": desc})
def vcpu_remove(self, vnodename):
......@@ -631,8 +613,7 @@ class Distem():
see {file:files/resources_desc.md#CPU0 Resource Description - VCPU}
"""
return self.delete_json("/vnodes/%s/cpu" %(vnodename), data={})
return self.delete_json("/vnodes/%s/cpu" % (vnodename), data={})
def vcpu_info(self, vnodename):
......@@ -645,8 +626,7 @@ class Distem():
see {file:files/resources_desc.md#CPU0 Resource Description - VCPU}
"""
return self.get_json("/vnodes/%s/cpu" %(vnodename))
return self.get_json("/vnodes/%s/cpu" % (vnodename))
def vinput_update(self, vnodename, vifacename, desc=None):
......@@ -670,9 +650,9 @@ class Distem():
if desc is None:
desc = {}
return self.put_json("/vnodes/%s/ifaces/%s/input/" %(vnodename, vifacename),
{'desc': desc})
return self.put_json(
"/vnodes/%s/ifaces/%s/input/" % (vnodename, vifacename), {"desc": desc}
)
def vinput_info(self, vnodename, vifacename):
......@@ -689,8 +669,7 @@ class Distem():
see {file:files/resources_desc.md#Traffic Resource Description - VTraffic}
"""
return self.get_json("/vnodes/%s/ifaces/%s/input" %(vnodename, vifacename))
return self.get_json("/vnodes/%s/ifaces/%s/input" % (vnodename, vifacename))
def voutput_update(self, vnodename, vifacename, desc=None):
......@@ -714,8 +693,9 @@ class Distem():
if desc is None:
desc = {}
return self.put_json("/vnodes/%s/ifaces/%s/output" %(vnodename, vifacename), {'desc': desc})
return self.put_json(
"/vnodes/%s/ifaces/%s/output" % (vnodename, vifacename), {"desc": desc}
)
def voutput_info(self, vnodename, vifacename):
......@@ -732,10 +712,9 @@ class Distem():
see {file:files/resources_desc.md#Traffic Resource Description - VTraffic})
"""
return self.get_json("/vnodes/%s/ifaces/%s/output" %(vnodename, vifacename))
return self.get_json("/vnodes/%s/ifaces/%s/output" % (vnodename, vifacename))
def vmem_create(self, vnodename, mem, swap=None, hierarchy='v1'):
def vmem_create(self, vnodename, mem, swap=None, hierarchy="v1"):
"""
Create a new memory limitation
......@@ -753,9 +732,8 @@ class Distem():
if swap is None:
swap = []
desc = {'mem': mem, 'swap': swap, 'hierarchy': hierarchy}
return self.post_json("/vnodes/%s/vmem" %(vnodename), {'desc': desc})
desc = {"mem": mem, "swap": swap, "hierarchy": hierarchy}
return self.post_json("/vnodes/%s/vmem" % (vnodename), {"desc": desc})
def vmem_update(self, vnodename, desc):
......@@ -767,32 +745,35 @@ class Distem():
desc(dict) The memory limitation description
"""
return self.put_json("/vnodes/%s/vmem" %(vnodename), {'desc': desc})
return self.put_json("/vnodes/%s/vmem" % (vnodename), {"desc": desc})
def get_json(self, route):
return self.raw_request(method="get",
route='http://%s:%s%s' %(self.serveraddr, self.port, route),
data={})
return self.raw_request(
method="get",
route="http://%s:%s%s" % (self.serveraddr, self.port, route),
data={},
)
def post_json(self, route, data):
return self.raw_request(method="post",
route='http://%s:%s%s' %(self.serveraddr, self.port, route),
data=data)
return self.raw_request(
method="post",
route="http://%s:%s%s" % (self.serveraddr, self.port, route),
data=data,
)
def put_json(self, route, data):
return self.raw_request(method="put",
route='http://%s:%s%s' %(self.serveraddr, self.port, route),
data=data)
return self.raw_request(
method="put",
route="http://%s:%s%s" % (self.serveraddr, self.port, route),
data=data,
)
def delete_json(self, route, data):
return self.raw_request(method="delete",
route='http://%s:%s%s' %(self.serveraddr, self.port, route),
data=data)
return self.raw_request(
method="delete",
route="http://%s:%s%s" % (self.serveraddr, self.port, route),
data=data,
)
def raw_request(self, method, route, data):
result = ""
......@@ -812,5 +793,4 @@ class Distem():
result = response.text
return result
else:
raise Exception(response.headers['X-Application-Error-Code'])
raise Exception(response.headers["X-Application-Error-Code"])
......@@ -34,3 +34,4 @@ ignore = E121,E122,E123,E124,E125,E127,E128,E129,E131,E241,H405,F821, W503, W292
show-source = true
exclude = venv,.git,.tox,dist,*egg,ansible,tests
max-complexity = 12
max-line-length = 88
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