-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- packaging: restructuring all code into snafulib with adapted and so…
…rt of working setup.py
- Loading branch information
spio
committed
Apr 22, 2017
1 parent
4ea931b
commit 5724a5f
Showing
10 changed files
with
735 additions
and
709 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,7 @@ snafu.ini | |
functions-local | ||
functions-tenants | ||
_* | ||
|
||
build/ | ||
dist/ | ||
snafu.egg-info/ |
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,7 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Snafu: Snake Functions - Command-Line Tool | ||
# Snafu: Snake Functions - Main Command-Line Tool | ||
|
||
import lib.snafu | ||
import snafulib.snafu | ||
|
||
sr = lib.snafu.SnafuRunner() | ||
snafulib.snafu.SnafuRunner() |
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,51 +1,7 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Snafu: Snake Functions - Account Management | ||
# Snafu: Snake Functions - Account Management Command-Line Tool | ||
|
||
import sys | ||
import os.path | ||
import argparse | ||
import configparser | ||
import snafulib.snafuaccounts | ||
|
||
class SnafuAccounts: | ||
def __init__(self): | ||
self.accounts = {} | ||
|
||
def addaccount(self, key, secret, endpoint): | ||
accdb = os.path.expanduser("~/.snafu-accounts") | ||
if os.getenv("HOME") == "/": | ||
accdb = "/root/.snafu-accounts" | ||
c = configparser.ConfigParser() | ||
try: | ||
c.read(accdb) | ||
except: | ||
pass | ||
acc = "account{}".format(len(c.sections())) | ||
c.add_section(acc) | ||
c.set(acc, "access_key_id", key) | ||
c.set(acc, "secret_access_key", secret) | ||
if endpoint: | ||
c.set(acc, "endpoint", endpoint) | ||
f = open(accdb, "w") | ||
c.write(f) | ||
|
||
def run(self): | ||
parser = argparse.ArgumentParser(description="Snake Functions as a Service - Account Management") | ||
parser.add_argument("-a", "--add", help="add an account", action="store_true") | ||
parser.add_argument("-k", "--key-id", help="access key id") | ||
parser.add_argument("-s", "--secret-access-key", help="secret access key") | ||
parser.add_argument("-e", "--endpoint", help="tenant-specific static endpoint") | ||
args = parser.parse_args() | ||
|
||
if args.add: | ||
if not args.key_id or not args.secret_access_key: | ||
print("Error: Must specify both --key-id and --secret-access-key for --add.", file=sys.stderr) | ||
return | ||
|
||
self.addaccount(args.key_id, args.secret_access_key, args.endpoint) | ||
else: | ||
print("Error: Must specify --add.", file=sys.stderr) | ||
return | ||
|
||
sa = SnafuAccounts() | ||
sa.run() | ||
snafulib.snafuaccounts.SnafuAccountsRunner() |
Oops, something went wrong.