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 config_tags=api.config.PLC_VSYS_DEFAULTS
32 values= [ value for value in config_tags.split(',') if value ]
35 slice_tags=GetSliceTags({'tagname':'vsys','value':value})
36 names_with_tag = [ st['name'] for st in slice_tags ]
39 if slice['name'] not in names_with_tag:
40 add_value (slice,value,options)
43 print "Found %d slices for which %s is missing"%(counter,value)
47 Checks that a set of slices has a set of vsys tags set
49 %prog -- -p 'inria*' -t promisc -t fd_tuntap -vn
51 parser = OptionParser(usage=usage)
52 parser.add_option("-t","--tag",action='append',default=[],dest='tags',
53 help="ignore PLC config and provide tags on the command line - can be repeated")
54 parser.add_option("-a","--all",action='store_true',default=False,
55 dest='all',help="Apply on foreign slices as well (default is local only)")
56 parser.add_option("-p","--pattern",action='store',default=None,
57 dest='pattern',help="Apply on slices whose name matches pattern")
58 parser.add_option("-v", "--verbose", action = "store_true", default = False,
59 dest='verbose', help="be verbose")
60 parser.add_option("-n", "--dry-run", action = "store_true", default = False,
61 dest='dry_run', help="don't actually do it")
62 (options, args) = parser.parse_args()
70 if __name__ == "__main__":