git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Better mgt of external slices/users/sites + fixes
[sfa.git]
/
sfa
/
planetlab
/
plaggregate.py
diff --git
a/sfa/planetlab/plaggregate.py
b/sfa/planetlab/plaggregate.py
index
b5e8073
..
fdd70e5
100644
(file)
--- a/
sfa/planetlab/plaggregate.py
+++ b/
sfa/planetlab/plaggregate.py
@@
-1,6
+1,6
@@
#!/usr/bin/python
from collections import defaultdict
#!/usr/bin/python
from collections import defaultdict
-from sfa.util.xrn import Xrn, hrn_to_urn, urn_to_hrn
+from sfa.util.xrn import Xrn, hrn_to_urn, urn_to_hrn
, get_authority, get_leaf
from sfa.util.sfatime import utcparse, datetime_to_string
from sfa.util.sfalogging import logger
from sfa.util.faults import SliverDoesNotExist
from sfa.util.sfatime import utcparse, datetime_to_string
from sfa.util.sfalogging import logger
from sfa.util.faults import SliverDoesNotExist
@@
-18,7
+18,7
@@
from sfa.rspecs.elements.lease import Lease
from sfa.rspecs.elements.granularity import Granularity
from sfa.rspecs.version_manager import VersionManager
from sfa.rspecs.elements.granularity import Granularity
from sfa.rspecs.version_manager import VersionManager
-from sfa.planetlab.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename, slicename_to_hrn
+from sfa.planetlab.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename, slicename_to_hrn
, xrn_to_ext_slicename, top_auth
from sfa.planetlab.vlink import get_tc_rate
from sfa.planetlab.topology import Topology
from sfa.storage.alchemy import dbsession
from sfa.planetlab.vlink import get_tc_rate
from sfa.planetlab.topology import Topology
from sfa.storage.alchemy import dbsession
@@
-129,7
+129,13
@@
class PlAggregate:
except ValueError:
pass
else:
except ValueError:
pass
else:
- names.add(xrn.pl_slicename())
+ slice_hrn = xrn.get_hrn()
+ top_auth_hrn = top_auth(slice_hrn)
+ if top_auth_hrn == self.driver.hrn:
+ slice_name = hrn_to_pl_slicename(slice_hrn)
+ else:
+ slice_name = xrn_to_ext_slicename(slice_hrn)
+ names.add(slice_name)
filter = {}
if names:
filter = {}
if names:
@@
-141,7
+147,7
@@
class PlAggregate:
if not slices:
return []
slice = slices[0]
if not slices:
return []
slice = slices[0]
- slice['hrn'] =
PlXrn(auth=self.driver.hrn, slicename=slice['name']).
hrn
+ slice['hrn'] =
slice_
hrn
# get sliver users
persons = []
# get sliver users
persons = []
@@
-165,10
+171,10
@@
class PlAggregate:
# construct user key info
users = []
for person in persons:
# construct user key info
users = []
for person in persons:
- name = person['email'][0:person['email'].index('@')]
+ person_urn = hrn_to_urn(self.driver.shell.GetPersonHrn(int(person['person_id'])), 'user')
user = {
'login': slice['name'],
user = {
'login': slice['name'],
- 'user_urn':
Xrn('%s.%s' % (self.driver.hrn, name), type='user').
urn,
+ 'user_urn':
person_
urn,
'keys': [keys[k_id]['key'] for k_id in person['key_ids'] if k_id in keys]
}
users.append(user)
'keys': [keys[k_id]['key'] for k_id in person['key_ids'] if k_id in keys]
}
users.append(user)
@@
-193,7
+199,7
@@
class PlAggregate:
rspec_node = NodeElement()
# xxx how to retrieve site['login_base']
site=sites[node['site_id']]
rspec_node = NodeElement()
# xxx how to retrieve site['login_base']
site=sites[node['site_id']]
- rspec_node['component_id'] =
PlXrn(self.driver.hrn, hostname=node['hostname']).get_urn(
)
+ rspec_node['component_id'] =
hostname_to_urn(self.driver.hrn, site['login_base'], node['hostname']
)
rspec_node['component_name'] = node['hostname']
rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
rspec_node['authority_id'] = hrn_to_urn(PlXrn.site_hrn(self.driver.hrn, site['login_base']), 'authority+sa')
rspec_node['component_name'] = node['hostname']
rspec_node['component_manager_id'] = Xrn(self.driver.hrn, 'authority+cm').get_urn()
rspec_node['authority_id'] = hrn_to_urn(PlXrn.site_hrn(self.driver.hrn, site['login_base']), 'authority+sa')
@@
-203,7
+209,13
@@
class PlAggregate:
rspec_node['available'] = 'true'
else:
rspec_node['available'] = 'false'
rspec_node['available'] = 'true'
else:
rspec_node['available'] = 'false'
- rspec_node['exclusive'] = 'false'
+
+ #distinguish between Shared and Reservable nodes
+ if node['node_type'] == 'reservable':
+ rspec_node['exclusive'] = 'true'
+ else:
+ rspec_node['exclusive'] = 'false'
+
rspec_node['hardware_types'] = [HardwareType({'name': 'plab-pc'}),
HardwareType({'name': 'pc'})]
# only doing this because protogeni rspec needs
rspec_node['hardware_types'] = [HardwareType({'name': 'plab-pc'}),
HardwareType({'name': 'pc'})]
# only doing this because protogeni rspec needs
@@
-311,6
+323,9
@@
class PlAggregate:
op_status = 'geni_unknown'
else:
allocation_status = 'geni_unallocated'
op_status = 'geni_unknown'
else:
allocation_status = 'geni_unallocated'
+ else:
+ allocation_status = 'geni_unallocated'
+ op_status = 'geni_failed'
# required fields
geni_sliver = {'geni_sliver_urn': rspec_node['sliver_id'],
'geni_expires': rspec_node['expires'],
# required fields
geni_sliver = {'geni_sliver_urn': rspec_node['sliver_id'],
'geni_expires': rspec_node['expires'],
@@
-322,9
+337,6
@@
class PlAggregate:
def get_leases(self, slice=None, options={}):
def get_leases(self, slice=None, options={}):
- if slice_xrn and not slice:
- return []
-
now = int(time.time())
filter={}
filter.update({'clip':now})
now = int(time.time())
filter={}
filter.update({'clip':now})
@@
-350,8
+362,8
@@
class PlAggregate:
site_id=lease['site_id']
site=sites_dict[site_id]
site_id=lease['site_id']
site=sites_dict[site_id]
- rspec_lease['component_id'] = h
ostname_to_urn(self.driver.hrn, site['login_base'], lease['hostname']
)
- slice_hrn = s
licename_to_hrn(self.driver.hrn, lease['name
'])
+ rspec_lease['component_id'] = h
rn_to_urn(self.driver.shell.GetNodeHrn(lease['hostname']), 'node'
)
+ slice_hrn = s
elf.driver.shell.GetSliceHrn(lease['slice_id
'])
slice_urn = hrn_to_urn(slice_hrn, 'slice')
rspec_lease['slice_id'] = slice_urn
rspec_lease['start_time'] = lease['t_from']
slice_urn = hrn_to_urn(slice_hrn, 'slice')
rspec_lease['slice_id'] = slice_urn
rspec_lease['start_time'] = lease['t_from']