Ejemplo n.º 1
0
def check_arguments() :
    """Check the command line arguments"""
    global CREATE
    global DESTROY
    if len(sys.argv) == 1 :
        USAGE()
        sys.exit()
    if sys.argv[1] in ('-h', '--help') :
        USAGE()
        sys.exit()
    if sys.argv[1] == 'listall' or sys.argv[1] == 'ALL' :
        return 'ALL'
    if sys.argv[1] in ('CREATE', 'create', 'Create') :
        CREATE = True
        del sys.argv[1]
    if sys.argv[1] in ('DESTROY', 'destroy', 'Destroy') :
        DESTROY = True
        del sys.argv[1]
    if len(sys.argv) != 2 :
        print 'bad argument count'
        USAGE()
        sys.exit()
    FQDN = sys.argv[1]
    if fqdn_validator.validate_FQDN(FQDN) :
        return FQDN
    else :
        print """invalid FQDN! 
Needs to end with (atl|twc|dmz|be|fe).atl.weather.com.
Or needs to begin with (pr|qa|dv|dr) and have (tce) as third letter.
Or needs to match [0-3][xb][0-9][0-9].
Exiting"""
        sys.exit(1)
Ejemplo n.º 2
0
def check_arguments():
    """Check the command line arguments"""
    global CREATE
    global DESTROY
    if len(sys.argv) == 1:
        USAGE()
        sys.exit()
    if sys.argv[1] in ('-h', '--help'):
        USAGE()
        sys.exit()
    if sys.argv[1] == 'listall' or sys.argv[1] == 'ALL':
        return 'ALL'
    if sys.argv[1] in ('CREATE', 'create', 'Create'):
        CREATE = True
        del sys.argv[1]
    if sys.argv[1] in ('DESTROY', 'destroy', 'Destroy'):
        DESTROY = True
        del sys.argv[1]
    if len(sys.argv) != 2:
        print 'bad argument count'
        USAGE()
        sys.exit()
    FQDN = sys.argv[1]
    if fqdn_validator.validate_FQDN(FQDN):
        return FQDN
    else:
        print """invalid FQDN! 
Needs to end with (atl|twc|dmz|be|fe).atl.weather.com.
Or needs to begin with (pr|qa|dv|dr) and have (tce) as third letter.
Or needs to match [0-3][xb][0-9][0-9].
Exiting"""
        sys.exit(1)
Ejemplo n.º 3
0
def create_FQDN(FQDN) :
    if fqdn_validator.validate_FQDN(FQDN) :
        success, host = SanData.create(FQDN)
        if success :
            return bottle.template('make_table', rows=[host])
        else :
            if host.FQDN == '' :
                return 'creation failed'
            else :
                result = "<p>Host already existed.<p>"
                result += bottle.template('make_table', rows=[host])
                return result
    else :
        return 'invalid FQDN'