From 9ffca4406147069ceec8791ed8ed2b64a905b135 Mon Sep 17 00:00:00 2001 From: Tony Mack Date: Sun, 22 May 2011 22:21:09 -0400 Subject: [PATCH] fix pg ad rspec schema validation errors --- sfa/rspecs/pg_rspec.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/sfa/rspecs/pg_rspec.py b/sfa/rspecs/pg_rspec.py index 60f9c3e4..e2653ad7 100755 --- a/sfa/rspecs/pg_rspec.py +++ b/sfa/rspecs/pg_rspec.py @@ -35,16 +35,18 @@ class PGRSpec(RSpec): template = """""" def __init__(self, rspec="", namespaces={}, type=None): + if not type: + type = 'advertisement' self.type = type - if not type or type == 'advertisement': + + if type == 'advertisement': self.version = pg_rspec_ad_version rspec_type = 'ad' else: - self.version = pg_rspec_request_version - rspec_type == type - + self.version = pg_rspec_request_version + rspec_type = type - self.template = self.template % locals() + self.template = self.template % {'rspec_type': rspec_type} if not namespaces: self.namespaces = {'rspecv2': self.version['namespace']} @@ -106,10 +108,10 @@ class PGRSpec(RSpec): if 'hostname' in node: node_tag.set('component_name', node['hostname']) # TODO: should replace plab-pc with pc model - node_type_tag = etree.SubElement(node_tag, 'hardware_type', type_name='plab-pc') - node_type_tag = etree.SubElement(node_tag, 'hardware_type', type_name='pc') + node_type_tag = etree.SubElement(node_tag, 'hardware_type', name='plab-pc') + node_type_tag = etree.SubElement(node_tag, 'hardware_type', name='pc') available_tag = etree.SubElement(node_tag, 'available', now='true') - location_tag = etree.SubElement(node_tag, 'country', location="us") + location_tag = etree.SubElement(node_tag, 'location', country="us") if 'site' in node: if 'longitude' in node['site']: location_tag.set('longitude', str(node['site']['longitude'])) -- 2.47.0