-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated usage chapter, examples; fixed error
Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
- Loading branch information
1 parent
62d1406
commit 26b317c
Showing
11 changed files
with
120 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Example script that processes the servers of a server or grou nickname. | ||
""" | ||
|
||
import sys | ||
import os | ||
from pprint import pprint | ||
import easy_vault | ||
|
||
from secure_server_access import VaultFile, VaultFileException, \ | ||
ServerDefinitionFile, ServerDefinitionFileException | ||
|
||
|
||
def main(): | ||
"""Main function""" | ||
|
||
if len(sys.argv) < 4: | ||
print("Usage: {} vaultfile srvdeffile nickname".format(sys.argv[0])) | ||
sys.exit(2) | ||
|
||
vault_file = sys.argv[1] | ||
srvdef_file = sys.argv[2] | ||
nickname = sys.argv[3] | ||
|
||
try: | ||
sdf = ServerDefinitionFile(srvdef_file) | ||
except ServerDefinitionFileException as exc: | ||
print("Error: {}".format(exc)) | ||
return 1 | ||
|
||
sd_list = sdf.list_servers(nickname) | ||
|
||
try: | ||
vault = VaultFile(vault_file) | ||
except VaultFileException as exc: | ||
print("Error: {}".format(exc)) | ||
return 1 | ||
|
||
for sd in sd_list: | ||
nick = sd.nickname | ||
secrets = vault.get_secrets(nick) | ||
|
||
host=secrets['host'], | ||
username=secrets['username'] | ||
password=secrets['password'] | ||
|
||
print("Server {n}: host={h}, username={u}, password=********". | ||
format(n=nick, h=host, u=username)) | ||
|
||
return 0 | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
--- | ||
# Example server definition file for secure-server-access package. | ||
|
||
servers: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
--- | ||
# Example vault file for secure-server-access package. | ||
|
||
secrets: | ||
|
||
myserver1: | ||
host: "10.11.12.13" | ||
username: myusername | ||
password: mypassword | ||
username: myuser1 | ||
password: mypass1 | ||
|
||
myserver2: | ||
host: "9.11.12.13" | ||
username: myusername | ||
password: mypassword | ||
host: "9.10.11.12" | ||
username: myuser2 | ||
password: mypass2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters