Commit 2c68bea8 authored by David Johnson's avatar David Johnson

Enable create_sliver to take an rspec string or filename via CLI.

parent 311c25a3
...@@ -301,6 +301,22 @@ def parse_str_list(str): ...@@ -301,6 +301,22 @@ def parse_str_list(str):
return [] return []
return str.split(',') return str.split(',')
def parse_rspec_arg(_rspec):
try:
from lxml import etree as ET
ET.fromstring(_rspec)
return _rspec
except:
pass
try:
f = open(_rspec,'r')
return f.read()
except:
LOG.warn("rspec argument does not appear to be XML nor a file;"
" but assuming it is indeed XML!")
return _rspec
pass
# #
# By default, adjust our credential caching time by this much to give a # By default, adjust our credential caching time by this much to give a
# little slop to make sure we can renew the credential. # little slop to make sure we can renew the credential.
...@@ -1825,6 +1841,8 @@ class ProtoGeniServer(object): ...@@ -1825,6 +1841,8 @@ class ProtoGeniServer(object):
@ApplicableMethod( @ApplicableMethod(
excluded=['selfcredential'], excluded=['selfcredential'],
largs=[dict(name='rspec',type=parse_rspec_arg,
help='An RSpec XML string or a file containing an RSpec')],
kwargs=[dict(name='dokeys',type=parse_bool), kwargs=[dict(name='dokeys',type=parse_bool),
dict(name='gen_random_key',action='store_true')]) dict(name='gen_random_key',action='store_true')])
def create_sliver(self,rspec,cm=None,slicename=None,dokeys=True, def create_sliver(self,rspec,cm=None,slicename=None,dokeys=True,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment