Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
python-distem
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
myriads-team
python-distem
Commits
2e4596bf
Commit
2e4596bf
authored
Jul 10, 2019
by
Romain Olivo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modif example & add viface_update
parent
a2c10bcb
Pipeline
#86249
passed with stages
in 2 minutes and 16 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
53 deletions
+31
-53
distem/__init__.py
distem/__init__.py
+28
-1
examples/example.py
examples/example.py
+3
-52
No files found.
distem/__init__.py
View file @
2e4596bf
...
...
@@ -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
Args:
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/resources_desc.md#Network_interface Resource Description - VIface}.
Returns:
{Dictionnary} The virtual network interface description
see {file:files/resources_desc.md#Network_Interfaces 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
:
try
:
...
...
@@ -788,3 +814,4 @@ class Distem():
return
result
else
:
raise
Exception
(
response
.
headers
[
'X-Application-Error-Code'
])
examples/example.py
View file @
2e4596bf
...
...
@@ -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__":
FSIMG
=
"file:///home/rolivo/distem_img/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
=
[
"econome-
21.nantes.grid5000.fr"
,
"econome-5
.nantes.grid5000.fr"
]
PNODES
=
[
"econome-
14.nantes.grid5000.fr"
,
"econome-19
.nantes.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'
:
'
lol
'
,
'name'
:
'
mynetwork
'
,
'address'
:
"10.176.0.0/22"
}
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"
)
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 ;
\
for i in `seq 1 100`; do
\
dd if=/dev/zero of=$i bs=1K count=50;
\
done'
)
# Printing the current latency
start_time
=
float
(
time
.
time
())
distem
.
vnode_execute
(
node1
[
'name'
],
'hostname'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment