def setup():
    '''interactively edit the setup file. filepath must first be set'''
    checkForSetupFile()

    location = getLocation()
    if location:
        if prompt_bool('\nlocation has been configured as "%s", would you like to change this' % location):
            configLocation()
    else:
        configLocation()

    while True:
        if getAppliances() and not prompt_bool('\nDo you want to add/change/remove/view/check ' + \
                                'an appliance that is to be used when running local tests?'):
            break
        configAppliance()
        while True:
            if not prompt_bool('\nDo you want to add/change/remove/view/check another appliance?'):
                break
            configAppliance()
        break
        
    currentArgs = getArgs()
    if currentArgs:
        ansi.printc('\ncurrently sb test is adding the following args')
        ansi.writec(currentArgs, colors.PARAM_COLOR)
    if prompt_bool('\nsb test can be configured to always add arguments like -s ' '\n' \
                         'I have this configured to add' '\n' \
                         '-s --no-build-first --skip-compiled  --nologcapture' '\n' \
                         'to sb test' '\n' \
                         'for most people this is an unneccessary configuration' '\n'
                         'would you like to configure this'):
        configArgs()
Пример #2
0
def prompt_bool(
    msg,
    default='n'
):  #textui.prompt.prompt_bool should probably be replaced with this, and used instead
    '''
    Ask user for a yes/no answer.

    @param default If None, don't default and keep asking until either 'y'
           or 'n' is received. Otherwise, use the default value if neither
           'y' or 'n' is recieved
    '''
    while True:
        ansi.writec(msg)
        if default == 'y':
            ansi.writec(' (Y/n) ', colors.PARAM_COLOR)
        if default == 'n':
            ansi.writec(' (y/N) ', colors.PARAM_COLOR)
        else:
            ansi.writec(' (y/n) ', colors.PARAM_COLOR)

        answer = raw_input().strip().lower()

        if answer == 'y':
            return True
        if answer == 'n':
            return False
        if default != None:
            return
def prompt_bool(msg, default='n'): #textui.prompt.prompt_bool should probably be replaced with this, and used instead
    '''
    Ask user for a yes/no answer.

    @param default If None, don't default and keep asking until either 'y'
           or 'n' is received. Otherwise, use the default value if neither
           'y' or 'n' is recieved
    '''
    while True:
        ansi.writec(msg)
        if default == 'y': 
            ansi.writec(' (Y/n) ', colors.PARAM_COLOR)
        if default == 'n':
            ansi.writec(' (y/N) ', colors.PARAM_COLOR)
        else:
            ansi.writec(' (y/n) ', colors.PARAM_COLOR)
        
        answer = raw_input().strip().lower()

        if answer == 'y': 
            return True
        if answer == 'n': 
            return False
        if default != None: 
            return
Пример #4
0
def setup():
    '''interactively edit the setup file. filepath must first be set'''
    checkForSetupFile()

    location = getLocation()
    if location:
        if prompt_bool(
                '\nlocation has been configured as "%s", would you like to change this'
                % location):
            configLocation()
    else:
        configLocation()

    while True:
        if getAppliances() and not prompt_bool('\nDo you want to add/change/remove/view/check ' + \
                                'an appliance that is to be used when running local tests?'):
            break
        configAppliance()
        while True:
            if not prompt_bool(
                    '\nDo you want to add/change/remove/view/check another appliance?'
            ):
                break
            configAppliance()
        break

    currentArgs = getArgs()
    if currentArgs:
        ansi.printc('\ncurrently sb test is adding the following args')
        ansi.writec(currentArgs, colors.PARAM_COLOR)
    if prompt_bool('\nsb test can be configured to always add arguments like -s ' '\n' \
                         'I have this configured to add' '\n' \
                         '-s --no-build-first --skip-compiled  --nologcapture' '\n' \
                         'to sb test' '\n' \
                         'for most people this is an unneccessary configuration' '\n'
                         'would you like to configure this'):
        configArgs()
def configLocation():
    '''interactively configure a location for local tests'''
    while True:
        ansi.writec('\nwhere are you located(')
        ansi.writec('ps-orem, DSR, or other', colors.PARAM_COLOR)
        ansi.writec(') this is for tests like the NetApp connnector tests that require a local machine: ')

        response = raw_input().lower().strip()
        if response == 'ps-orem' or response == 'orem':
            setLocation('ps-orem')  
            break
        if response == 'dsr':
            setLocation('dsr')      
            break
        if response == 'other':
            setLocation('other')       
            break   
        ansi.eprintc('that location does not yet exist', colors.WARNING_COLOR)
Пример #6
0
def configLocation():
    '''interactively configure a location for local tests'''
    while True:
        ansi.writec('\nwhere are you located(')
        ansi.writec('ps-orem, DSR, or other', colors.PARAM_COLOR)
        ansi.writec(
            ') this is for tests like the NetApp connnector tests that require a local machine: '
        )

        response = raw_input().lower().strip()
        if response == 'ps-orem' or response == 'orem':
            setLocation('ps-orem')
            break
        if response == 'dsr':
            setLocation('dsr')
            break
        if response == 'other':
            setLocation('other')
            break
        ansi.eprintc('that location does not yet exist', colors.WARNING_COLOR)
Пример #7
0
def configAppliance():
    '''interactively configure an appliance'''

    appName = prompt("\nEnter the name of an existing/new appliance: ",
                     default=None)
    assert appName

    oldHost = oldUser = oldPasswd = None

    if appName in getAppliances():
        oldHost, oldUser, oldPasswd = getAppInfo(appName)

        ansi.printc('\nwhat do you want to do with the appliance %s' % appName)
        ansi.writec('type ')
        ansi.writec('c', colors.PARAM_COLOR)
        ansi.printc(' to change the appliance configurations')
        ansi.writec('type ')
        ansi.writec('r', colors.PARAM_COLOR)
        ansi.printc(' to remove the appliance from the setup file')
        ansi.writec('type ')
        ansi.writec('v', colors.PARAM_COLOR)
        ansi.printc(' to view info about the appliance\'s configuration')
        ansi.writec('type ')
        ansi.writec('check', colors.PARAM_COLOR)
        ansi.printc(' to check the credentials of the appliance')
        response = prompt('\n', choices='options: c, r, v, check', default='v')

        if response == 'c':
            print 'Changing an appliance isn\'t working right now \n the setup file must be manually changed'
            pass
        elif response == 'v':
            displayApplianceInfo(appName)
            return
        elif response == 'r':
            delAppliance(appName)
            return
        elif response == 'check':
            checkCredentials(oldHost, oldUser, oldPasswd)
            return
        else:
            ansi.eprintc('not a valid option', colors.ERROR_COLOR)
            return

    host = prompt('\nwhat is the ip address for "%s"' % appName,
                  default=oldHost)
    name = prompt('\nwhat is the username for the appliance "%s"' % appName,
                  default=oldUser)
    passwd = prompt('\nwhat is the password for "%s"' % appName,
                    default=oldPasswd)

    if prompt_bool(
            '\nWould you like to check the entered credentials for "%s"? (%s must be running):'
            % (appName, appName)):
        if not checkCredentials(host, name, passwd):
            ansi.printc('failed to set up %s' % appName, colors.WARNING_COLOR)
            return

    print '\n%s successfully configured. You can now use the appliance %s ' \
          'to run tests by using the command' % (appName, appName)
    ansi.printc('sb test --psa %s\n' % appName, colors.TITLE_COLOR)

    setAppliance(appName, host, name, passwd)
    return
def configAppliance():
    '''interactively configure an appliance'''

    appName = prompt("\nEnter the name of an existing/new appliance: ", default=None)
    assert appName

    oldHost = oldUser = oldPasswd = None
    
    if appName in getAppliances():
        oldHost, oldUser, oldPasswd = getAppInfo(appName)

        ansi.printc('\nwhat do you want to do with the appliance %s' % appName)
        ansi.writec('type '); ansi.writec('c', colors.PARAM_COLOR);     ansi.printc(' to change the appliance configurations')
        ansi.writec('type '); ansi.writec('r', colors.PARAM_COLOR);     ansi.printc(' to remove the appliance from the setup file')
        ansi.writec('type '); ansi.writec('v', colors.PARAM_COLOR);     ansi.printc(' to view info about the appliance\'s configuration')
        ansi.writec('type '); ansi.writec('check', colors.PARAM_COLOR); ansi.printc(' to check the credentials of the appliance')
        response = prompt('\n', choices='options: c, r, v, check', default='v')
        
        if response == 'c':
            print 'Changing an appliance isn\'t working right now \n the setup file must be manually changed'
            pass
        elif response == 'v':
            displayApplianceInfo(appName)
            return
        elif response == 'r':
            delAppliance(appName)
            return
        elif response == 'check':
            checkCredentials(oldHost, oldUser, oldPasswd)
            return
        else:
            ansi.eprintc('not a valid option', colors.ERROR_COLOR)
            return

    host =   prompt('\nwhat is the ip address for "%s"'             % appName, default=oldHost)
    name =   prompt('\nwhat is the username for the appliance "%s"' % appName, default=oldUser)
    passwd = prompt('\nwhat is the password for "%s"'               % appName, default=oldPasswd)

    if prompt_bool('\nWould you like to check the entered credentials for "%s"? (%s must be running):' % (appName, appName)):
        if not checkCredentials(host, name, passwd):
            ansi.printc('failed to set up %s' % appName, colors.WARNING_COLOR)
            return
            
    print '\n%s successfully configured. You can now use the appliance %s ' \
          'to run tests by using the command' % (appName, appName)
    ansi.printc('sb test --psa %s\n' % appName, colors.TITLE_COLOR)

    setAppliance(appName, host, name, passwd)
    return