コード例 #1
0
ファイル: imagebackend.py プロジェクト: VeenaSL/sriov
 def write_to_disk_info_file():
     # Use os.open to create it without group or world write permission.
     fd = os.open(self.disk_info_path, os.O_RDWR | os.O_CREAT, 0o644)
     with os.fdopen(fd, "r+") as disk_info_file:
         line = disk_info_file.read().rstrip()
         dct = _dict_from_line(line)
         if self.path in dct:
             msg = _("Attempted overwrite of an existing value.")
             raise exception.InvalidDiskInfo(reason=msg)
         dct.update({self.path: driver_format})
         disk_info_file.seek(0)
         disk_info_file.truncate()
         disk_info_file.write('%s\n' % jsonutils.dumps(dct))
     # Ensure the file is always owned by the nova user so qemu can't
     # write it.
     utils.chown(self.disk_info_path, owner_uid=os.getuid())
コード例 #2
0
 def write_to_disk_info_file():
     # Use os.open to create it without group or world write permission.
     fd = os.open(self.disk_info_path, os.O_RDWR | os.O_CREAT, 0o644)
     with os.fdopen(fd, "r+") as disk_info_file:
         line = disk_info_file.read().rstrip()
         dct = _dict_from_line(line)
         if self.path in dct:
             msg = _("Attempted overwrite of an existing value.")
             raise exception.InvalidDiskInfo(reason=msg)
         dct.update({self.path: driver_format})
         disk_info_file.seek(0)
         disk_info_file.truncate()
         disk_info_file.write('%s\n' % jsonutils.dumps(dct))
     # Ensure the file is always owned by the nova user so qemu can't
     # write it.
     utils.chown(self.disk_info_path, owner_uid=os.getuid())