Created
October 14, 2014 15:47
-
-
Save zeroasterisk/0dc2abd8133c56fb86e4 to your computer and use it in GitHub Desktop.
Rackspace API Cloud Files - List all Container URLs and Metadata (pyrax)
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# ---------------------------------------- | |
# | |
# Setup: | |
# $ sudo pip install --upgrade git+git://github.com/rackspace/pyrax.git | |
# $ vim ~/.rackspace_cloud_credentials | |
# [rackspace_cloud] | |
# username = myusername | |
# api_key = 01234567890abcdef | |
# | |
# Usage: | |
# | |
# $ python rsc_files_containers_urls.py | |
# | |
# Expected Output: | |
# | |
# container: <Container '.CDN_ACCESS_LOGS'> | |
# metadata: {} | |
# cdn_uri: None | |
# cdn_ssl_uri: None | |
# container: <Container 'CdnContainer'> | |
# metadata: {'access_log_delivery': 'false'} | |
# cdn_uri: http://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.r55.cf2.rackcdn.com | |
# cdn_ssl_uri: https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.ssl.cf2.rackcdn.com | |
# ... | |
# | |
# ---------------------------------------- | |
# Copyright (c)2012 Rackspace US, Inc. | |
# All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); you may | |
# not use this file except in compliance with the License. You may obtain | |
# a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | |
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | |
# License for the specific language governing permissions and limitations | |
# under the License. | |
from __future__ import print_function | |
import os | |
import time | |
import pyrax | |
import pyrax.exceptions as exc | |
pyrax.set_setting("identity_type", "rackspace") | |
creds_file = os.path.expanduser("~/.rackspace_cloud_credentials") | |
pyrax.set_credential_file(creds_file) | |
cf = pyrax.cloudfiles | |
for cont in cf.get_all_containers(): | |
print("container:", cont | |
) | |
meta = cf.get_container_metadata(cont) | |
print("metadata:", meta | |
) | |
print("cdn_uri:", cont.cdn_uri) | |
print("cdn_ssl_uri:", cont.cdn_ssl_uri) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment