3 from optparse import OptionParser
6 vsys_tag_type=GetSliceTags({'tagname':'vsys'})[0]
8 print("Can't find tag vsys - exiting")
11 def add_value (slice, value, options):
12 (slice_id, slice_name ) = (slice['slice_id'], slice['name'])
14 print("Would add vsys=%s to slice %s (%d)"%(value,slice_name,slice_id))
17 print("Adding vsys=%s to slice %s (%d)"%(value,slice_name,slice_id))
18 AddSliceTag (slice_id, 'vsys', value)
22 # retrieve applicable slices
24 if options.pattern: filter['name']=options.pattern
25 if not options.all: filter['peer_id']=None
26 slices=GetSlices(filter)
31 values= [ y for y in [ x.strip() for x in api.config.PLC_VSYS_DEFAULTS.split(',') ] if y ]
34 slice_tags=GetSliceTags({'tagname':'vsys','value':value})
35 names_with_tag = [ st['name'] for st in slice_tags ]
38 if slice['name'] not in names_with_tag:
39 add_value (slice,value,options)
42 print("Found %d slices for which %s is missing"%(counter,value))
46 Checks that a set of slices has a set of vsys tags set
48 %prog -- -p 'inria*' -t promisc -t fd_tuntap -vn
50 parser = OptionParser(usage=usage)
51 parser.add_option("-t","--tag",action='append',default=[],dest='tags',
52 help="ignore PLC config and provide tags on the command line - can be repeated")
53 parser.add_option("-a","--all",action='store_true',default=False,
54 dest='all',help="Apply on foreign slices as well (default is local only)")
55 parser.add_option("-p","--pattern",action='store',default=None,
56 dest='pattern',help="Apply on slices whose name matches pattern")
57 parser.add_option("-v", "--verbose", action = "store_true", default = False,
58 dest='verbose', help="be verbose")
59 parser.add_option("-n", "--dry-run", action = "store_true", default = False,
60 dest='dry_run', help="don't actually do it")
61 (options, args) = parser.parse_args()
69 if __name__ == "__main__":