MyFirstApp: Durability section with shade

Fixing errors in the backup script for the fractal app images.

Closes-Bug: #1594431

Change-Id: I42783d8f00dbac996746ed440bdc7885b4f3b48f
This commit is contained in:
Marcela Bonell 2016-06-20 11:33:10 -05:00
parent 2ed56abe21
commit e6e7801a6d

View File

@ -1,5 +1,3 @@
#! /usr/bin/env python
# step-1 # step-1
from __future__ import print_function from __future__ import print_function
import hashlib import hashlib
@ -19,7 +17,6 @@ print(conn.list_containers())
file_path = 'goat.jpg' file_path = 'goat.jpg'
object_name = 'an amazing goat' object_name = 'an amazing goat'
container = conn.get_container(container_name) container = conn.get_container(container_name)
object = conn.create_object(container=container_name, name=object_name, filename=file_path) object = conn.create_object(container=container_name, name=object_name, filename=file_path)
# step-5 # step-5
@ -36,6 +33,8 @@ print(hashlib.md5(open('goat.jpg', 'rb').read()).hexdigest())
conn.delete_object(container_name, object_name) conn.delete_object(container_name, object_name)
# step-9 # step-9
print(conn.list_objects(container_name))
# step-10 # step-10
container_name = 'fractals' container_name = 'fractals'
print(conn.get_container(container_name)) print(conn.get_container(container_name))
@ -44,7 +43,6 @@ print(conn.get_container(container_name))
import base64 import base64
import cStringIO import cStringIO
import json import json
import requests import requests
endpoint = 'http://IP_API_1' endpoint = 'http://IP_API_1'
@ -52,12 +50,11 @@ params = { 'results_per_page': '-1' }
response = requests.get('%s/v1/fractal' % endpoint, params=params) response = requests.get('%s/v1/fractal' % endpoint, params=params)
data = json.loads(response.text) data = json.loads(response.text)
for fractal in data['objects']: for fractal in data['objects']:
r = requests.get(url, stream=True) r = requests.get('%s/fractal/%s' % (endpoint, fractal['uuid']), stream=True)
with open(fractal['uuid'], 'wb') as f: with open(fractal['uuid'], 'wb') as f:
for chunk in r.iter_content(chunk_size=1024): for chunk in r.iter_content(chunk_size=1024):
if chunk: if chunk:
f.write(chunk) f.write(chunk)
f.close() f.close()
conn.create_object(container=container_name, name=fractal['uuid']) conn.create_object(container=container_name, name=fractal['uuid'])
@ -66,8 +63,7 @@ for object in conn.list_objects(container_name):
# step-12 # step-12
for object in conn.list_objects(container_name): for object in conn.list_objects(container_name):
conn.delete_objects(container_name, object['name']) conn.delete_object(container_name, object['name'])
conn.delete_container(container_name) conn.delete_container(container_name)
# step-13 # step-13