arunk786

script

Dec 13th, 2011
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import sys
  3. from string import join
  4.  
  5. #Default rack for all IP
  6. DEFAULT_RACK = '/default/rack0';
  7.  
  8. #Rack Map between IP and desired rack location
  9.  
  10. RACK_MAP = { '208.94.2.10' : '/datacenter1/rack0',
  11.              '1.2.3.4' : '/datacenter1/rack0',
  12.              '1.2.3.5' : '/datacenter1/rack0',
  13.              '1.2.3.6' : '/datacenter1/rack0',
  14.  
  15.              'arun-Presario-C500-RU914PA-ACJ' : '/datacenter2/rack0',
  16.              '10.2.3.4' : '/datacenter2/rack0'
  17.     }
  18.  
  19. #if only one IP is passed
  20. if len(sys.argv)==1:
  21.     print DEFAULT_RACK
  22.  
  23. #else search for argument IP in our Rack map. If found get the appropriate rack location frm #Rack map and print
  24.  
  25. else:
  26.     print join([RACK_MAP.get(i, DEFAULT_RACK) for i in sys.argv[1:]]," ")
  27.  
Advertisement
Add Comment
Please, Sign In to add comment