Skip to content

Instantly share code, notes, and snippets.

@hacosta
Created January 24, 2014 21:54
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 hacosta/8607418 to your computer and use it in GitHub Desktop.
Save hacosta/8607418 to your computer and use it in GitHub Desktop.
import logging
from barbicanclient.common import auth
from barbicanclient import client
def verify(auth_url, username, api_key, password):
if not password or api_key:
raise ValueError('Password or api_key must be provided')
if password:
rack_auth = auth.RackspaceAuthV2(auth_url, username=username, password=password)
else:
rack_auth = auth.RackspaceAuthV2(auth_url, username=username, api_key=api_key)
# now instantiate the client, this will authenticate and
# retrieve the barbican endpoint from the catalog
barbican = client.Client(auth_plugin=rack_auth)
# now you can use the client to start the verification process
ver_href = barbican.verifications.create(resource_ref='server_id', resource_type='image', resource_action='vm_attach', impersonation_allowed=True)
logging.info('Retrieving verification..')
while True:
ref = barbican.verifications.get(endpoint)
if ref.status == 'ACTIVE':
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment