Commit f7949e20 by Czémán Arnold

disk: fix disk permission problem

parent 73dd2d63
...@@ -290,7 +290,8 @@ class Disk(object): ...@@ -290,7 +290,8 @@ class Disk(object):
if self.format == 'iso' or self.format == 'raw': if self.format == 'iso' or self.format == 'raw':
raise NotImplemented() raise NotImplemented()
try: try:
return subprocess.check_output(cmdline) return subprocess.check_output(
['/bin/sudo', '/usr/bin/qemu-img'] + cmdline)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
logger.error(e) logger.error(e)
raise Exception(unicode(e)) raise Exception(unicode(e))
...@@ -298,8 +299,7 @@ class Disk(object): ...@@ -298,8 +299,7 @@ class Disk(object):
def create_snapshot(self, snapshot_name): def create_snapshot(self, snapshot_name):
''' Creating qcow2 snapshot. ''' Creating qcow2 snapshot.
''' '''
cmdline = ['qemu-img', cmdline = ['snapshot',
'snapshot',
'-c', snapshot_name, '-c', snapshot_name,
self.get_path()] self.get_path()]
self.common_snapshot_operation(cmdline) self.common_snapshot_operation(cmdline)
...@@ -307,8 +307,7 @@ class Disk(object): ...@@ -307,8 +307,7 @@ class Disk(object):
def list_snapshots(self): def list_snapshots(self):
''' List qcow2 snapshot. ''' List qcow2 snapshot.
''' '''
cmdline = ['qemu-img', cmdline = ['info',
'info',
'--output', 'json', '--output', 'json',
self.get_path()] self.get_path()]
output = self.common_snapshot_operation(cmdline) output = self.common_snapshot_operation(cmdline)
...@@ -318,8 +317,7 @@ class Disk(object): ...@@ -318,8 +317,7 @@ class Disk(object):
def remove_snapshot(self, id): def remove_snapshot(self, id):
''' Remove qcow2 snapshot. ''' Remove qcow2 snapshot.
''' '''
cmdline = ['qemu-img', cmdline = ['snapshot',
'snapshot',
'-d', unicode(id), '-d', unicode(id),
self.get_path()] self.get_path()]
self.common_snapshot_operation(cmdline) self.common_snapshot_operation(cmdline)
...@@ -327,8 +325,7 @@ class Disk(object): ...@@ -327,8 +325,7 @@ class Disk(object):
def revert_snapshot(self, id): def revert_snapshot(self, id):
''' Revert qcow2 snapshot. ''' Revert qcow2 snapshot.
''' '''
cmdline = ['qemu-img', cmdline = ['snapshot',
'snapshot',
'-a', unicode(id), '-a', unicode(id),
self.get_path()] self.get_path()]
self.common_snapshot_operation(cmdline) self.common_snapshot_operation(cmdline)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment