Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support curdir conf, OS_* env, and "debug novaenv" #1

Merged
merged 2 commits into from

2 participants

@clayg
  • instead of just ~/.supernova, also read .supernova if available

    • don't print confusing warning when using OS_* style environ

    • "supernova debug nova_env" will inject NOVACLIENT_DEBUG

Also moved the order of arg checks so "supernova list" will error on
missing nova_env section "list" instead of "you didn't pass enough args"

@clayg clayg Support curdir conf, OS_* env, and "debug novaenv"
 * instead of just ~/.supernova, also read .supernova if available

 * don't print confusing warning when using OS_* style environ

 * "supernova debug nova_env" will inject NOVACLIENT_DEBUG

Also moved the order of arg checks so "supernova list" will error on
missing nova_env section "list" instead of "you didn't pass enough args"
2b5b3da
@major major merged commit 055e710 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 30, 2012
  1. @clayg

    Support curdir conf, OS_* env, and "debug novaenv"

    clayg authored
     * instead of just ~/.supernova, also read .supernova if available
    
     * don't print confusing warning when using OS_* style environ
    
     * "supernova debug nova_env" will inject NOVACLIENT_DEBUG
    
    Also moved the order of arg checks so "supernova list" will error on
    missing nova_env section "list" instead of "you didn't pass enough args"
  2. @clayg

    docs on optional debug arg

    clayg authored
This page is out of date. Refresh to see the latest.
Showing with 30 additions and 19 deletions.
  1. +8 −2 README.md
  2. +22 −17 supernova/supernova.py
View
10 README.md
@@ -40,7 +40,7 @@ When you use *supernova*, you'll refer to these environments as **production** a
### Usage
- supernova [environment] [novaclient arguments...]
+ supernova [debug] [environment] [novaclient arguments...]
For example, if you wanted to run a list in the **production** environment:
@@ -50,7 +50,13 @@ Show a particular instance's data in the preprod environment:
supernova preprod show 3edb6dac-5a75-486a-be1b-3b15fd5b4ab0a
-The first argument is the environment argument and it is expected to be a single word without spaces. Any text after the environment argument is passed directly to novaclient.
+The first argument is generally the environment argument and it is expected to be a single word without spaces. Any text after the environment argument is passed directly to novaclient.
+
+You may optionally pass in the literal string "debug" as the first argument
+(before the environment argument) to inject the NOVACLIENT_DEBUG=1 option into
+the process environment to see additional debug information about the requests
+being made to the API. As before, any text after the environment argument is
+passed directly to novaclient.
#### A brief note about environment variables
View
39 supernova/supernova.py
@@ -27,19 +27,33 @@ def data_file(fname):
# Pick up the user's credentials and environments
user_creds = ConfigParser.RawConfigParser()
-user_creds.read(os.path.expanduser("~/.supernova"))
+user_creds.read([os.path.expanduser("~/.supernova"), '.supernova'])
def bin_helper():
# Parse any options the user might have passed
args = sys.argv
args.pop(0) # get rid of the PROG arg
- try:
- nova_env = args.pop(0) # environment argument for supernova
- except:
- print "You must specify a valid nova environment as " \
- "the first argument."
- print "Available environments: %r" % user_creds.sections()
+ while True:
+ try:
+ nova_env = args.pop(0) # environment argument for supernova
+ except IndexError:
+ print "You must specify a valid nova environment as " \
+ "the first argument."
+ print "Available environments: %r" % nova_envs.sections()
+ sys.exit()
+ # make the sneakies on "supernova debug nova_env list"
+ if nova_env == 'debug':
+ # note this doesn't "export" the var, it only effects this process
+ os.environ['NOVACLIENT_DEBUG'] = '1'
+ else:
+ break
+
+ # Does the user have a configuration block for this environment?
+ if nova_env not in user_creds.sections():
+ print "You asked for the %r environment but it doesn't " \
+ "have a configuration section starting with [%s] in %s." % (
+ nova_env, nova_env, os.path.expanduser("~/.supernova"))
sys.exit()
# Our remaining arguments should be the stuff we pass through to
@@ -51,17 +65,8 @@ def bin_helper():
else:
nova_args = args
- # Does the user have a configuration block for this environment?
- if nova_env not in user_creds.sections():
- print "You asked for the %r environment but it doesn't " \
- "have a configuration section starting with [%s] in %s." % (
- nova_env, nova_env, os.path.expanduser("~/.supernova"))
- sys.exit()
-
# Do we have any login credentials for the environment specified?
- try:
- dict(user_creds.items(nova_env))['nova_url']
- except KeyError:
+ if not any(k for (k, v) in user_creds.items(nova_env) if k.endswith('_url')):
print """
You may be missing authentication credentials for the %r environment in your
%s file. Newer versions of supernova require all of your novaclient
Something went wrong with that request. Please try again.