From 81635abad1fc07419effe497f787263ae79c8bb4 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Thu, 1 Dec 2011 13:01:08 +0100 Subject: [PATCH] topology.py moved in sfa/plc/ --- sfa/importer/sfa-import-plc.py | 5 ++--- sfa/managers/aggregate_manager.py | 1 + sfa/plc/aggregate.py | 29 ++++++++++++++++------------- sfa/plc/peers.py | 2 +- sfa/{util => plc}/topology.py | 9 --------- 5 files changed, 20 insertions(+), 26 deletions(-) rename sfa/{util => plc}/topology.py (74%) diff --git a/sfa/importer/sfa-import-plc.py b/sfa/importer/sfa-import-plc.py index a9915525..d41bbd4c 100755 --- a/sfa/importer/sfa-import-plc.py +++ b/sfa/importer/sfa-import-plc.py @@ -18,10 +18,9 @@ import os import getopt import sys -from sfa.util.xrn import get_leaf, get_authority -from sfa.util.plxrn import hostname_to_hrn, slicename_to_hrn, email_to_hrn, hrn_to_pl_slicename from sfa.util.config import Config -from sfa.util.xrn import Xrn +from sfa.util.xrn import Xrn, get_leaf, get_authority +from sfa.util.plxrn import hostname_to_hrn, slicename_to_hrn, email_to_hrn, hrn_to_pl_slicename from sfa.storage.table import SfaTable diff --git a/sfa/managers/aggregate_manager.py b/sfa/managers/aggregate_manager.py index 2fbdf3d3..c412e170 100644 --- a/sfa/managers/aggregate_manager.py +++ b/sfa/managers/aggregate_manager.py @@ -12,6 +12,7 @@ from sfa.util.callids import Callids from sfa.trust.sfaticket import SfaTicket from sfa.trust.credential import Credential + from sfa.rspecs.version_manager import VersionManager from sfa.rspecs.rspec import RSpec diff --git a/sfa/plc/aggregate.py b/sfa/plc/aggregate.py index 0eff6cca..afdc656f 100644 --- a/sfa/plc/aggregate.py +++ b/sfa/plc/aggregate.py @@ -1,6 +1,6 @@ #!/usr/bin/python from sfa.util.xrn import hrn_to_urn, urn_to_hrn, urn_to_sliver_id -from sfa.util.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename +from sfa.util.sfatime import epochparse from sfa.rspecs.rspec import RSpec from sfa.rspecs.elements.hardware_type import HardwareType @@ -12,10 +12,12 @@ from sfa.rspecs.elements.location import Location from sfa.rspecs.elements.interface import Interface from sfa.rspecs.elements.services import Services from sfa.rspecs.elements.pltag import PLTag -from sfa.util.topology import Topology from sfa.rspecs.version_manager import VersionManager + +from sfa.util.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename from sfa.plc.vlink import get_tc_rate -from sfa.util.sfatime import epochparse +from sfa.plc.topology import Topology + class Aggregate: @@ -54,8 +56,8 @@ class Aggregate: site1 = sites[site_id1] site2 = sites[site_id2] # get hrns - site1_hrn = self.api.hrn + '.' + site1['login_base'] - site2_hrn = self.api.hrn + '.' + site2['login_base'] + site1_hrn = self.api.driver.hrn + '.' + site1['login_base'] + site2_hrn = self.api.driver.hrn + '.' + site2['login_base'] for s1_node_id in site1['node_ids']: for s2_node_id in site2['node_ids']: @@ -65,9 +67,9 @@ class Aggregate: node2 = nodes[s2_node_id] # set interfaces # just get first interface of the first node - if1_xrn = PlXrn(auth=self.api.hrn, interface='node%s:eth0' % (node1['node_id'])) + if1_xrn = PlXrn(auth=self.api.driver.hrn, interface='node%s:eth0' % (node1['node_id'])) if1_ipv4 = interfaces[node1['interface_ids'][0]]['ip'] - if2_xrn = PlXrn(auth=self.api.hrn, interface='node%s:eth0' % (node2['node_id'])) + if2_xrn = PlXrn(auth=self.api.driver.hrn, interface='node%s:eth0' % (node2['node_id'])) if2_ipv4 = interfaces[node2['interface_ids'][0]]['ip'] if1 = Interface({'component_id': if1_xrn.urn, 'ipv4': if1_ipv4} ) @@ -78,8 +80,8 @@ class Aggregate: link['interface1'] = if1 link['interface2'] = if2 link['component_name'] = "%s:%s" % (site1['login_base'], site2['login_base']) - link['component_id'] = PlXrn(auth=self.api.hrn, interface=link['component_name']).get_urn() - link['component_manager_id'] = hrn_to_urn(self.api.hrn, 'authority+am') + link['component_id'] = PlXrn(auth=self.api.driver.hrn, interface=link['component_name']).get_urn() + link['component_manager_id'] = hrn_to_urn(self.api.driver.hrn, 'authority+am') links.append(link) return links @@ -180,10 +182,10 @@ class Aggregate: # xxx how to retrieve site['login_base'] site_id=node['site_id'] site=sites_dict[site_id] - rspec_node['component_id'] = hostname_to_urn(self.api.hrn, site['login_base'], node['hostname']) + rspec_node['component_id'] = hostname_to_urn(self.api.driver.hrn, site['login_base'], node['hostname']) rspec_node['component_name'] = node['hostname'] - rspec_node['component_manager_id'] = self.api.hrn - rspec_node['authority_id'] = hrn_to_urn(PlXrn.site_hrn(self.api.hrn, site['login_base']), 'authority+sa') + rspec_node['component_manager_id'] = self.api.driver.hrn + rspec_node['authority_id'] = hrn_to_urn(PlXrn.site_hrn(self.api.driver.hrn, site['login_base']), 'authority+sa') rspec_node['boot_state'] = node['boot_state'] rspec_node['exclusive'] = 'False' rspec_node['hardware_types']= [HardwareType({'name': 'plab-pc'}), @@ -202,7 +204,8 @@ class Aggregate: for if_id in node['interface_ids']: interface = Interface(interfaces[if_id]) interface['ipv4'] = interface['ip'] - interface['component_id'] = PlXrn(auth=self.api.hrn, interface='node%s:eth%s' % (node['node_id'], if_count)).get_urn() + interface['component_id'] = PlXrn(auth=self.api.driver.hrn, + interface='node%s:eth%s' % (node['node_id'], if_count)).get_urn() rspec_node['interfaces'].append(interface) if_count+=1 diff --git a/sfa/plc/peers.py b/sfa/plc/peers.py index b659ea9a..f9f80db0 100644 --- a/sfa/plc/peers.py +++ b/sfa/plc/peers.py @@ -2,7 +2,7 @@ from sfa.util.xrn import get_authority from types import StringTypes def get_peer(api, hrn): - # Becaues of myplc federation, we first need to determine if this + # Because of myplc native federation, we first need to determine if this # slice belongs to out local plc or a myplc peer. We will assume it # is a local site, unless we find out otherwise peer = None diff --git a/sfa/util/topology.py b/sfa/plc/topology.py similarity index 74% rename from sfa/util/topology.py rename to sfa/plc/topology.py index 79482f19..cd6036af 100644 --- a/sfa/util/topology.py +++ b/sfa/plc/topology.py @@ -15,16 +15,7 @@ class Topology(set): def __init__(self, config_file = "/etc/sfa/topology"): set.__init__(self) - self.config_file = None - self.config_path = None - self.load(config_file) - - def load(self, config_file): try: - - self.config_file = config_file - # path to configuration data - self.config_path = os.path.dirname(config_file) # load the links f = open(config_file, 'r') for line in f: -- 2.47.0