Dec-28-2018, 01:52 AM
Hello, I am just toying around and building a script to create network configurations for my CCNP lab..
def mainMenu (): print('\n Hello, this is DesignMe, your handy dandy Cisco configuration assistant. This is NetworkNick, How can I help you today?') print('\n 1. Base configuration file \n 2. Subnet and IP address allocation \n 3. OSPF network configuration \n 4. Quit \n') selection = int(input('Please enter choice below:')) try: if selection == 1: baseRouterConfig() elif selection == 2: createAddress() elif selection == 3: networkOSPF() elif selection == 4: exit else: print('Invalid choice, please choose from menu options 1, 2,3 or 4.') mainMenu() except ValueError: print('Invalid choice.') def baseRouterConfig(): hostName() UserName() thePassword() def thePassword(): whatpass = input('\n Would you like a password? ') if whatpass.lower().startswith('y'): thepassword = False while not thepassword: reponse = input('What would you like the password to be?') secondtime = input('Please retype password..') if reponse == secondtime: thepassword = True return secondtime else: print('\n You have chosen not to set a password.') return def hostName(): whatName = False while not whatName: whatname = input('What is the hostname you would like? ') response = input('{} is that correct?'.format(whatname)) if response.lower().startswith('y'): whatName = True return whatname def userName(): whatName = False while not whatName: username = input('\n What username would you like? ') response = input('{} is that correct? '.format(username)) if response.lower().startswith('y'): whatName = True return username mainMenu()So I just learned how to use while-loops and functions and my goal right now is to get the main menu to go to the baseRouterConfig() function and then go through the list of functions there.