Created
January 24, 2014 21:54
-
-
Save hacosta/8607418 to your computer and use it in GitHub Desktop.
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
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