Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions oca/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Image(PoolElement):
'update': 'image.update',
'enable': 'image.enable',
'publish': 'image.publish',
'chmod': 'image.chmod',
'chown': 'image.chown',
'persistent': 'image.persistent',
'clone': 'image.clone',
Expand Down Expand Up @@ -152,6 +153,34 @@ def chown(self, uid, gid):
"""
self.client.call(self.METHODS['chown'], self.id, uid, gid)

def chmod(self, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u, other_m, other_a):
"""
Changes the permission bits

Arguments

``owner_u``
User USE bit. Set to -1 to leave current value
``owner_m``
User MANAGE bit. Set to -1 to leave current value
``owner_a``
User ADMIN bit. Set to -1 to leave current value
``group_u``
Group USE bit. Set to -1 to leave current value
``group_m``
Group MANAGE bit. Set to -1 to leave current value
``group_a``
Group ADMIN bit. Set to -1 to leave current value
``other_u``
Other USE bit. Set to -1 to leave current value
``other_m``
Other MANAGE bit. Set to -1 to leave current value
``other_a``
Other ADMIN bit. Set to -1 to leave current value
"""
self.client.call(self.METHODS['chmod'], self.id, owner_u, owner_m, owner_a, group_u, group_m, group_a, other_u,
other_m, other_a)

def clone(self, name='', datastore_id=-1):
"""
Creates a clone of an image
Expand Down
7 changes: 7 additions & 0 deletions oca/tests/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,10 @@ def test_chown(self):
h.chown(10, 10)
self.client.call.assert_called_once_with('image.chown',
'1', 10, 10)

def test_chmod(self):
self.client.call = Mock(return_value='')
h = oca.Image(self.xml, self.client)
h.chmod(1, 0, 0, -1, -1, -1, -1, -1, -1)
self.client.call.assert_called_once_with('image.chmod',
'1', 1, 0, 0, -1, -1, -1, -1, -1, -1)