iotlab.py 3.29 KB
Newer Older
albert's avatar
albert committed
1
from myslicelib.api.sfa.sfa import SfaError
Loic Baron's avatar
Loic Baron committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
from myslicelib.util.sfabuilder import SfaBuilder

class Iotlab(SfaBuilder):

    def builder(self, urn, record_dict):
        #<?xml version="1.0"?>
        #  <rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.geni.net/resources/rspec/3" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" type="request" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd" expires="2014-05-30T17:07:46Z" generated="2014-05-30T16:07:46Z">
        #    <node component_manager_id="urn:publicid:IDN+iotlab+authority+cm" component_id="urn:publicid:IDN+iotlab+node+a8-144.devgrenoble.iot-lab.info" component_name="a8-144.devgrenoble.iot-lab.info">
        #      <sliver_type name="iotlab-node"/>
        #    </node>
        #    <node component_manager_id="urn:publicid:IDN+iotlab+authority+cm" component_id="urn:publicid:IDN+iotlab+node+m3-35.devstras.iot-lab.info" component_name="m3-35.devstras.iot-lab.info">
        #      <sliver_type name="iotlab-node"/>
        #    </node>
        #    <lease slice_id="urn:publicid:IDN+ple:upmc+slice+myslicedemo" start_time="1402005600" duration="420">
        #      <node component_id="urn:publicid:IDN+iotlab+node+m3-35.devstras.iot-lab.info"/>
        #      <node component_id="urn:publicid:IDN+iotlab+node+a8-144.devgrenoble.iot-lab.info"/>
        #    </lease>
        #  </rspec>

Quan Zhou's avatar
Quan Zhou committed
21
        rspec = '<?xml version="1.0"?><rspec xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.geni.net/resources/rspec/3" xmlns:plos="http://www.planet-lab.org/resources/sfa/ext/plos/1" xmlns:flack="http://www.protogeni.net/resources/rspec/ext/flack/1" xmlns:planetlab="http://www.planet-lab.org/resources/sfa/ext/planetlab/1" type="request" xsi:schemaLocation="http://www.geni.net/resources/rspec/3 http://www.geni.net/resources/rspec/3/request.xsd http://www.planet-lab.org/resources/sfa/ext/planetlab/1 http://www.planet-lab.org/resources/sfa/ext/planetlab/1/planetlab.xsd http://www.planet-lab.org/resources/sfa/ext/plos/1 http://www.planet-lab.org/resources/sfa/ext/plos/1/plos.xsd" expires="2014-05-30T17:07:46Z" generated="2014-05-30T16:07:46Z">'
Loic Baron's avatar
Loic Baron committed
22
23
24
25
26
27
28
29
30
31

        for r in record_dict['resources']:
            rspec += '<node component_manager_id="'+r['manager']+'" component_id="'+r['id']+'" component_name="'+r['id'].split('+')[-1]+'">'
            rspec += '<sliver_type name="iotlab-node"/>'
            rspec += '</node>'

        if 'leases' not in record_dict:
            raise SfaError('Leases must be specified to reserve FIT IoT-LAB resources')

        for l in record_dict['leases']:
32
            rspec += '<lease slice_id="'+urn+'" start_time="'+str(l['start_time'])+'" duration="'+str(int(int(l['duration'])/60))+'">'
Loic Baron's avatar
Loic Baron committed
33
34
35
36
37
38
            for r in l['resources']:
                rspec += '<node component_id="'+r+'"/>'
            rspec += '</lease>'

        rspec += '</rspec>'
        return rspec