Skip to content

Commit 469abd8

Browse files
mguezuragasysradium
authored andcommitted
Add support for the image chmod method (python-oca#49)
1 parent 513241b commit 469abd8

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

oca/image.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class Image(PoolElement):
1010
'update': 'image.update',
1111
'enable': 'image.enable',
1212
'publish': 'image.publish',
13+
'chmod': 'image.chmod',
1314
'chown': 'image.chown',
1415
'persistent': 'image.persistent',
1516
'clone': 'image.clone',
@@ -152,6 +153,34 @@ def chown(self, uid, gid):
152153
"""
153154
self.client.call(self.METHODS['chown'], self.id, uid, gid)
154155

156+
def chmod(self, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a):
157+
"""
158+
Changes the permission bits
159+
160+
Arguments
161+
162+
``owner_u``
163+
User USE bit. Set to -1 to leave current value
164+
``owner_m``
165+
User MANAGE bit. Set to -1 to leave current value
166+
``owner_a``
167+
User ADMIN bit. Set to -1 to leave current value
168+
``group_u``
169+
Group USE bit. Set to -1 to leave current value
170+
``group_m``
171+
Group MANAGE bit. Set to -1 to leave current value
172+
``group_a``
173+
Group ADMIN bit. Set to -1 to leave current value
174+
``other_u``
175+
Other USE bit. Set to -1 to leave current value
176+
``other_m``
177+
Other MANAGE bit. Set to -1 to leave current value
178+
``other_a``
179+
Other ADMIN bit. Set to -1 to leave current value
180+
"""
181+
self.client.call(self.METHODS['chmod'], self.id, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
182+
other_m, other_a)
183+
155184
def clone(self, name='', datastore_id=-1):
156185
"""
157186
Creates a clone of an image

oca/tests/test_image.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,10 @@ def test_chown(self):
100100
h.chown(10, 10)
101101
self.client.call.assert_called_once_with('image.chown',
102102
'1', 10, 10)
103+
104+
def test_chmod(self):
105+
self.client.call = Mock(return_value='')
106+
h = oca.Image(self.xml, self.client)
107+
h.chmod(1, 0, 0, -1, -1, -1, -1, -1, -1)
108+
self.client.call.assert_called_once_with('image.chmod',
109+
'1', 1, 0, 0, -1, -1, -1, -1, -1, -1)

0 commit comments

Comments
 (0)