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
bugfix - the way update_driver_relation(s) gets to access its driver
[sfa.git]
/
sfa
/
managers
/
registry_manager.py
diff --git
a/sfa/managers/registry_manager.py
b/sfa/managers/registry_manager.py
index
f55e69b
..
bbd958e
100644
(file)
--- a/
sfa/managers/registry_manager.py
+++ b/
sfa/managers/registry_manager.py
@@
-25,7
+25,8
@@
from sqlalchemy.orm.collections import InstrumentedList
class RegistryManager:
class RegistryManager:
- def __init__ (self, config): pass
+ def __init__ (self, config):
+ logger.info("Creating RegistryManager[%s]"%id(self))
# The GENI GetVersion call
def GetVersion(self, api, options):
# The GENI GetVersion call
def GetVersion(self, api, options):
@@
-50,7
+51,7
@@
class RegistryManager:
# Slivers don't have credentials but users should be able to
# specify a sliver xrn and receive the slice's credential
if type == 'sliver' or '-' in Xrn(hrn).leaf:
# Slivers don't have credentials but users should be able to
# specify a sliver xrn and receive the slice's credential
if type == 'sliver' or '-' in Xrn(hrn).leaf:
- slice_xrn =
self
.driver.sliver_to_slice_xrn(hrn)
+ slice_xrn =
api
.driver.sliver_to_slice_xrn(hrn)
hrn = slice_xrn.hrn
# Is this a root or sub authority
hrn = slice_xrn.hrn
# Is this a root or sub authority
@@
-173,7
+174,7
@@
class RegistryManager:
if details:
# in details mode we get as much info as we can, which involves contacting the
# testbed for getting implementation details about the record
if details:
# in details mode we get as much info as we can, which involves contacting the
# testbed for getting implementation details about the record
-
self
.driver.augment_records_with_testbed_info(local_dicts)
+
api
.driver.augment_records_with_testbed_info(local_dicts)
# also we fill the 'url' field for known authorities
# used to be in the driver code, sounds like a poorman thing though
def solve_neighbour_url (record):
# also we fill the 'url' field for known authorities
# used to be in the driver code, sounds like a poorman thing though
def solve_neighbour_url (record):
@@
-265,18
+266,19
@@
class RegistryManager:
# subject_record describes the subject of the relationships
# ref_record contains the target values for the various relationships we need to manage
# (to begin with, this is just the slice x person (researcher) and authority x person (pi) relationships)
# subject_record describes the subject of the relationships
# ref_record contains the target values for the various relationships we need to manage
# (to begin with, this is just the slice x person (researcher) and authority x person (pi) relationships)
- def update_driver_relations (self,
subject_obj, ref_obj, dbsession
):
+ def update_driver_relations (self,
api, subject_obj, ref_obj
):
type=subject_obj.type
#for (k,v) in subject_obj.__dict__.items(): print k,'=',v
if type=='slice' and hasattr(ref_obj,'researcher'):
type=subject_obj.type
#for (k,v) in subject_obj.__dict__.items(): print k,'=',v
if type=='slice' and hasattr(ref_obj,'researcher'):
- self.update_driver_relation(
subject_obj, ref_obj.researcher, 'user', 'researcher', dbsession
)
+ self.update_driver_relation(
api, subject_obj, ref_obj.researcher, 'user', 'researcher'
)
elif type=='authority' and hasattr(ref_obj,'pi'):
elif type=='authority' and hasattr(ref_obj,'pi'):
- self.update_driver_relation(
subject_obj,ref_obj.pi, 'user', 'pi', dbsession
)
+ self.update_driver_relation(
api, subject_obj,ref_obj.pi, 'user', 'pi'
)
# field_key is the name of one field in the record, typically 'researcher' for a 'slice' record
# hrns is the list of hrns that should be linked to the subject from now on
# target_type would be e.g. 'user' in the 'slice' x 'researcher' example
# field_key is the name of one field in the record, typically 'researcher' for a 'slice' record
# hrns is the list of hrns that should be linked to the subject from now on
# target_type would be e.g. 'user' in the 'slice' x 'researcher' example
- def update_driver_relation (self, record_obj, hrns, target_type, relation_name, dbsession):
+ def update_driver_relation (self, api, record_obj, hrns, target_type, relation_name):
+ dbsession=api.dbsession()
# locate the linked objects in our db
subject_type=record_obj.type
subject_id=record_obj.pointer
# locate the linked objects in our db
subject_type=record_obj.type
subject_id=record_obj.pointer
@@
-284,7
+286,7
@@
class RegistryManager:
link_id_tuples = dbsession.query(RegRecord.pointer).filter_by(type=target_type).filter(RegRecord.hrn.in_(hrns)).all()
# sqlalchemy returns named tuples for columns
link_ids = [ tuple.pointer for tuple in link_id_tuples ]
link_id_tuples = dbsession.query(RegRecord.pointer).filter_by(type=target_type).filter(RegRecord.hrn.in_(hrns)).all()
# sqlalchemy returns named tuples for columns
link_ids = [ tuple.pointer for tuple in link_id_tuples ]
-
self
.driver.update_relation (subject_type, target_type, relation_name, subject_id, link_ids)
+
api
.driver.update_relation (subject_type, target_type, relation_name, subject_id, link_ids)
def Register(self, api, record_dict):
def Register(self, api, record_dict):
@@
-347,14
+349,14
@@
class RegistryManager:
record.reg_keys = [ RegKey (key) for key in record.keys ]
# update testbed-specific data if needed
record.reg_keys = [ RegKey (key) for key in record.keys ]
# update testbed-specific data if needed
- pointer =
self
.driver.register (record.__dict__, hrn, pub_key)
+ pointer =
api
.driver.register (record.__dict__, hrn, pub_key)
record.pointer=pointer
dbsession.add(record)
dbsession.commit()
# update membership for researchers, pis, owners, operators
record.pointer=pointer
dbsession.add(record)
dbsession.commit()
# update membership for researchers, pis, owners, operators
- self.update_driver_relations (
record, record, dbsession
)
+ self.update_driver_relations (
api, record, record
)
return record.get_gid_object().save_to_string(save_parents=True)
return record.get_gid_object().save_to_string(save_parents=True)
@@
-412,7
+414,7
@@
class RegistryManager:
print "DO NOT REMOVE ME before driver.update, record=%s"%record
new_key_pointer = -1
try:
print "DO NOT REMOVE ME before driver.update, record=%s"%record
new_key_pointer = -1
try:
- (pointer, new_key_pointer) =
self
.driver.update (record.__dict__, new_record.__dict__, hrn, new_key)
+ (pointer, new_key_pointer) =
api
.driver.update (record.__dict__, new_record.__dict__, hrn, new_key)
except:
pass
if new_key and new_key_pointer:
except:
pass
if new_key and new_key_pointer:
@@
-421,7
+423,7
@@
class RegistryManager:
dbsession.commit()
# update membership for researchers, pis, owners, operators
dbsession.commit()
# update membership for researchers, pis, owners, operators
- self.update_driver_relations (
record, new_record, dbsession
)
+ self.update_driver_relations (
api, record, new_record
)
return 1
return 1
@@
-459,7
+461,7
@@
class RegistryManager:
# call testbed callback first
# IIUC this is done on the local testbed TOO because of the refreshpeer link
# call testbed callback first
# IIUC this is done on the local testbed TOO because of the refreshpeer link
- if not
self
.driver.remove(record.__dict__):
+ if not
api
.driver.remove(record.__dict__):
logger.warning("driver.remove failed")
# delete from sfa db
logger.warning("driver.remove failed")
# delete from sfa db
@@
-474,10
+476,10
@@
class RegistryManager:
# verify that the callers's ip address exist in the db and is an interface
# for a node in the db
(ip, port) = api.remote_addr
# verify that the callers's ip address exist in the db and is an interface
# for a node in the db
(ip, port) = api.remote_addr
- interfaces =
self
.driver.shell.GetInterfaces({'ip': ip}, ['node_id'])
+ interfaces =
api
.driver.shell.GetInterfaces({'ip': ip}, ['node_id'])
if not interfaces:
raise NonExistingRecord("no such ip %(ip)s" % locals())
if not interfaces:
raise NonExistingRecord("no such ip %(ip)s" % locals())
- nodes =
self
.driver.shell.GetNodes([interfaces[0]['node_id']], ['node_id', 'hostname'])
+ nodes =
api
.driver.shell.GetNodes([interfaces[0]['node_id']], ['node_id', 'hostname'])
if not nodes:
raise NonExistingRecord("no such node using ip %(ip)s" % locals())
node = nodes[0]
if not nodes:
raise NonExistingRecord("no such node using ip %(ip)s" % locals())
node = nodes[0]