Last active
August 29, 2015 14:09
-
-
Save smalot/4b979e2adde320c5ce35 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 os | |
from StringIO import StringIO | |
import json | |
import sys | |
import subprocess | |
import shutil | |
def getParent(rootid, id): | |
print "--> ", id | |
with open("/var/lib/docker/graph/"+id+"/json") as data_file: | |
data = json.load(data_file) | |
if "parent" in data: | |
parent = data["parent"] | |
getParent(rootid, parent) | |
print "[cp -r /var/lib/docker/graph/"+id+"/* /var/lib/docker/graph/4242"+rootid+"/]" | |
os.system("cp -r /var/lib/docker/graph/"+id+"/* /var/lib/docker/graph/4242"+rootid+"/") | |
rootid = sys.argv[-1] | |
shutil.rmtree(path="/var/lib/docker/graph/4242"+rootid,ignore_errors=True) | |
print "[mkdir /var/lib/docker/graph/4242"+rootid+"]" | |
os.mkdir("/var/lib/docker/graph/4242"+rootid) | |
getParent(rootid, rootid) | |
data = [] | |
with open("/var/lib/docker/graph/4242"+rootid+"/json", "r") as data_file: | |
data = json.load(data_file) | |
data["id"] = "4242" + data["id"] | |
del data["parent"] | |
del data["Size"] | |
with open("/var/lib/docker/graph/4242"+rootid+"/json", "w") as data_file: | |
json.dump(data, data_file) | |
shutil.rmtree(path="/var/lib/docker/graph/4242"+rootid+"/layersize",ignore_errors=True) | |
print "==> 4242"+rootid |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment