[lxc-devel] [pylxd/master] Allow specification of devices in a profile
zulcss on Github
lxc-bot at linuxcontainers.org
Wed May 25 14:33:08 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 565 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160525/fc1ebfd9/attachment.bin>
-------------- next part --------------
From 5002ee6d222183997a1f88b5e283f04d27843b5d Mon Sep 17 00:00:00 2001
From: Chuck Short <chuck.short at canonical.com>
Date: Tue, 24 May 2016 21:50:33 -0400
Subject: [PATCH] Allow specification of devices in a profile
Currently its not possible to specify devices when creating a
LXD profile. Make config dictionary and devices
optional when creating an LXD profileThis is required
so we can attach disks, network interfaces, etc.
Signed-off-by: Chuck Short <chuck.short at canonical.com>
---
pylxd/profile.py | 12 +++++++-----
pylxd/tests/test_profile.py | 2 +-
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/pylxd/profile.py b/pylxd/profile.py
index 1dab086..dcc921d 100644
--- a/pylxd/profile.py
+++ b/pylxd/profile.py
@@ -44,12 +44,14 @@ def all(cls, client):
return profiles
@classmethod
- def create(cls, client, name, config):
+ def create(cls, client, name, config=None, devices=None):
"""Create a profile."""
- client.api.profiles.post(json={
- 'name': name,
- 'config': config
- })
+ profile = {'name': name}
+ if config is not None:
+ profile['config'] = config
+ if devices is not None:
+ profile['devices'] = devices
+ client.api.profiles.post(json=profile)
return cls.get(client, name)
diff --git a/pylxd/tests/test_profile.py b/pylxd/tests/test_profile.py
index f8ea7e1..49df682 100644
--- a/pylxd/tests/test_profile.py
+++ b/pylxd/tests/test_profile.py
@@ -14,7 +14,7 @@ def test_all(self):
def test_create(self):
"""A new profile is created."""
an_profile = profile.Profile.create(
- self.client, name='an-new-profile', config={})
+ self.client, name='an-new-profile', config={}, devices={})
self.assertIsInstance(an_profile, profile.Profile)
self.assertEqual('an-new-profile', an_profile.name)
More information about the lxc-devel
mailing list