help="type filter ([all]|user|slice|authority|node|aggregate)",
choices=("all", "user", "slice", "authority", "node", "aggregate"),
default="all")
+ if command in ("show"):
+ parser.add_option("-k","--key",dest="keys",action="append",default=[],
+ help="specify specific keys to be displayed from record")
if command in ("resources"):
# rspec version
parser.add_option("-r", "--rspec-version", dest="rspec_version", default="SFA 1",
def print_help (self):
+ print "==================== Generic sfi usage"
self.sfi_parser.print_help()
+ print "==================== Specific command usage"
self.command_parser.print_help()
#
self.dispatch(command, command_options, command_args)
except KeyError:
self.logger.critical ("Unknown command %s"%command)
- raise
sys.exit(1)
-
+
return
####################
record_dicts = filter_records(options.type, record_dicts)
if not record_dicts:
self.logger.error("No record of type %s"% options.type)
+ return
+ # user has required to focus on some keys
+ if options.keys:
+ def project (record):
+ projected={}
+ for key in options.keys:
+ try: projected[key]=record[key]
+ except: pass
+ return projected
+ record_dicts = [ project (record) for record in record_dicts ]
records = [ Record(dict=record_dict) for record_dict in record_dicts ]
for record in records:
if (options.format == "text"): record.dump(sort=True)
rspec.filter({'component_manager_id': server_version['urn']})
rspec = RSpecConverter.to_pg_rspec(rspec.toxml(), content_type='request')
else:
+ print >>sys.stderr, "\r\n \r\n \r\n WOOOOOO"
users = sfa_users_arg(user_records, slice_record)
# do not append users, keys, or slice tags. Anything
renew slice (RenewSliver)
"""
server = self.sliceapi()
+ if len(args) != 2:
+ self.print_help()
+ sys.exit(1)
+ [ slice_hrn, input_time ] = args
# slice urn
- slice_hrn = args[0]
slice_urn = hrn_to_urn(slice_hrn, 'slice')
+ # time: don't try to be smart on the time format, server-side will
# creds
slice_cred = self.slice_credential_string(args[0])
creds = [slice_cred]
if options.delegate:
delegated_cred = self.delegate_cred(slice_cred, get_authority(self.authority))
creds.append(delegated_cred)
- # time
- time = args[1]
# options and call_id when supported
api_options = {}
api_options['call_id']=unique_call_id()
- result = server.RenewSliver(slice_urn, creds, time, *self.ois(server,api_options))
+ result = server.RenewSliver(slice_urn, creds, input_time, *self.ois(server,api_options))
value = ReturnValue.get_value(result)
if self.options.raw:
save_raw_to_file(result, self.options.raw, self.options.rawformat, self.options.rawbanner)
from types import StringTypes
from collections import defaultdict
+import sys
from sfa.util.sfatime import utcparse, datetime_to_epoch
from sfa.util.sfalogging import logger
# slice belongs to out local plc or a myplc peer. We will assume it
# is a local site, unless we find out otherwise
peer = None
-
# get this slice's authority (site)
slice_authority = get_authority(hrn)
# get this site's authority (sfa root authority or sub authority)
site_authority = get_authority(slice_authority).lower()
-
# check if we are already peered with this site_authority, if so
peers = self.driver.shell.GetPeers({}, ['peer_id', 'peername', 'shortname', 'hrn_root'])
for peer_record in peers:
def verify_slice_leases(self, slice, requested_leases, kept_leases, peer):
leases = self.driver.shell.GetLeases({'name':slice['name']}, ['lease_id'])
+ grain = self.driver.shell.GetLeaseGranularity()
current_leases = [lease['lease_id'] for lease in leases]
deleted_leases = list(set(current_leases).difference(kept_leases))
self.driver.shell.UnBindObjectFromPeer('slice', slice['slice_id'], peer['shortname'])
deleted=self.driver.shell.DeleteLeases(deleted_leases)
for lease in requested_leases:
- added=self.driver.shell.AddLeases(lease['hostname'], slice['name'], int(lease['t_from']), int(lease['t_until']))
+ added=self.driver.shell.AddLeases(lease['hostname'], slice['name'], int(lease['start_time']), int(lease['duration']) * grain + int(lease['start_time']))
except:
logger.log_exc('Failed to add/remove slice leases')
#----------------------------------------------------------------------
import re
-
+import sys
from sfa.util.faults import SfaAPIError
# for convenience and smoother translation - we should get rid of these functions eventually
# provide either urn, or (hrn + type)
def __init__ (self, xrn, type=None):
if not xrn: xrn = ""
+
# user has specified xrn : guess if urn or hrn
if Xrn.is_urn(xrn):
self.hrn=None
# self.authority keeps a list
if not hasattr(self,'authority'):
self.authority=Xrn.hrn_auth_list(self.hrn)
-
+
+
def get_leaf(self):
self._normalize()
return self.leaf
raise SfaAPIError, "Xrn.hrn_to_urn, hrn=%s"%self.hrn
if self.type and self.type.startswith('authority'):
- self.authority = Xrn.hrn_split(self.hrn)
+ self.authority = Xrn.hrn_auth_list(self.hrn)
+ leaf = self.get_leaf()
+ if not self.authority:
+ self.authority = [self.hrn]
type_parts = self.type.split("+")
self.type = type_parts[0]
name = 'sa'
if len(type_parts) > 1:
name = type_parts[1]
+ authority_string = ":".join([self.get_authority_urn(), leaf])
else:
self.authority = Xrn.hrn_auth_list(self.hrn)
name = Xrn.hrn_leaf(self.hrn)
-
- authority_string = self.get_authority_urn()
+ authority_string = self.get_authority_urn()
if self.type == None:
urn = "+".join(['',authority_string,Xrn.unescape(name)])