[lxc-devel] [pylxd/master] Add more examples

BryanQuigley on Github lxc-bot at linuxcontainers.org
Fri Mar 30 19:02:52 UTC 2018


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 442 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180330/344e0678/attachment.bin>
-------------- next part --------------
From 2bbdae9fb561ed804723f881f7db9addc959404d Mon Sep 17 00:00:00 2001
From: BryanQuigley <BryanQuigley at users.noreply.github.com>
Date: Fri, 30 Mar 2018 15:02:29 -0400
Subject: [PATCH] Add more examples

Add examples for the items I just learned about, how to specify a profile, an image source, and find out what IP address a machine is using.
---
 doc/source/containers.rst | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/doc/source/containers.rst b/doc/source/containers.rst
index b2e9e3c..7fc9a0b 100644
--- a/doc/source/containers.rst
+++ b/doc/source/containers.rst
@@ -116,6 +116,13 @@ container.
     >>> container.start()
     >>> container.freeze()
     >>> container.delete()
+   
+   
+Config line with a specific image source and a profile.
+
+.. code-block:: python
+
+    >>> config = {'name': 'somename', 'source': {'type': 'image', "mode": "pull", "server": "https://cloud-images.ubuntu.com/daily", "protocol": "simplestreams", 'alias': 'bionic/amd64'}, 'profiles': ['profilename'] }
 
 
 To modify container's configuration method `save` should be called after
@@ -125,6 +132,14 @@ To modify container's configuration method `save` should be called after
     >>> container.ephemeral = False
     >>> container.devices = { 'root': { 'path': '/', 'type': 'disk', 'size': '7GB'} }
     >>> container.save
+    
+To get state information such as a network address.
+
+.. code-block:: python
+
+    >>> addresses = container.state().network['eth0']['addresses']
+    >>> addresses
+    [{'family': 'inet', 'address': '10.251.77.182', 'netmask': '24', 'scope': 'global'}, {'family': 'inet6', 'address': 'fd42:ea82:ea5f:ab08:216:3eff:fe18:cef1', 'netmask': '64', 'scope': 'global'}, {'family': 'inet6', 'address': 'fe80::216:3eff:fe18:cef1', 'netmask': '64', 'scope': 'link'}]
 
 
 Container Snapshots


More information about the lxc-devel mailing list