Merge branch 'geni-v3' of ssh://git.onelab.eu/git/sfa into geni-v3
Loic Baron [Wed, 30 Jul 2014 08:15:32 +0000 (10:15 +0200)]
Conflicts:
sfa/iotlab/iotlabaggregate.py
sfa/iotlab/iotlabslices.py

1  2 
sfa/iotlab/iotlabaggregate.py
sfa/iotlab/iotlabdriver.py
sfa/iotlab/iotlabslices.py

@@@ -400,12 -401,11 +401,13 @@@ class IotlabAggregate
          return rspec_node
  
  
-     def get_leases(self, slice=None, options={}):
+     def get_leases(self, slice=None, options=None):
+         if options is None: options={}
          filter={}
          if slice:
 -           filter.update({'name':slice['slice_name']})
 +           #filter.update({'name':slice['slice_name']}) # JORDAN: this is = "upmc" !!!
 +           filter.update({'slice_hrn':slice['slice_hrn']}) # JORDAN: this is = "upmc" !!!
 +            # slice_hrn = "ple.upmc.myslicedemo
          #return_fields = ['lease_id', 'hostname', 'site_id', 'name', 't_from', 't_until']
          leases = self.driver.GetLeases(lease_filter_dict=filter)
          grain = self.driver.testbed_shell.GetLeaseGranularity()
          .. seealso:: http://groups.geni.net/geni/wiki/GAPI_AM_API_V3/CommonConcepts#urns
          """
  
 +        SLICE_KEY = 'slice_hrn' # slice_hrn
+         if options is None: options={}
          slice_ids = set()
          node_ids = []
          for urn in urns:
@@@ -1563,42 -1516,26 +1568,43 @@@ class IotlabDriver(Driver)
              client_id = hostname
              node_urn = xrn_object(self.testbed_shell.root_auth, hostname).urn
              component_id = node_urn
 -            if 'reg-urn' in current_slice:
 -                slice_urn = current_slice['reg-urn']
 +            if current_slice is not None:
 +                if 'reg-urn' in current_slice:
 +                    slice_urn = current_slice['reg-urn']
 +                else:
 +                    slice_urn = current_slice['urn']
              else:
 -                slice_urn = current_slice['urn']
 -            for lease in leases:
 +                slice_urn = slice_record['urn']
 +            # JORDAN: We loop over leases previously in the slice
 +            for lease in leases: # rspec_requested_leases ?????? XXX
 +                logger.debug("FOR LEASE LOOP JORDAN lease=%r" % lease)
 +                logger.debug("JORDAN hostname=%r lease['reserved_nodes']=%r, bool=%r" % (hostname, lease['reserved_nodes'], hostname in lease['reserved_nodes']))
                  if hostname in lease['reserved_nodes']:
 +                    logger.debug("JORDAN IF OK")
                      index = lease['reserved_nodes'].index(hostname)
 +                    logger.debug("JORDAN index=%r" % index)
                      sliver_hrn = '%s.%s-%s' % (self.hrn, lease['lease_id'],
                                     lease['resource_ids'][index] )
 -            sliver_id = Xrn(sliver_hrn, type='sliver').urn
 -            record = SliverAllocation(sliver_id=sliver_id, client_id=client_id,
 -                                      component_id=component_id,
 -                                      slice_urn = slice_urn,
 -                                      allocation_state='geni_allocated')
 -            record.sync(self.api.dbsession())
  
 -        return aggregate.describe([xrn.get_urn()], version=rspec.version)
 +                    logger.debug("LOIC sliver_hrn=%r" % sliver_hrn)
 +                    sliver_id = Xrn(sliver_hrn, type='sliver').urn
 +
 +                    logger.debug("LOIC sliver_id=%r" % sliver_id)
 +                    record = SliverAllocation(sliver_id=sliver_id, client_id=client_id,
 +                                              component_id=component_id,
 +                                              slice_urn = slice_urn,
 +                                              allocation_state='geni_allocated')
 +                    record.sync(self.api.dbsession())
 +
 +        # JORDAN : added describe_options which was not specified at all
 +        describe_options = {
 +            'geni_slice_urn': urn,
 +            'list_leases': 'all',
 +        }
 +        return aggregate.describe([xrn.get_urn()], version=rspec.version, options=describe_options)
  
-     def provision(self, urns, options={}):
+     def provision(self, urns, options=None):
+         if options is None: options={}
          # update users
          slices = IotlabSlices(self)
          aggregate = IotlabAggregate(self)
Simple merge