from datetime import datetime, timedelta
from sfa.util.xrn import *
from sfa.util.plxrn import hostname_to_urn
-from sfa.util.config import Config
from sfa.util.faults import SfaNotImplemented, InvalidRSpec
class RSpec:
header = '<?xml version="1.0"?>\n'
template = """<RSpec></RSpec>"""
- config = Config()
xml = None
type = None
version = None
# 'rspec' file doesnt exist. 'rspec' is proably an xml string
try:
tree = etree.parse(StringIO(rspec), parser)
- except:
- raise InvalidRSpec('Must specify a xml file or xml string. Received: ' + rspec )
+ except Exception, e:
+ raise InvalidRSpec(str(e))
self.xml = tree.getroot()
if namespaces:
self.namespaces = namespaces
raise InvalidRSpec(message)
return True
-
def cleanup(self):
"""
Optional method which inheriting classes can choose to implent.
"""
pass
+ def _process_slivers(self, slivers):
+ """
+ Creates a dict of sliver details for each sliver host
+
+ @param slivers a single hostname, list of hostanmes or list of dicts keys on hostname,
+ Returns a list of dicts
+ """
+ if not isinstance(slivers, list):
+ slivers = [slivers]
+ dicts = []
+ for sliver in slivers:
+ if isinstance(sliver, dict):
+ dicts.append(sliver)
+ elif isinstance(sliver, basestring):
+ dicts.append({'hostname': sliver})
+ return dicts
+
def __str__(self):
return self.toxml()