Don't load the glance when it's not needed

Fixes #13

If the user doesn't specify the --register-with-glance option, the
python-glance or python-glanceclient library should not be needed.

Signed-off-by: Tomas Sedovic <tomas@sedovic.cz>
This commit is contained in:
Tomas Sedovic 2012-10-12 17:35:26 +02:00
parent 39401324d5
commit f25d37d888
1 changed files with 9 additions and 1 deletions

View File

@ -38,7 +38,10 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
if os.path.exists(os.path.join(possible_topdir, 'heat_jeos')):
sys.path.insert(0, possible_topdir)
from heat_jeos import glance_clients as glance
try:
from heat_jeos import glance_clients as glance
except ImportError:
glance = None
from heat_jeos.utils import *
@ -99,6 +102,11 @@ def command_create(options, arguments):
sys.exit(1)
if options.register_with_glance:
if not glance:
logging.error("The Python Glance client is not installed. Please "
"install python-glance for Essex or python-glanceclient for "
"Folsom.")
sys.exit(1)
try:
client = glance.client(options)
glance.get_image(client, 'test')