From cf1a7aedc34e503642281cb555bcaf4ebf24450d Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Sun, 22 Oct 2023 14:43:42 -0400 Subject: [PATCH 1/2] profile: allow setting description during creation Closes #565 Signed-off-by: Simon Deziel --- pylxd/models/profile.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pylxd/models/profile.py b/pylxd/models/profile.py index 2b0c04fa..772de990 100644 --- a/pylxd/models/profile.py +++ b/pylxd/models/profile.py @@ -51,13 +51,15 @@ def all(cls, client): return profiles @classmethod - def create(cls, client, name, config=None, devices=None): + def create(cls, client, name, config=None, devices=None, description=None): """Create a profile.""" profile = {"name": name} if config is not None: profile["config"] = config if devices is not None: profile["devices"] = devices + if description is not None: + profile["description"] = description client.api.profiles.post(json=profile) return cls.get(client, name) From 559eeaba6250d2e8c33e9d417b11e2be878cd5f3 Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Sun, 22 Oct 2023 14:44:04 -0400 Subject: [PATCH 2/2] integration/test_profiles: test setting description Signed-off-by: Simon Deziel --- integration/test_profiles.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/integration/test_profiles.py b/integration/test_profiles.py index 49d287f2..d2cfd405 100644 --- a/integration/test_profiles.py +++ b/integration/test_profiles.py @@ -40,11 +40,13 @@ def test_create(self): """A profile is created.""" name = "an-profile" config = {"limits.memory": "1GB"} - profile = self.client.profiles.create(name, config) + description = "Memory limiting profile" + profile = self.client.profiles.create(name, config, description=description) self.addCleanup(self.delete_profile, name) self.assertEqual(name, profile.name) self.assertEqual(config, profile.config) + self.assertEqual(description, profile.description) class TestProfile(IntegrationTestCase):