Skip to content

Instantly share code, notes, and snippets.

@kmamiya
Created December 3, 2016 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmamiya/6ad9765bccd0b13227ae76d2a8b16a6c to your computer and use it in GitHub Desktop.
Save kmamiya/6ad9765bccd0b13227ae76d2a8b16a6c to your computer and use it in GitHub Desktop.
The sample code for getting disk-image list from ConoHa with my conoha library that released as kmamiya/serverless-email-send-tool
# 1. $ git clone 'https://github.com/kmamiya/serverless-email-send-tool.git'
# 2. cd serverless-email-send-tool/bin
# 4. Rename or copy from config.json.template
# 5. Edit config.json
# 6. Download this.
# 7. $ python list_diskimage_sample.py config.json
#
from conoha import ConoHa
import sys
import json
def exit_if_failure( conoha ):
if not conoha.success():
print( 'HTTP_STATUS: ' + str( conoha.http_status() ) )
exit( 1 )
with open( sys.argv[1], 'r' ) as config_reader:
config = json.loads( config_reader.read() )
conoha = ConoHa( config['identity_url'], config['user_agent'] )
connect_response = conoha.connect(
config['username'], config['password'], config['tenant_id']
)
exit_if_failure( conoha )
image_list = conoha.list_image()
for name,image_info in image_list.items():
if 'private' == image_info['visibility']:
for key in image_info.keys():
print( key + ':' + str(image_info[key]) )
print( "\n" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment