Skip to content

Commit

Permalink
Pull images if they're not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
Spike Curtis committed Apr 10, 2015
1 parent 557c63f commit 11cd93a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 18 additions & 0 deletions calicoctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def node(ip, force_unix_socket, node_image, ip6=""):
network_mode="host",
binds=binds)

_find_or_pull_node_image(node_image)
container = node_docker_client.create_container(
node_image,
name="calico-node",
Expand Down Expand Up @@ -411,6 +412,23 @@ def node(ip, force_unix_socket, node_image, ip6=""):
print "Calico node is running with id: %s" % cid


def _find_or_pull_node_image(image_name):
"""
Check if Docker has a cached copy of an image, and if not, attempt to pull
it.
:param image_name: The full name of the image.
:return: None.
"""
try:
_ = docker_client.inspect_image(image_name)
except docker.errors.APIError as err:
if err.response.status_code == 404:
# TODO: Display proper status bar
print "Pulling Docker image %s" % image_name
docker_client.pull(image_name)


def grep(text, pattern):
return "\n".join([line for line in text.splitlines() if pattern in line])

Expand Down
1 change: 0 additions & 1 deletion node/adapter/powerstrip-calico.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def _install_endpoint(self, client_request):

return


def assign_ipv4(self):
"""
Assign a IPv4 address from the configured pools.
Expand Down

0 comments on commit 11cd93a

Please sign in to comment.