Added graphviz to the sphinx extensions, added some graphs for the container docs to better explain how it works
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/db7d8f09 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/db7d8f09 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/db7d8f09 Branch: refs/heads/trunk Commit: db7d8f09ed54a2a10ce87cafba4c0ca6631b64bc Parents: c188d32 Author: anthony-shaw <anthony.p.s...@gmail.com> Authored: Wed Jan 6 21:30:12 2016 +1100 Committer: anthony-shaw <anthony.p.s...@gmail.com> Committed: Wed Jan 6 21:30:12 2016 +1100 ---------------------------------------------------------------------- docs/conf.py | 2 +- docs/container/index.rst | 73 +++++++++++++++++++- .../container/docker/deploy_container.py | 10 +++ docs/examples/container/ecs/deploy_container.py | 25 ++++--- 4 files changed, 98 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/db7d8f09/docs/conf.py ---------------------------------------------------------------------- diff --git a/docs/conf.py b/docs/conf.py index f1e53d8..2b17ca5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,7 +40,7 @@ sys.path.insert(0, os.path.abspath('../')) # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', - 'sphinx.ext.viewcode'] + 'sphinx.ext.viewcode', 'sphinx.ext.graphviz'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] http://git-wip-us.apache.org/repos/asf/libcloud/blob/db7d8f09/docs/container/index.rst ---------------------------------------------------------------------- diff --git a/docs/container/index.rst b/docs/container/index.rst index 01c9203..4f5fb66 100644 --- a/docs/container/index.rst +++ b/docs/container/index.rst @@ -9,6 +9,46 @@ Container API allows users to install and deploy containers onto container based on-premise installations of software like Docker as well as interfacing with Cloud Service Providers that offer Container-as-a-Service APIs. +.. graphviz:: + + digraph G { + graph [ fontname = "Roboto Slab", + fontsize = 18, + label = "Using the driver to deploy containers with or without clusters" ]; + + subgraph noncluster { + style=filled; + color=lightgrey; + node [style=filled,color=white]; + list_images -> install_image -> deploy_container; + label = "Non-Cluster Container Driver"; + } + + subgraph cluster { + node [style=filled]; + list_locations -> list_clusters -> create_cluster; + label = "Cluster supported Container Driver"; + color=blue + } + __init__ -> list_images; + __init__ -> list_locations; + create_cluster -> list_images; + deploy_container -> end; + + __init__ [shape=square]; + end [shape=squae]; + } + +For a working example of the container driver with cluster support, see the example for Amazon's Elastic Container Service: + +.. literalinclude:: /examples/container/ecs/deploy_container.py + :language: python + +For an example of the simple container support, see the Docker example: + +.. literalinclude:: /examples/container/docker/deploy_container.py + :language: python + Drivers ------- Container-as-a-Service providers will implement the `ContainerDriver` class to provide functionality for : @@ -40,7 +80,38 @@ clusters may be listed, created and destroyed. When containers are deployed, the * :class:`~libcloud.container.base.ContainerCluster` - Represents a deployed container image running on a container host * :class:`~libcloud.container.base.ClusterLocation` - Represents a location for clusters to be deployed - +Bootstrapping Docker with Compute Drivers +----------------------------------------- + +The compute and container drivers can be combined using the :doc:`deployment </compute/deployment>` feature of the compute driver to bootstrap an installation of a container virtualization provider like Docker. +Then using the Container driver, you can connect to that API and install images and deploy containers. + +.. graphviz:: + + digraph G2 { + + subgraph compute { + style=filled; + color=lightgrey; + node [style=filled,color=white]; + create_node -> deploy_node; + label = "Compute API"; + } + + subgraph container { + node [style=filled]; + __init__ -> install_image -> deploy_container; + label = "Container API"; + color=blue + } + start -> create_node; + deploy_node -> __init__; + deploy_container -> end; + + start [shape=Mdiamond]; + end [shape=Msquare]; + } + Supported Providers ------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/db7d8f09/docs/examples/container/docker/deploy_container.py ---------------------------------------------------------------------- diff --git a/docs/examples/container/docker/deploy_container.py b/docs/examples/container/docker/deploy_container.py new file mode 100644 index 0000000..7d643c2 --- /dev/null +++ b/docs/examples/container/docker/deploy_container.py @@ -0,0 +1,10 @@ +from libcloud.container.types import Provider +from libcloud.container.providers import get_driver + +cls = get_driver(Provider.DOCKER) + +driver = cls(host='https://198.61.239.128', port=4243, + key_file='key.pem', cert_file='cert.pem') + +image = driver.install_image('tomcat:8.0') +container = driver.deploy_container('tomcat', image) http://git-wip-us.apache.org/repos/asf/libcloud/blob/db7d8f09/docs/examples/container/ecs/deploy_container.py ---------------------------------------------------------------------- diff --git a/docs/examples/container/ecs/deploy_container.py b/docs/examples/container/ecs/deploy_container.py index f9bc9df..2dd6662 100644 --- a/docs/examples/container/ecs/deploy_container.py +++ b/docs/examples/container/ecs/deploy_container.py @@ -8,13 +8,18 @@ conn = cls(access_id='AKIAI7OR4GWEEPRIFBBA', secret='xiKazLqsAgMQ4c3rC2RSXHBJrJTqNZmjYcXHsYXO', region='ap-southeast-2') -container = conn.deploy_container( - name='my-simple-app', - image=ContainerImage( - id=None, - name='simple-app', - path='simple-app', - version=None, - driver=conn - ) -) + +for cluster in conn.list_clusters(): + print(cluster.name) + if cluster.name == 'default': + container = conn.deploy_container( + cluster=cluster, + name='my-simple-app', + image=ContainerImage( + id=None, + name='simple-app', + path='simple-app', + version=None, + driver=conn + ) + )