Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6f0affda authored by Romain Olivo's avatar Romain Olivo
Browse files

doc

parent 1c192b3e
No related branches found
No related tags found
No related merge requests found
Pipeline #88482 passed
.. automodule:: distem.api
:members:
:undoc-members:
.. toctree::
:maxdepth: 2
:caption: Contents:
api.rst
.. toctree::
:maxdepth: 2
:caption Contents:
tutorials
apidoc
File added
File added
import logging
import time
import os
from statistics import mean, stdev
from distem import Distem
......@@ -7,107 +10,44 @@ if __name__ == "__main__":
# The path to the compressed filesystem image
# We can point to local file since our homedir is available from NFS
FSIMG = "file:///home/USER/distem_img/distem-fs-jessie.tar.gz"
FSIMG = "file:///home/msimonin/public/distem-fs-jessie.tar.gz"
# Put the physical machines that have been assigned to you
# You can get that by executing: cat $OAR_NODE_FILE | uniq
PNODES = ["pnode1", "pnode2"]
PNODES = ["parapide-10.rennes.grid5000.fr", "parapide-11.rennes.grid5000.fr"]
# 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': 'testnet',
'address': ARGV[0]
'name': 'mynetworkk',
'address': "10.158.0.0/22"
}
nodelist = ['node-1', 'node-2']
# Read SSH keys
PRIV_KEY = os.path.join(os.environ["HOME"], ".ssh", "id_rsa")
PUB_KEY = "%s.pub" % PRIV_KEY
private_key = open(os.path.expanduser(PRIV_KEY)).read()
public_key = open(os.path.expanduser(PUB_KEY)).read()
sshkeys = {
"public" : public_key,
"private" : private_key
}
latencies = ['0ms', '20ms', '40ms', '60ms']
results = {
'scp': {},
'rsync': {}
}
avg = {
'scp': {},
'rsync': {}
}
node1 = {
'name': 'node-1',
'name': nodelist[0],
'address': []
}
node2 = {
'name': 'node-2',
'name': nodelist[1],
'address': []
}
ifname = 'if0'
iteration = 5
def average(values):
sum_values = 0.0
for i in values:
sum_values += float(i)
return sum_values / len(values)
def stddev(values, avg):
sum_values = 0.0
for i in values:
sum_values += (float(i) - avg) * (float(i) - avg)
return sum_values / len(values)
# Connect to the Distem server (on http://localhost:4567 by default)
distem = Distem()
# Start by creating the virtual network
print("Network created")
distem.vnetwork_create(vnet['name'],
vnet['address'])
# 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])
distem.vnode_create(nodelist[0],
{'host': PNODES[0]}, sshkeys)
# Specify the path to the compressed filesystem image
# of this virtual node
distem.vfilesystem_create(nodelist[0],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
print("Interface created")
distem.viface_create(nodelist[0],
'if0',
{'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])
distem.vnode_create(nodelist[1],
{'host': PNODES[1]},
sshkeys)
distem.vfilesystem_create(nodelist[1],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
print("Interface created")
distem.viface_create(nodelist[1],
'if0',
{'vnetwork': vnet['name']})
# Starting the virtual nodes using the synchronous method
distem.vnodes_start(nodelist)
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
distem.vnode_execute(node1['name'],
'mkdir -p /tmp/src ; cd /tmp/src ; \
......@@ -117,8 +57,8 @@ if __name__ == "__main__":
)
# Printing the current latency
start_time = float(time.time())
distem.vnode_execute(node1['name'], 'hostname')
start_time = time.time()
distem.vnode_execute(node1['name'], 'hsjvdjq')
print("Latency without any limitations # %s" %(str(time.time() - start_time)))
desc = {
......@@ -133,8 +73,6 @@ if __name__ == "__main__":
for latency in latencies:
results['scp'][latency] = []
results['rsync'][latency] = []
avg['scp'][latency] = []
avg['rsync'][latency] = []
print("Latency #%s" %str(latency))
# Update the latency description on virtual nodes
......@@ -149,37 +87,33 @@ if __name__ == "__main__":
distem.vnode_execute(node2['name'], 'rm -rf /tmp/dst')
# Starting the copy from node1 to node2
start_time = time.time()
cmd = "scp -rq /tmp/src %s:/tmp/dst" % node2["address"]
distem.vnode_execute(node1['name'],
"scp -rq /tmp/src #{node2['address']}:/tmp/dst"
cmd,
)
results['scp'][latency] = str(time.time() - start_time)
end_time = time.time()
import ipdb; ipdb.set_trace()
results['scp'][latency].append(time.time() - start_time)
# Launch RSYNC test
# Cleaning target directory on node2
distem.vnode_execute(node2['name'], 'rm -rf /tmp/dst')
# Starting the copy from node1 to node2
start_time = round(time.time(), 5)
distem.vnode_execute('node-1',
start_time = time.time()
distem.vnode_execute(node1['name'],
"rsync -r /tmp/src #{node2['address']}:/tmp/dst"
)
results['rsync'][latency] = str(time.time() - start_time)
results['rsync'][latency].append(time.time() - start_time)
values = []
print("Rsync results :")
for latency in latencies:
values.append(results['rsync'][latency])
avg['rsync'][latency] = average(values)
for latency in latencies:
print(results['rsync'][latency])
print("%s: [average=%s,standard_deviation=%s]"
%(str(latency), avg['rsync'][latency], stddev(values, avg['rsync'][latency])))
%(latency, mean(results['rsync'][latency]), stdev(results['rsync'][latency])))
values = []
print("SCP results :")
for latency in latencies:
values.append(results['scp'][latency])
avg['scp'][latency] = average(values)
print("Scp results :")
for latency in latencies:
print(results['scp'][latency])
print("%s: [average=%s,standard_deviation=%s]"
%(str(latency), avg['scp'][latency], stddev(values, avg['scp'][latency])))
%(latency, mean(results['scp'][latency]), stdev(results['scp'][latency])))
import time
import os
from statistics import mean, stdev
from distem import Distem
if __name__ == "__main__":
# The path to the compressed filesystem image
# We can point to local file since our homedir is available from NFS
FSIMG = "file:///home/USER/public/distem-fs-jessie.tar.gz"
# Put the physical machines that have been assigned to you
# You can get that by executing: cat $OAR_NODE_FILE | uniq
PNODES = ["pnode1", "pnode2"]
# 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': 'mynetworkk',
'address': "10.158.0.0/22"
}
nodelist = ['node-1', 'node-2']
# Read SSH keys
PRIV_KEY = os.path.join(os.environ["HOME"], ".ssh", "id_rsa")
PUB_KEY = "%s.pub" % PRIV_KEY
private_key = open(os.path.expanduser(PRIV_KEY)).read()
public_key = open(os.path.expanduser(PUB_KEY)).read()
sshkeys = {
"public" : public_key,
"private" : private_key
}
node1 = {
'name': nodelist[0],
'address': []
}
node2 = {
'name': nodelist[1],
'address': []
}
ifname = 'if0'
# Connect to the Distem server (on http://localhost:4567 by default)
distem = Distem()
# Start by creating the virtual network
distem.vnetwork_create(vnet['name'],
vnet['address'])
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
distem.vnode_create(nodelist[0],
{'host': PNODES[0]}, sshkeys)
print("Node %s created" %nodelist[0])
# Specify the path to the compressed filesystem image
# of this virtual node
distem.vfilesystem_create(nodelist[0],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
distem.viface_create(nodelist[0],
'if0',
{'vnetwork': vnet['name'], 'default': 'true'})
print("Interface created")
# Create the first virtual node and set it to be hosted on
# the second physical machine
distem.vnode_create(nodelist[1],
{'host': PNODES[1]},
sshkeys)
print("Node %s created" %nodelist[1])
distem.vfilesystem_create(nodelist[1],
{'image': FSIMG})
# Create a virtual network interface and connect it to vnet
distem.viface_create(nodelist[1],
'if0',
{'vnetwork': vnet['name']})
print("Interface created")
# Starting the virtual nodes using the synchronous method
distem.vnodes_start(nodelist)
print("Nodes started")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment