コード例 #1
0
ファイル: actions.py プロジェクト: cheickina/image_share
def image_list_detail(args, producer_data):
    tenant, token, url = mutate_url_servers_endpoint(producer_data)

    uuid = args['uuid']
    url = url + "/" + uuid
    body, status_code = do_request(url, token)
    print body
コード例 #2
0
ファイル: actions.py プロジェクト: cheickina/image_share
def status_set(args, consumer_data):
    consumer_tenant, consumer_token, consumer_url = consumer_data
    uuid = args['uuid']

    url = consumer_url + "/" + uuid + "/members/" + consumer_tenant
    if args['accepted']:
        status = 'accepted'
    elif args['rejected']:
        status = 'rejected'
    elif args['pending']:
        status = 'pending'

    json_data = {"status": status}

    print ("\nAttempting to set status to "
           "{} for member {}...".format(status, consumer_tenant))
    body, status_code = do_request(url, consumer_token, json_data, mode="put")

    if status_code == 404:
        print("Error....Http Code 404 returned. Are you sure {}"
              " is the Consumer? Only the Consumer can set"
              " status.").format(consumer_tenant)
    else:
        print body
        return status_code
コード例 #3
0
ファイル: actions.py プロジェクト: cheickina/image_share
def member_add(args, producer_data,
               remove=False, consumer_tenant=None):
    # if called from command line instead of image_share()
    if args.get('consumer_tenantid', None):
        consumer_tenant = args['consumer_tenantid']

    producer_tenant, producer_token, producer_url = producer_data

    uuid = args['uuid']
    url = producer_url + "/" + uuid + "/members"
    json_data = {"member": consumer_tenant}


    if remove:
        print("\nAttempting to remove consumer {}"
              " as member to image {}...".format(consumer_tenant, uuid))
        url = url + "/" + consumer_tenant
        # remove/delete API does not return body
        # so do raw request
        r = do_raw_request(url, producer_token, mode="delete")
        if r.status_code == 204:
            # Delete API does not return anything
            print "Success"
        elif r.status_code == 404:
            print("User {} doesn't exist"
                  " as a member").format(consumer_tenant)
    else:
        print("\nAttempting to add consumer {}"
              " as member to image {}...".format(consumer_tenant, uuid))
        body, status_code = do_request(
            url, producer_token, json_data, mode="post")
        if status_code == 409:
            print "Member already exists!...don't worry...continuing..."
        elif status_code == 404:
            print ("No image found with ID {}." 
                   "\nAre you sure the Producer's image"
                   " resides in region {}?".format(
                       uuid, args["region"]))
            sys.exit()
        else:
            print status_code
            print body
            sys.exit();
コード例 #4
0
ファイル: actions.py プロジェクト: cheickina/image_share
 def wrapper(args, producer_data):
     original_function = function(args, producer_data)
     tenant, token, url = producer_data
     body, status_code = do_request(url, token)
     print body
     return original_function