ventilaar
/
sdn-cursus
Archived
1
Fork 0

processes user input, but needs more extensions

especially clean output
This commit is contained in:
Ventilaar 2021-11-18 09:55:15 +01:00
parent 6ddf82ea0d
commit e2c09174ce
1 changed files with 38 additions and 3 deletions

View File

@ -15,12 +15,12 @@ def generate_config(s):
f"hostname {s['HOSTNAME']}\n" \
'no ip domain-lookup\n' \
f"ip domain-name {s['DOMAIN']}\n" \
f"crypto key generate rsa general-keys modulus {s['RSA_BITSIZE']}\n" \
f"crypto key generate rsa general-keys modulus {RSA_BITSIZE}\n" \
f"username {s['SSH_USERNAME']} password {s['SSH_PASSWORD']}\n" \
f"enable secret {s['ENABLE_PASSWORD']}\n" \
'service password-encryption\n' \
'ip ssh version 2\n' \
f"int {s['MANAGEMENT_INTERFACE']}" \
f"int {MANAGEMENT_INTERFACE}" \
f"ip address {s['MANAGEMENT_IP']} {s['MANAGEMENT_MASK']}\n" \
'no shutdown\n' \
'exit\n' \
@ -33,6 +33,41 @@ def generate_config(s):
return config
def ask_options():
opt = dict()
opt['HOSTNAME'] = input('Hostname: ')
while not opt['HOSTNAME']:
print('Hostname required!')
opt['HOSTNAME'] = input('Hostname: ')
opt['DOMAIN'] = input('Domain(router.lan): ')
if not opt['DOMAIN']:
opt['domain'] = 'router.lan'
opt['SSH_USERNAME'] = input('SSH Username(cisco): ')
if not opt['SSH_USERNAME']:
opt['SSH_USERNAME'] = 'cisco'
opt['SSH_PASSWORD'] = input('SSH Password(cisco): ')
if not opt['SSH_PASSWORD']:
opt['SSH_PASSWORD'] = 'cisco'
opt['ENABLE_PASSWORD'] = input('Enable Password(class): ')
if not opt['ENABLE_PASSWORD']:
opt['ENABLE_PASSWORD'] = 'class'
opt['MANAGEMENT_IP'] = input('Management IP: ')
while not opt['MANAGEMENT_IP']:
print('Address required!')
opt['MANAGEMENT_IP'] = input('Management IP: ')
opt['MANAGEMENT_MASK'] = input('Management Mask(255.255.255.0): ')
if not opt['MANAGEMENT_MASK']:
opt['MANAGEMENT_MASK'] = '255.255.255.0'
return opt
def menu():
print(
f"{'_' * 64}\n"
@ -45,7 +80,7 @@ def menu():
def main():
menu()
print(generate_config(test))
print(generate_config(ask_options()))