hrn_list = hrn
if not hrn_list:
- interfaces = aggregates.interfaces
+ interfaces = aggregates.interfaces.keys()
else:
- interfaces = [interface for interface in aggregates.interfaces if interface['hrn'] in hrn_list]
+ interfaces = [interface for interface in aggregates.interfaces if interface in hrn_list]
return interfaces
geni_aggs = Aggregates(self.api, '/etc/sfa/geni_aggregates.xml')
+ geni_aggs = geni_aggs.interfaces.values()
+
hrn_list = []
if hrn:
if isinstance(hrn, StringTypes):
hrn_list = hrn
if not hrn_list:
- interfaces = geni_aggs.interfaces
+ interfaces = geni_aggs
else:
- interfaces = [interface for interface in geni_aggs.interfaces if interface['hrn'] in hrn_list]
-
+ interfaces = [interface for interface in geni_aggs if interface['hrn'] in hrn_list]
+
+
# Remove Aggregate's default sfa-aggregate
interfaces = interfaces[:-1]
- # Remove empty interfaces
- interfaces = [interface for interface in interfaces if interface['hrn'] != '']
-
+
# Add urns
for interface in interfaces:
interface['urn'] = hrn_to_urn(interface['hrn'], 'authority')
hrn_list = hrn
if not hrn_list:
- interfaces = registries.interfaces
+ interfaces = registries.interfaces.keys()
else:
- interfaces = [interface for interface in registries.interfaces if interface['hrn'] in hrn_list]
+ interfaces = [interface for interface in registries.interfaces if interface in hrn_list]
return interfaces
def create_top_level_auth_records(self, hrn):
- # create the authority if it doesnt already exist
AuthHierarchy = self.AuthHierarchy
urn = hrn_to_urn(hrn, 'authority')
- if not AuthHierarchy.auth_exists(urn):
- trace("Import: creating top level authorites", self.logger)
- AuthHierarchy.create_auth(urn)
+ # make sure parent exists
parent_hrn = get_authority(hrn)
if not parent_hrn:
parent_hrn = hrn
- auth_info = AuthHierarchy.get_auth_info(parent_hrn)
+ if not parent_hrn == hrn:
+ self.create_top_level_auth_records(parent_hrn)
+
+ # create the authority if it doesnt already exist
+ if not AuthHierarchy.auth_exists(urn):
+ trace("Import: creating top level authorites", self.logger)
+ AuthHierarchy.create_auth(urn)
# create the db record if it doesnt already exist
+ auth_info = AuthHierarchy.get_auth_info(hrn)
table = SfaTable()
auth_record = table.find({'type': 'authority', 'hrn': hrn})
if not isinstance(interfaces, list):
interfaces = [self.interfaces]
self.interfaces = {}
+ required_fields = self.default_fields.keys()
for interface in interfaces:
- self.interfaces[interface['hrn']] = interface
+ valid = True
+ # skp any interface definition that has a null hrn,
+ # address or port
+ for field in required_fields:
+ if field not in interface or not interface[field]:
+ valid = False
+ break
+ if valid:
+ self.interfaces[interface['hrn']] = interface
def sync_interfaces(self):