Allocating resource via geni-lib (externally)

133 views
Skip to first unread message

Ivo Jimenez

unread,
Mar 28, 2017, 5:16:08 PM3/28/17
to cloudla...@googlegroups.com

Hi,

I'd like to request CloudLab nodes using geni-lib externally (from one of my servers). I know this has been discussed before, in particular here and here but I haven't been able to accomplish this. This is what I have so far:


#!/usr/bin/env python from geni.aggregate import cloudlab as cl from geni.rspec import pg as rspec from geni.aggregate import FrameworkRegistry from geni.aggregate.context import Context from geni.aggregate.user import User ctxt = loadContext("/mnt/context.json", key_passphrase=True) node = rspec.RawPC("node") node.disk_image = "urn:publicid:IDN+image//UBUNTU16-64-STD" r = rspec.Request() r.addResource(node) cl.UtahDDC.createsliver(ctxt, "myslice", r)

The contents of context.json:

{
  "framework" : "emulab-ch2",
  "cert-path" : "/path/to/cloudlab.pem",
  "key-path" : "/path/to/cloudlab.pem",
  "user-name" : "ivotron",
  "user-urn" : "urn:publicid:IDN+emulab.net+user+ivotron",
  "user-pubkeypath" : "/my/.ssh/id_rsa.pub",
  "project" : "myproject"
}

The output I get:

root@25c1c509274d:/# ./request.py
Private key passphrase:
Traceback (most recent call last):
  File "./request.py", line 15, in <module>
    cl.UtahDDC.createsliver(ctxt, "myslice", r)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/core.py", line 144, in createsliver
    res = self.api.createsliver(context, self.url, sname, rspec_data)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/apis.py", line 83, in createsliver
    sinfo = context.getSliceInfo(sname)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 269, ingetSliceInfo
    scinfo = SliceCredInfo(self, sname)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 51, in __init__
    self._build()
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 57, in _build
    self._downloadCredential()
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 62, in _downloadCredential
    cred = self.context.cf.getSliceCredentials(self.context, self.slicename)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/frameworks.py", line 418,in getSliceCredentials
    raise ClearinghouseError(res["output"], res)
geni.aggregate.frameworks.ClearinghouseError: get_credentials encountered an error requesting the slice credential: No such Slice

Also, since I'd like to fully automate this, I was wondering if there's any way of providing the password on the script itself?

Thanks!

Nicholas Bastin

unread,
Mar 28, 2017, 7:11:16 PM3/28/17
to Ivo Jimenez, cloudlab-users
On Tue, Mar 28, 2017 at 2:15 PM, Ivo Jimenez <ivoji...@gmail.com> wrote:

I'd like to request CloudLab nodes using geni-lib externally (from one of my servers). I know this has been discussed before, in particular here and here but I haven't been able to accomplish this. This is what I have so far:

root@25c1c509274d:/# ./request.py
Private key passphrase:
Traceback (most recent call last):
  File "./request.py", line 15, in <module>
    cl.UtahDDC.createsliver(ctxt, "myslice", r)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/core.py", line 144, in createsliver
    res = self.api.createsliver(context, self.url, sname, rspec_data)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/apis.py", line 83, in createsliver
    sinfo = context.getSliceInfo(sname)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 269, ingetSliceInfo
    scinfo = SliceCredInfo(self, sname)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 51, in __init__
    self._build()
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 57, in _build
    self._downloadCredential()
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/context.py", line 62, in _downloadCredential
    cred = self.context.cf.getSliceCredentials(self.context, self.slicename)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/frameworks.py", line 418,in getSliceCredentials
    raise ClearinghouseError(res["output"], res)
geni.aggregate.frameworks.ClearinghouseError: get_credentials encountered an error requesting the slice credential: No such Slice

You can get more useful logs if you give geni-lib a log handle to record the input and output of XML-RPC requests, which will hopefully make this problem easier to track down:

import logging
from geni.minigcf.config import HTTP
HTTP.LOG_URLS = (logging, logging.ERROR)
HTTP.LOG_RAW_REQUESTS = (logging, logging.ERROR)
HTTP.LOG_RAW_RESPONSES = (logging, logging.ERROR)

(You can change the log handle and level as you desire - this will spew to your screen but you can make a real log handle to pass it)

If you set that and then run your script, that log output will hopefully help diagnose the problem.

Also, since I'd like to fully automate this, I was wondering if there's any way of providing the password on the script itself?

You can supply the passphrase itself as a string to key_passphrase (instead of True, which generates the input query).  I don't recommend this, but the option is available.

--
Nick 

Nicholas Bastin

unread,
Mar 28, 2017, 7:45:18 PM3/28/17
to Ivo Jimenez, cloudlab-users
On Tue, Mar 28, 2017 at 2:15 PM, Ivo Jimenez <ivoji...@gmail.com> wrote:


#!/usr/bin/env python from geni.aggregate import cloudlab as cl from geni.rspec import pg as rspec from geni.aggregate import FrameworkRegistry from geni.aggregate.context import Context from geni.aggregate.user import User ctxt = loadContext("/mnt/context.json", key_passphrase=True) node = rspec.RawPC("node") node.disk_image = "urn:publicid:IDN+image//UBUNTU16-64-STD" r = rspec.Request() r.addResource(node) cl.UtahDDC.createsliver(ctxt, "myslice", r)
Does the slice "myslice" actually exist?  The error message you're getting might actually just be true.

--
Nick 

Nicholas Bastin

unread,
Mar 28, 2017, 7:52:32 PM3/28/17
to Ivo Jimenez, cloudlab-users
I was able to create and use a slice credential using geni-lib with a Cloudlab credential, so I think there's nothing inherently wrong with the workflow - possibly your project or slice names are not correct.

You can create a slice using the following:

>>> import datetime
>>> slice_exp = datetime.datetime.now() + datetime.timedelta(days=5)
>>> sinfo = context.cf.createSlice(context, "test-20170328", exp = slice_exp)
>>> pprint.pprint(sinfo)
{'SLICE_CREATION': '2017-03-28T23:46:26Z',
 'SLICE_DESCRIPTION': '',
 'SLICE_EXPIRATION': '2017-04-02T16:46:23Z',
 'SLICE_EXPIRED': False,
 'SLICE_NAME': 'test-20170328',
 'SLICE_PROJECT_URN': 'urn:publicid:IDN+emulab.net+project+ig-control-of',
 'SLICE_UID': 'c1b0bba4-1410-11e7-ac8d-90e2ba22fee4',
 'SLICE_URN': 'urn:publicid:IDN+emulab.net:ig-control-of+slice+test-20170328',
 '_EMULAB_SLICE_HRN': 'utahemulab.test-20170328'}


Set your slice expiration and name as appropriate, of course.

--
Nick

Ivo Jimenez

unread,
Mar 29, 2017, 1:15:44 PM3/29/17
to Nicholas Bastin, cloudlab-users

Thanks a lot. So I was missing a ctxt.cf.createSlice. I can create the slice without problems but when I try to request resources, I get a timeout:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/core.py", line 144, in createsliver
    res = self.api.createsliver(context, self.url, sname, rspec_data)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/apis.py", line 91, in createsliver
    res = AM2.createsliver(url, False, context.cf.cert, context.cf.key, [cred_data], sinfo.urn, rspec, udata)
  File "/usr/local/lib/python2.7/dist-packages/geni/minigcf/amapi2.py", line 61, in createsliver
    return _rpcpost(url, req_data, (cert, key), root_bundle)
  File "/usr/local/lib/python2.7/dist-packages/geni/minigcf/util.py", line 25, in _rpcpost
    timeout = config.HTTP.TIMEOUT, allow_redirects = config.HTTP.ALLOW_REDIRECTS)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 511, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 449, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='boss.utahddc.geniracks.net',port=12369): Read timed out. (read timeout=30)

For completeness, this is what I'm executing

from geni.aggregate import cloudlab as cl
from geni.rspec import pg as rspec
from geni.util import loadContext

import datetime

ctxt = loadContext("/mnt/context.json", key_passphrase=True)

slice_exp = datetime.datetime.now() + datetime.timedelta(hours=1)

ctxt.cf.createSlice(ctxt, "myslice", exp=slice_exp)

node = rspec.RawPC("node")
img = "urn:publicid:IDN+apt.emulab.net+image+schedock-PG0:docker-ubuntu16:0"
node.disk_image = img

r = rspec.Request()
r.addResource(node)

cl.UtahDDC.createsliver(ctxt, "myslice", r)

Another question I hope you can help with is, how can I ensure to "teardown" any resources I have created?

Thanks!

Nicholas Bastin

unread,
Mar 29, 2017, 2:06:42 PM3/29/17
to Ivo Jimenez, cloudlab-users
On Wed, Mar 29, 2017 at 10:15 AM, Ivo Jimenez <ivoji...@gmail.com> wrote:

Thanks a lot. So I was missing a ctxt.cf.createSlice. I can create the slice without problems but when I try to request resources, I get a timeout:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/core.py", line 144, in createsliver
    res = self.api.createsliver(context, self.url, sname, rspec_data)
  File "/usr/local/lib/python2.7/dist-packages/geni/aggregate/apis.py", line 91, in createsliver
    res = AM2.createsliver(url, False, context.cf.cert, context.cf.key, [cred_data], sinfo.urn, rspec, udata)
  File "/usr/local/lib/python2.7/dist-packages/geni/minigcf/amapi2.py", line 61, in createsliver
    return _rpcpost(url, req_data, (cert, key), root_bundle)
  File "/usr/local/lib/python2.7/dist-packages/geni/minigcf/util.py", line 25, in _rpcpost
    timeout = config.HTTP.TIMEOUT, allow_redirects = config.HTTP.ALLOW_REDIRECTS)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 511, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 449, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='boss.utahddc.geniracks.net',port=12369): Read timed out. (read timeout=30)

This *probably* succeeded, just after 30 seconds (you can check with sliverstatus).  You can fix this problem by making the timeout longer:

from geni.minigcf.config import HTTP
HTTP.TIMEOUT = 90

We will likely make the default a larger number in a future release, as 30 is too short for a few sites.

Another question I hope you can help with is, how can I ensure to "teardown" any resources I have created?

You should call deletesliver(context, SLICENAME) when you are done using your resources.  They will also be automatically deleted at their expiration date of course, but please delete them beforehand if you are finished using them.

--
Nick 

Ivo Jimenez

unread,
Apr 20, 2017, 1:33:21 AM4/20/17
to Nicholas Bastin, cloudlab-users
Sorry for the delay. all worked great. Thanks!

Ivo Jimenez

unread,
Apr 20, 2017, 3:22:21 AM4/20/17
to Nicholas Bastin, cloudlab-users
Sorry to bother again. One last question: how can I delete a slice? I can successfully delete slivers but I wasn't able to find a deleteslice method. Thanks a lot!

Robert P Ricci

unread,
Apr 20, 2017, 8:45:41 AM4/20/17
to Ivo Jimenez, Nicholas Bastin, cloudlab-users
You actually cannot delete a slice, you can only let it expire. The reason that this is the case is that this set of APIs was defined for a loosely-coupled federation, in which the entity that tracks the slice cannot know with 100% certainty where resources might exists that have been added to that slice; as a result, the only way to maintain global consistency is to make sure that all of those resources have lifetimes <= the slice lifetime, and to prevent deletion of the slice itself before it expires.

--
You received this message because you are subscribed to the Google Groups "cloudlab-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloudlab-user...@googlegroups.com.
To post to this group, send email to cloudla...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloudlab-users/CAJw4g7UqozLyZDyVsZ-G%3DdWbtdP85RBFHnXaKkJfi1ePmsUzHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Ivo Jimenez

unread,
Apr 20, 2017, 6:06:28 PM4/20/17
to Robert P Ricci, Nicholas Bastin, cloudlab-users
I see, makes sense, thanks a lot!

Ivo Jimenez

unread,
May 26, 2017, 1:47:40 PM5/26/17
to cloudlab-users
Is there a list of <agg-name,hw-type> resources available via cloudlab (aggregates in package geni.aggregate.cloudlab )? This is what I have so far:

Utah        -> m400,m510
Wisconsin   -> c220g1,c220g2,c240g1,c240g2
Clemson     -> c8220,c8220x,c6320,c4130
Apt         -> r320,c6220
UtahDDC     -> dl360
Kentucky_PG -> ?
UTAH_PG     -> ?
Wall1_PG    -> ?
Wall2_PG    -> ?
wilab_PG    -> ?

From CloudLab's cluster graph web UI, I can see there are d430, d710 and pc3000 but I cannot identify which aggregate module they correspond to. Is there an 'emulab' aggreate? Also, from this page, I can see there are other types such as d820 and pc2400w. Can those be requested too? If they do, which aggregate module names do they correspond to?

thanks a lot!


Nicholas Bastin

unread,
May 26, 2017, 3:20:20 PM5/26/17
to Ivo Jimenez, cloudlab-users
You can get the hardware types from the advertisements, if you have a working context object, although they are fairly verbose:

for am in CLAM.aggregates():
    print am.name
    ad = am.listresources(context)
    hwtypes = set()
    for node in ad.nodes:
        hwtypes |= set(node.hardware_types.keys())
    print hwtypes
    print "----------"

apt
set(['x86_64', 'lan', 'r720', 'c6220', 'interconnect', 'r320-vm', 'r720-vm', 'c6220-vm', 'r320', 'pcvm', 'pcsanhost', 'pc', 'switch', 'ipv4', 'interconnect-vm', 'x86_64-vm'])
----------
cl-clemson
set(['', 'bridge', 'lan', 'c8220-vm', 'dss7500-vm', 'dss7500', 'c8220x', 'interconnect', 'c4130-vm', 'c6320', 'c8220x-vm', 'pcvm', 'c8220', 'pcsanhost', 'delay-c4130', 'c6320-vm', 'delay', 'pc', 'switch', 'ipv4', 'c4130', 'bridge-c4130', 'interconnect-vm', '-vm'])
----------
cl-utah
set(['m510', 'lan', 'x86_64', 'pcsanhost', 'm400', 'dboxvm', 'interconnect', 'm510-vm', 'pcvm', 'aarch64', 'dboxvm-vm', 'pc', 'switch', 'ipv4', 'interconnect-vm', 'x86_64-vm'])
----------
ig-utahddc
set(['delay-dl360', 'bridge', 'lan', 'pcvm', 'interconnect', 'dl360-vm', 'delay', 'pc', 'switch', 'ipv4', 'interconnect-vm', 'dl360', 'bridge-dl360'])
----------
cl-wisconsin
set(['', 'lan', 'c220g1-vm', 'interconnect', 'c240g2-vm', 'c240g1-vm', 'c240g1', 'c240g2', 'C240M4', 'pcvm', 'pcsanhost', 'c220g2', 'pc', 'switch', 'c220g1', 'c220g2-vm', 'interconnect-vm', 'C240M4-vm', '-vm', 'ipv4'])
----------

You can generate the same list for emulab sites iteratinv over geni.aggregate.protogeni.aggregates():

pg-kentucky
set(['', 'bridge', 'delay-pc2400', 'pcvm3500', 'pc3500', 'delay-pc3300', 'pc2400-vm', 'bridge-pc2400', 'pc3400-vm', 'delay-pc3000', 'pcvm', 'delay', 'pc', 'pcvm3300', 'ipv4', 'pcvm3000', 'bridge-pc3000', 'pc3400', 'pc3000-vm', 'lan', 'pc3300-vm', 'pc3000', 'interconnect', 'pcvm2400', 'bridge-pc3300', 'pc2400', 'pc3500-vm', '-vm', 'delay-pc3500', 'switch', 'pc3300', 'bridge-pc3500', 'delay-pc3400', 'interconnect-vm', 'pcvm3400', 'bridge-pc3400'])
----------
pg-utah
set(['', 'delay-d430', 'pc2400c2', 'bridge', 'firewall', 'pc2gen', 'pcvm2830qx2', 'd530', 'pcRemote', 'd430', 'pcvm', 'bbgeni-vm', 'bbg', 'd430k', 'netfpga2', 'pc', 'ipv4', 'pc2830qx2-vm', 'spp', 'pcpg-i2-vm', 'd710-vm', 'pcvwa', 'd2100-vm', 'bridge-d430k', 'pcivy', 'emote', 'pcvmpg', 'd710', 'flex900', 'motehost', 'spp-vm', 'd430-vm', 'pc2830qx2', 'bridge-d710', 'pc2400hp', 'd2100', 'enodeb', 'sppvm', 'nuc5300-vm', '80211', 'ue', 'd430k-vm', 'x86_64', 'gec16-port', 'xcvr2450', 'delay-d710', 'delay-d430k', 'pcivy-vm', 'pcvmpg-i2', 'delay-pc3000', 'd820', '80211b', 'wire', 'interconnect', '80211g', 'pcsanhost', 'nuc5300', 'bridge-d430', 'gec16port', 'delay', 'pcpg-i2', 'pcvmivy', 'bridge-pc3000', '-vm', 'x86_64-vm', 'netfpga', 'lan', 'hp5406', 'pm-mote', 'pcvroninet', '80211a', 'nexus5', 'interconnect-vm', 'pcpg', 'pcvron', 'd530-vm', 'bbgeni', 'powermon', 'switch', 'd820-vm', 'pc3000', 'bbgenivm', 'pcpg-vm'])
----------
pg-wall1
set(['pcgen02-5p-vm', 'flex900', 'lan', 'pcgen02-1p', 'pcgen00-1p', 'pcvmgen02-5p', 'ZOTAC-vm', 'pcgen04lsi-vm', 'pcgen02-2p', 'APU-vm', 'ipv4', 'pcvmgen02-4p', 'delay-pcgen02-2p', 'interconnect', 'pcgen02-1p-vm', 'xcvr2450', 'delay-pcgen02-5p', '80211b', 'pcgen04lsi', 'pcvmgen02-1p', '80211a', 'pcvm', '80211g', 'pcvmgen02-2p', 'NUC', 'delay-pcgen02-4p', 'pcvmgen04lsi', 'SWITCHPORT', 'NUC-vm', 'APU', 'delay', 'pc', 'switch', 'pcgen02-2p-vm', 'pcgen02-4p-vm', '80211', 'pcgen02-4p', 'interconnect-vm', 'ZOTAC', 'pcgen01-5p', 'pcgen02-5p'])
----------
pg-wall2
set(['pcgen05b', 'pcgen04raid-2p-vm', 'pcgen03-7p', 'pcgen03-5p', 'pcgen04-vm', 'ZOTAC-vm', 'pcgen05b-vm', 'pcgen04lsi-vm', 'pcgen05-vm', 'supernode', 'flex900', 'delay-pcgen05b', 'gpunode', 'pcvmgen03-2p', 'netfpga2', 'pcvmgen04raid-2p', 'gpunode-vm', 'gpunode2', 'delay', 'pcvmgen03-4p', 'delay-pcgen03-4p', 'pcvm', 'delay-pcgen05', 'SWITCHPORT', 'pcsanhost', 'pcgen04-1p', 'pcvmgen04lsi', 'switch', 'xcvr2450', 'pcgen03-1p-vm', 'delay-pcgen04-2p', 'pc', 'pcgen04lsi', 'pcgen04raid-2p', 'delay-pcgen03-2p', 'pcgen03-5p-vm', 'pcgen03-4p', 'pcgen03-2p', 'pcvmgen03-5p', 'ipv4', 'netfpga', '80211b', 'lan', 'delay-pcgen04', 'pcgen03-4p-vm', 'pcgen04', 'pcgen05', 'ZOTAC', 'interconnect', 'pcvmgen03-1p', '80211a', 'pcgen04-1p-vm', 'pcvmgen04-1p', 'delay-pcgen04lsi', 'netfpga2-vm', 'pcgen04lsi-2p', 'pcgen04lsi-2p-vm', '80211g', 'delay-pcgen03-5p', 'pcgen04-2p-vm', 'pcvmgen05', 'pcvmgen04', 'delay-pcgen03-7p', 'pcvmgen04-2p', 'pcvmgen03-7p', 'pcvmgen05b', 'pcgen03-2p-vm', 'pcgen04-2p', 'supernode-vm', 'netfpga-vm', 'pcgen03-1p', 'pcvmgen04lsi-2p', '80211', 'interconnect-vm', 'pcgen03-7p-vm', 'gpunode2-vm'])
----------
pg-wilab
set(['LTE-FEMTOCELL', 'flex900', 'lan', 'ZOTAC1P', 'SERVER1P', 'ARDUINO', 'ZOTAC', 'APU-vm', 'DSS', 'WARP', 'SERVER1P-vm', 'RASPBERRYPI', 'SERVER5P', 'USRP', 'interconnect-vm', 'ZOTAC1P-vm', 'interconnect', 'SERVER5P-vm', 'SERVER1G2X-vm', '80211b', '80211a', 'pcvm', '80211g', 'MOBILE', '80211', 'ZOTAC-vm', 'TLVAP', 'MOBILE-vm', 'APU', 'ALIX', 'pc', 'switch', 'ipv4', 'DSS-vm', 'SERVER1G2X', 'xcvr2450'])
----------

--
Nick

Ivo Jimenez

unread,
May 26, 2017, 4:41:52 PM5/26/17
to Nicholas Bastin, cloudlab-users
Ahh, this is awesome, thanks a lot!
Reply all
Reply to author
Forward
0 new messages