Commit 2e4596bf authored by Romain Olivo's avatar Romain Olivo

modif example & add viface_update

parent a2c10bcb
Pipeline #86249 passed with stages
in 2 minutes and 16 seconds
......@@ -548,6 +548,32 @@ class Distem():
return self.delete_json('/vnodes/%s/ifaces/%s/' %(str(vnodename), str(vifacename)), data={})
def viface_update(self, 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
vnodename(str): The name of the virtual node
vifacename(str): The name of the virtual network interface
desc(dict): Hash structured as described in
{file:files/ Resource Description - VIface}.
{Dictionnary} The virtual network interface description
see {file:files/ Resource Description - VIfaces}
if desc is None:
desc = {}
return self.put_json("/vnodes/%s/ifaces/%s" %(vnodename, vifacename), {'desc': desc})
def vcpu_create(self, vnodename, val, unit='mhz', corenb=1):
......@@ -778,7 +804,7 @@ class Distem():
req = requests.Request(method, route, data=_data)
prepped = req.prepare()
response = return self.client.send(prepped)
response = self.client.send(prepped)
if 200 <= response.status_code < 300:
......@@ -788,3 +814,4 @@ class Distem():
return result
raise Exception(response.headers['X-Application-Error-Code'])
......@@ -5,6 +5,7 @@ import copy
from statistics import mean
from statistics import stdev
from math import sqrt
import time
from distem import Distem
......@@ -15,13 +16,13 @@ if __name__ == "__main__":
# Put the physical machines that have been assigned to you
# You can get that by executing: cat $OAR_NODE_FILE | uniq
# The first argument of the script is the address (in CIDR format)
# of the virtual network to set-up in our platform
# This ruby hash table describes our virtual network
vnet = {
'name': 'lol',
'name': 'mynetwork',
'address': ""
nodelist = ['node-1','node-2']
......@@ -65,56 +66,6 @@ if __name__ == "__main__":
# Connect to the Distem server (on http://localhost:4567 by default)
distem = Distem()
# Start by creating the virtual network
print("Network created")
# Creating one virtual node per physical one
# Create the first virtual node and set it to be hosted on
# the first physical machine
print("Node %s created" %nodelist[0])
{'host': PNODES[0]}, sshkeys)
# Specify the path to the compressed filesystem image
# of this virtual node
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
print("Interface created")
{'vnetwork': vnet['name'], 'default': 'true' })
# Create the first virtual node and set it to be hosted on
# the second physical machine
print("Node %s created" %nodelist[1])
{'host': PNODES[1] },
{'image': FSIMG })
# Create a virtual network interface and connect it to vnet
print("Interface created")
{ 'vnetwork': vnet['name'] }
# Starting the virtual nodes using the synchronous method
print("Nodes started")
# Getting the -automatically affected- address of each virtual nodes
# virtual network interfaces
node1['address'] = distem.viface_info(node1['name'],ifname)['address'].split("/")[0]
node2['address'] = distem.viface_info(node2['name'],ifname)['address'].split("/")[0]
# Creating the files we will use in our experimentation
'mkdir -p /tmp/src ; cd /tmp/src ; \
for i in `seq 1 100`; do \
dd if=/dev/zero of=$i bs=1K count=50; \
# Printing the current latency
start_time = float(time.time())
distem.vnode_execute(node1['name'], 'hostname')
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