parser.add_option("-f", "--format", dest="format", type="choice",
help="display format ([xml]|dns|ip)", default="xml",
choices=("xml", "dns", "ip"))
+ #panos: a new option to define the type of information about resources a user is interested in
+ parser.add_option("-i", "--info", dest="info",
+ help="optional component information", default=None)
+
if command in ("resources", "show", "list"):
parser.add_option("-o", "--output", dest="file",
if args:
cred = self.get_slice_cred(args[0]).save_to_string(save_parents=True)
hrn = args[0]
- call_options = {'geni_slice_urn': hrn_to_urn(hrn, 'slice')}
+ call_options = {'geni_slice_urn': hrn_to_urn(hrn, 'slice')}
else:
cred = user_cred
hrn = None
creds.append(delegated_cred)
if opts.rspec_version:
call_options['rspec_version'] = opts.rspec_version
+ #panos add info options
+ if opts.info:
+ call_options['info'] = opts.info
result = server.ListResources(creds, call_options,unique_call_id())
format = opts.format
if opts.file is None:
return 1
# xxx Thierry : caching at the aggregate level sounds wrong...
-caching=True
-#caching=False
+#caching=True
+caching=False
def ListSlices(api, creds, call_id):
if Callids().already_handled(call_id): return []
# look in cache first
# get the rspec's return format from options
rspec_version = RSpecVersion(options.get('rspec_version'))
version_string = "rspec_%s" % (rspec_version.get_version_name())
+
+ #panos adding the info option to the caching key (can be improved)
+ if options.get('info'):
+ version_string = version_string + "_"+options.get('info')
+
+ print "[aggregate] version string = ",version_string
# look in cache first
if caching and api.cache and not xrn:
api.logger.info("aggregate.ListResources: returning cached value for hrn %s"%hrn)
return rspec
- aggregate = Aggregate(api)
+ #aggregate = Aggregate(api)
+ #panos: passing user-defined options
+ #print "manager options = ",options
+ aggregate = Aggregate(api, options)
rspec = aggregate.get_rspec(slice_xrn=xrn, version=rspec_version)
rspec_version = RSpecVersion(options.get('rspec_version'))
version_string = "rspec_%s" % (rspec_version.get_version_name())
+ #panos adding the info option to the caching key (can be improved)
+ if options.get('info'):
+ version_string = version_string + "_"+options.get('info')
+
+ print "version string = ",version_string
+
# look in cache first
if caching and api.cache and not xrn:
rspec = api.cache.get(version_string)
links = {}
node_tags = {}
prepared=False
+ #panos new user options variable
+ user_options = {}
- def __init__(self, api):
+ def __init__(self, api, user_options={}):
self.api = api
+ #panos
+ self.user_options = user_options
+ print "[aggregate] options = ",self.user_options
def prepare_sites(self, force=False):
if not self.sites or force:
rspec_version = RSpecVersion(version)
if rspec_version['type'].lower() == 'protogeni':
rspec = PGRSpec()
+ #panos pass user options to SfaRSpec
elif rspec_version['type'].lower() == 'sfa':
- rspec = SfaRSpec()
+ rspec = SfaRSpec("",{},self.user_options)
else:
- rspec = SfaRSpec()
+ rspec = SfaRSpec("",{},self.user_options)
+
rspec.add_nodes(self.nodes.values())
rspec.add_interfaces(self.interfaces.values())
type = None
version = None
namespaces = None
+ user_options = {}
- def __init__(self, rspec="", namespaces={}):
+ def __init__(self, rspec="", namespaces={}, user_options={}):
+ self.user_options = user_options
if rspec:
self.parse_rspec(rspec, namespaces)
else:
bwlimit = etree.SubElement(node_tag, 'bw_limit', units='kbps').text = str(interface['bwlimit']/1000)
if 'tags' in node:
for tag in node['tags']:
- # expose this hard wired list of tags, plus the ones that are marked 'sfa' in their category
- if tag['tagname'] in ['fcdistro', 'arch'] or 'sfa' in tag['category'].split('/'):
+ #expose this hard wired list of tags, plus the ones that are marked 'sfa' in their category
+ #if tag['tagname'] in ['fcdistro', 'arch'] or 'sfa' in tag['category'].split('/'):
+ #tag_element = etree.SubElement(node_tag, tag['tagname'], value=tag['value'])
+
+ #panos expose tags only if requested by the user using the -i option
+ if self.user_options:
+ #print "[sfa rspec] found tag ",tag," and have info ",self.user_options.get('info')
+ if self.user_options.get('info') and tag['tagname'] in self.user_options.get('info'):
+ tag_element = etree.SubElement(node_tag, tag['tagname'], value=tag['value'])
+
+ if 'sfa' in tag['category'].split('/'):
tag_element = etree.SubElement(node_tag, tag['tagname'], value=tag['value'])
if 'site' in node: