From: Tony Mack Date: Wed, 26 Oct 2011 17:36:32 +0000 (-0400) Subject: implement prepare_links() X-Git-Tag: sfa-1.1-1~27 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ee57ecddefd30f9f3d36aeb8370d86836b6c0306;p=sfa.git implement prepare_links() --- diff --git a/sfa/plc/aggregate.py b/sfa/plc/aggregate.py index d6997421..1fff54d3 100644 --- a/sfa/plc/aggregate.py +++ b/sfa/plc/aggregate.py @@ -2,6 +2,7 @@ from sfa.util.xrn import hrn_to_urn, urn_to_hrn from sfa.util.plxrn import PlXrn, hostname_to_urn, hrn_to_pl_slicename from sfa.rspecs.rspec import RSpec +from sfa.rspecs.elements.link import Link from sfa.rspecs.version_manager import VersionManager from sfa.plc.vlink import get_tc_rate @@ -51,7 +52,39 @@ class Aggregate: def prepare_links(self, force=False): if not self.links or force: - pass + if not self.api.config.SFA_AGGREGATE_TYPE.lower() == 'vini': + return + + for (site_id1, site_id2) in PhysicalLinks: + link = Link() + if not site_id1 in self.sites or site_id2 not in self.sites: + continue + site1 = self.sites[site_id1] + site2 = self.sites[site_id2] + # get hrns + site1_hrn = self.api.hrn + '.' + site1['login_base'] + site2_hrn = self.api.hrn + '.' + site2['login_base'] + # get the first node + node1 = self.nodes[site1['node_id'][0]] + node2 = self.nodes[site2['node_id'][0]] + + # set interfaces + # just get first interface of the first node + if1_xrn = PlXrn(auth=self.api.hrn, interface='node%s:eth0' % (node1['node_id'])) + if2_xrn = PlXrn(auth=self.api.hrn, interface='node%s:eth0' % (node2['node_id'])) + + if1 = Interface({'component_id': if1_xrn.urn} ) + if2 = Interface({'component_id': if2_xrn.urn} ) + + # set link + link = Link({'capacity': '1000000', 'latency': '0', 'packet_loss': '0', 'type': 'ipv4'}) + 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, link=link['component_name']) + link['component_manager_id'] = hrn_to_urn(self.api.hrn, 'authority+am') + self.links[link['component_name']] = link + def prepare_node_tags(self, force=False): if not self.node_tags or force: