def get_credential():
import yaml
credentialfilename = r'credential_napalm.yaml'
diccredential = yaml.load(open(credentialfilename))
hostname = diccredential['hostname']
username = diccredential['username']
password = diccredential['password']
port = diccredential['optional_args']['port']
#credentialfilename.close()
return (hostname,username,password,port)
def main():
# get credential
returntuple = get_credential()
hostname = returntuple[0]
username = returntuple[1]
password = returntuple[2]
port = returntuple[3]
print(hostname,username,password,port) |