2
0
mirror of https://opendev.org/x/pyghmi synced 2026-03-27 21:33:31 +00:00

Extend overwrite protection to ipmi module

This affords the same protection that the redfish module now
has.

Change-Id: Icc3e4f90427b2912d4d18d60af6f1f599b8005d9
This commit is contained in:
Jarrod Johnson
2020-01-31 10:36:02 -05:00
parent d93718e306
commit 296f7d30dd

View File

@@ -16,6 +16,7 @@
"""This represents the low layer message framing portion of IPMI"""
from itertools import chain
import os
import socket
import struct
import threading
@@ -454,6 +455,10 @@ class Command(object):
return rsp
def get_diagnostic_data(self, savefile, progress=None, autosuffix=False):
if os.path.exists(savefile) and not os.path.isdir(savefile):
raise exc.InvalidParameterValue(
'Not allowed to overwrite existing file: {0}'.format(
savefile))
self.oem_init()
return self._oem.get_diagnostic_data(savefile, progress, autosuffix)
@@ -2034,6 +2039,10 @@ class Command(object):
return self._oem.delete_license(name)
def save_licenses(self, directory):
if os.path.exists(directory) and not os.path.isdir(directory):
raise exc.InvalidParameterValue(
'Not allowed to overwrite existing file: {0}'.format(
directory))
self.oem_init()
return self._oem.save_licenses(directory)