source: people/peter.buschman/backup_monitoring/backmon/commands/alias.py@ 1273

Last change on this file since 1273 was 976, checked in by peter, on Dec 6, 2011 at 10:19:33 AM

Raw checkin of current NetBackup / TSM parsing code.

File size: 1.2 KB
Line 
1#!/usr/bin/python26
2###
3### backmon.commands.alias
4###
5
6import sys
7import os
8import os.path
9import glob
10import re
11
12from optparse import OptionParser
13
14from ..lib import *
15
16usage = 'usage: %prog -e environment alias'
17
18parser = OptionParser(usage=usage)
19
20def run(args, kwargs):
21
22 #
23 # add kwargs to local namespace
24 #
25 for key in kwargs.keys():
26
27 if re.compile('^[A-Z][A-Z_]+$').match(key):
28 exec(key + ' = kwargs[\'' + key + '\']')
29
30 (options, args) = parser.parse_args(args)
31
32 if not OPTIONS.environment:
33 ERROR('Please specify an environment to use the alias command.')
34 sys.exit(1)
35 elif( len(args) == 0 ):
36 ERROR('No alias specified.')
37 sys.exit(1)
38 else:
39 alias = args.pop(0)
40 DEBUG('ALIAS=%s' % (alias))
41
42 environment = ENVIRONMENTS[ENVIRONMENT]
43
44 environment.refresh(['aliases'])
45 environment.parse_aliases()
46
47 if alias not in environment.aliases:
48 ERROR('No aliases were found for the alias "%s"' % (alias))
49 else:
50 for alias in environment.aliases[alias]:
51 if alias in SERVER_PATHS:
52 print alias
53# print SERVER_PATHS[alias]
54
Note: See TracBrowser for help on using the repository browser.