from sfa.util.xrn import Xrn
from sfa.rspecs.elements.element import Element
-from sfa.rspecs.elements.node import Node
+from sfa.rspecs.elements.node import NodeElement
from sfa.rspecs.elements.sliver import Sliver
from sfa.rspecs.elements.location import Location
from sfa.rspecs.elements.position_3d import Position3D
from sfa.rspecs.elements.versions.nitosv1PLTag import NITOSv1PLTag
from sfa.rspecs.elements.versions.pgv2Services import PGv2Services
-from sfa.nitos.nitosxrn import xrn_to_hostname
class NITOSv1Node:
@staticmethod
- def add_nodes(xml, nodes):
+ def add_nodes(xml, nodes, rspec_content_type=None):
network_elems = xml.xpath('//network')
if len(network_elems) > 0:
network_elem = network_elems[0]
else:
network_elem = xml
+ # needs to be improuved to retreive the gateway addr dynamically.
+ gateway_addr = 'nitlab.inf.uth.gr'
+
node_elems = []
for node in nodes:
node_fields = ['component_manager_id', 'component_id', 'boot_state']
# set component_name attribute and hostname element
if 'component_id' in node and node['component_id']:
- component_name = xrn_to_hostname(node['component_id'])
+ component_name = Xrn(xrn=node['component_id']).get_leaf()
node_elem.set('component_name', component_name)
hostname_elem = node_elem.add_element('hostname')
hostname_elem.set_text(component_name)
if position_3d:
node_elem.add_instance('position_3d', position_3d, Position3D.fields)
+ # all nitos nodes are exculsive
+ exclusive_elem = node_elem.add_element('exclusive')
+ exclusive_elem.set_text('TRUE')
+
+ # In order to access nitos nodes, one need to pass through the nitos gateway
+ # here we advertise Nitos access gateway address
+ gateway_elem = node_elem.add_element('gateway')
+ gateway_elem.set_text(gateway_addr)
# add granularity of the reservation system
granularity = node.get('granularity')['grain']
tag_elem = node_elem.add_element(tag['tagname'])
tag_elem.set_text(tag['value'])
NITOSv1Sliver.add_slivers(node_elem, node.get('slivers', []))
+
+ # add sliver tag in Request Rspec
+ if rspec_content_type == "request":
+ node_elem.add_instance('sliver', '', [])
@staticmethod
def add_slivers(xml, slivers):
def get_node_objs(node_elems):
nodes = []
for node_elem in node_elems:
- node = Node(node_elem.attrib, node_elem)
+ node = NodeElement(node_elem.attrib, node_elem)
if 'site_id' in node_elem.attrib:
node['authority_id'] = node_elem.attrib['site_id']
# get location
# get slivers
node['slivers'] = NITOSv1Sliver.get_slivers(node_elem)
# get tags
- node['tags'] = NITOSv1PLTag.get_pl_tags(node_elem, ignore=Node.fields+["hardware_type"])
+ node['tags'] = NITOSv1PLTag.get_pl_tags(node_elem, ignore=NodeElement.fields+["hardware_type"])
# get hardware types
hardware_type_elems = node_elem.xpath('./default:hardware_type | ./hardware_type')
node['hardware_types'] = [hw_type.get_instance(HardwareType) for hw_type in hardware_type_elems]