X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fsfarspec_proc.py;h=f8c8bb2fb78cf6d4c738629054a36d120a0cc9c7;hb=6285ca51026efb69642eea9dfc7c480e722d84a9;hp=66c2c8dc2c35009cb3881feb9441c64abb92142e;hpb=2e80f0fafa0c2ef6a5f536efd4c868c91468f962;p=nepi.git diff --git a/src/nepi/util/sfarspec_proc.py b/src/nepi/util/sfarspec_proc.py index 66c2c8dc..f8c8bb2f 100644 --- a/src/nepi/util/sfarspec_proc.py +++ b/src/nepi/util/sfarspec_proc.py @@ -3,9 +3,8 @@ # Copyright (C) 2013 INRIA # # This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation; # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -67,19 +66,19 @@ class SfaRSpecProcessing(object): try: nodes = rspec.version.get_nodes() - except Exception, e: + except Exception as e: self._log.warn("Could not retrieve nodes in RSpec: %s" % e) try: leases = rspec.version.get_leases() - except Exception, e: + except Exception as e: self._log.warn("Could not retrieve leases in RSpec: %s" % e) try: links = rspec.version.get_links() - except Exception, e: + except Exception as e: self._log.warn("Could not retrieve links in RSpec: %s" % e) try: channels = rspec.version.get_channels() - except Exception, e: + except Exception as e: self._log.warn("Could not retrieve channels in RSpec: %s" % e) resources = [] @@ -133,7 +132,7 @@ class SfaRSpecProcessing(object): # } - def build_sfa_rspec(self, slice_id, resources, leases): + def build_sfa_rspec(self, slice_id, resources, properties, leases): """ Build the XML RSpec from list of resources' urns. eg. resources = ["urn:publicid:IDN+ple:modenaple+node+planetlab-1.ing.unimo.it"] @@ -158,6 +157,7 @@ class SfaRSpecProcessing(object): links = [] self._log.debug("Building RSpec for resources %s" % resources) cardinal = 0 + wilab = False for urn in resources: # XXX TO BE CORRECTED, this handles None values if not urn: @@ -175,14 +175,16 @@ class SfaRSpecProcessing(object): if resource_type == 'node': # XXX dirty hack WiLab !!! -# Commented Lucia, only works with config file, not the case for nepi +# Commented Lucia, doesn't work for wilabt # if self.config: # if 'wilab2' in self.config['sm']: # resource['client_id'] = "PC" # resource['sliver_type'] = "raw-pc" if 'wilab2' in urn: + wilab = True resource['client_id'] = "node%s" % cardinal resource['sliver_type'] = "raw-pc" + resource['disk_image'] = "hola" top_auth = resource_hrn.replace("\\", "").split('.') top_auth.pop() top_auth = '.'.join(top_auth) @@ -195,14 +197,26 @@ class SfaRSpecProcessing(object): elif resource_type == 'channel': channels.append(resource) else: - raise Exception, "Not supported type of resource" + raise Exception("Not supported type of resource") rspec.version.add_nodes(nodes, rspec_content_type="request") #rspec.version.add_leases(leases) #rspec.version.add_links(links) #rspec.version.add_channels(channels) - self._log.debug("request rspec: %s"%rspec.toxml()) - return rspec.toxml() + #self._log.debug("request rspec: %s"%rspec.toxml()) + string = rspec.toxml() + if wilab and properties is not None: + ## dirty hack for the f4f demo + b = string.split('\n') + for i, n in enumerate(b): + if 'sliver_type name="raw-pc"' in n: + b[i] = '' + b.insert(i+1, '' % properties['disk_image']) + #b.insert(i+1, '' % properties['disk_image']) + b.insert(i+2, '') + string = ''.join(b) + self._log.debug("request rspec : %s" % string) + return string