Expose VirtualMedia on Systems in addition to Managers

VirtualMedia on Managers is deprecated, so make System the primary
source while keeping compatibility.

Change-Id: I933d0d5c9f78109f46eb314bef05cc8d653d7137
This commit is contained in:
Dmitry Tantsur 2023-12-11 12:46:57 +01:00
parent 19acb66e91
commit a654a033de
No known key found for this signature in database
GPG Key ID: 315B2AF9FD216C60
7 changed files with 112 additions and 118 deletions

View File

@ -0,0 +1,4 @@
---
features:
- |
Exposes the VirtualMedia resource directly on Systems, not just Managers.

View File

@ -18,19 +18,19 @@ from sushy_tools import error
virtual_media = flask.Blueprint(
'VirtualMedia', __name__,
url_prefix='/redfish/v1/Managers/<identity>/VirtualMedia')
url_prefix='/redfish/v1/Systems/<identity>/VirtualMedia')
@virtual_media.route('', methods=['GET'])
@api_utils.returns_json
def virtual_media_collection_resource(identity):
api_utils.debug('Serving virtual media resources for manager "%s"',
api_utils.debug('Serving virtual media resources for system "%s"',
identity)
return flask.render_template(
'virtual_media_collection.json',
identity=identity,
uuid=flask.current_app.managers.get_manager(identity)['UUID'],
uuid=flask.current_app.systems.uuid(identity),
devices=flask.current_app.vmedia.devices
)
@ -47,7 +47,7 @@ def virtual_media_resource(identity, device):
device_info = flask.current_app.vmedia.get_device_image_info(
identity, device)
api_utils.debug('Serving virtual media %s at manager "%s"',
api_utils.debug('Serving virtual media %s at system "%s"',
device, identity)
return flask.render_template(
@ -69,11 +69,11 @@ def virtual_media_resource(identity, device):
@virtual_media.route('/<device>', methods=['PATCH'])
@api_utils.returns_json
def virtual_media_patch(identity, device):
flask.current_app.managers.get_manager(identity)
flask.current_app.systems.uuid(identity)
if not flask.request.json:
raise error.BadRequest("Empty or malformed patch")
api_utils.debug('Updating virtual media %s at manager "%s"',
api_utils.debug('Updating virtual media %s at system "%s"',
device, identity)
verify = flask.request.json.get('VerifyCertificate')
@ -91,9 +91,9 @@ def virtual_media_patch(identity, device):
@virtual_media.route('/<device>/Certificates', methods=['GET'])
@api_utils.returns_json
def virtual_media_certificates(identity, device):
flask.current_app.managers.get_manager(identity)
flask.current_app.systems.uuid(identity)
location = \
f'/redfish/v1/Managers/{identity}/VirtualMedia/{device}/Certificates'
f'/redfish/v1/Systems/{identity}/VirtualMedia/{device}/Certificates'
certificates = flask.current_app.vmedia.list_certificates(identity, device)
return flask.render_template(
'certificate_collection.json',
@ -105,7 +105,7 @@ def virtual_media_certificates(identity, device):
@virtual_media.route('/<device>/Certificates', methods=['POST'])
@api_utils.returns_json
def virtual_media_add_certificate(identity, device):
flask.current_app.managers.get_manager(identity)
flask.current_app.systems.uuid(identity)
if not flask.request.json:
raise error.BadRequest("Empty or malformed certificate")
@ -120,13 +120,13 @@ def virtual_media_add_certificate(identity, device):
f"Only PEM certificates are supported, got {cert_type}")
api_utils.debug('Adding certificate for virtual media %s at '
'manager "%s"', device, identity)
'system "%s"', device, identity)
cert = flask.current_app.vmedia.add_certificate(
identity, device, cert_string, cert_type)
location = (
f'/redfish/v1/Managers/{identity}/VirtualMedia/{device}'
f'/redfish/v1/Systems/{identity}/VirtualMedia/{device}'
f'/Certificates/{cert.id}'
)
return '', 204, {'Location': location}
@ -135,9 +135,9 @@ def virtual_media_add_certificate(identity, device):
@virtual_media.route('/<device>/Certificates/<cert_id>', methods=['GET'])
@api_utils.returns_json
def virtual_media_get_certificate(identity, device, cert_id):
flask.current_app.managers.get_manager(identity)
flask.current_app.systems.uuid(identity)
location = (
f'/redfish/v1/Managers/{identity}/VirtualMedia/{device}'
f'/redfish/v1/Systems/{identity}/VirtualMedia/{device}'
f'/Certificates/{cert_id}'
)
certificates = flask.current_app.vmedia.list_certificates(identity, device)
@ -158,9 +158,9 @@ def virtual_media_get_certificate(identity, device, cert_id):
@virtual_media.route('/<device>/Certificates/<cert_id>', methods=['DELETE'])
@api_utils.returns_json
def virtual_media_delete_certificate(identity, device, cert_id):
flask.current_app.managers.get_manager(identity)
flask.current_app.systems.uuid(identity)
api_utils.debug('Removing certificate %s for virtual media %s at '
'manager "%s"', cert_id, device, identity)
'system "%s"', cert_id, device, identity)
flask.current_app.vmedia.delete_certificate(identity, device, cert_id)
return '', 204
@ -179,32 +179,27 @@ def virtual_media_insert(identity, device):
message = "UserName and Password must be passed together"
return flask.render_template('error.json', message=message), 400
manager = flask.current_app.managers.get_manager(identity)
systems = flask.current_app.managers.get_managed_systems(manager)
if not systems:
api_utils.warning('Manager %s manages no systems', identity)
return '', 204
system = flask.current_app.systems.uuid(identity)
image_path = flask.current_app.vmedia.insert_image(
identity, device, image, inserted, write_protected,
username=username, password=password)
for system in systems:
try:
flask.current_app.systems.set_boot_image(
system, device, boot_image=image_path,
write_protected=write_protected)
try:
flask.current_app.systems.set_boot_image(
system, device, boot_image=image_path,
write_protected=write_protected)
except error.NotSupportedError as ex:
api_utils.warning(
'System %s failed to set boot image %s on device %s: '
'%s', system, image_path, device, ex)
api_utils.info(
'Virtual media placed into device %(dev)s of manager %(mgr)s for '
'systems %(sys)s. Image %(img)s inserted %(ins)s',
{'dev': device, 'mgr': identity, 'sys': systems,
'img': image or '<empty>', 'ins': inserted})
except error.NotSupportedError as ex:
api_utils.warning(
'System %s failed to set boot image %s on device %s: '
'%s', system, image_path, device, ex)
else:
api_utils.info(
'Virtual media placed into device %(dev)s for '
'system %(sys)s. Image %(img)s inserted %(ins)s',
{'dev': device, 'sys': identity,
'img': image or '<empty>', 'ins': inserted})
return '', 204
@ -215,23 +210,16 @@ def virtual_media_insert(identity, device):
def virtual_media_eject(identity, device):
flask.current_app.vmedia.eject_image(identity, device)
manager = flask.current_app.managers.get_manager(identity)
systems = flask.current_app.managers.get_managed_systems(manager)
if not systems:
api_utils.warning('Manager %s manages no systems', identity)
return '', 204
try:
flask.current_app.systems.set_boot_image(identity, device)
for system in systems:
try:
flask.current_app.systems.set_boot_image(system, device)
except error.NotSupportedError as ex:
api_utils.warning(
'System %s failed to remove boot image from device %s: '
'%s', system, device, ex)
api_utils.info(
'Virtual media ejected from device %s manager %s systems %s',
device, identity, systems)
except error.NotSupportedError as ex:
api_utils.warning(
'System %s failed to remove boot image from device %s: '
'%s', identity, device, ex)
else:
api_utils.info(
'Virtual media ejected from device %s system %s',
device, identity)
return '', 204

View File

@ -343,7 +343,7 @@ def manager_resource(identity):
"PowerState": "On",
"FirmwareVersion": "1.00",
"VirtualMedia": {
"@odata.id": "/redfish/v1/Managers/%s/VirtualMedia" % uuid
"@odata.id": "/redfish/v1/Systems/%s/VirtualMedia" % systems[0],
},
"Links": {
"ManagerForServers": [

View File

@ -1,5 +1,5 @@
{
"@odata.type": "#ComputerSystem.v1_1_0.ComputerSystem",
"@odata.type": "#ComputerSystem.v1_13_0.ComputerSystem",
"Id": {{ identity|string|tojson }},
"Name": {{ name|string|tojson }},
"UUID": {{ uuid|string|tojson }},
@ -85,6 +85,9 @@
{%- if indicator_led %}
"IndicatorLED": {{ indicator_led|string|tojson }},
{%- endif %}
"VirtualMedia": {
"@odata.id": {{ "/redfish/v1/Systems/%s/VirtualMedia"|format(identity)|tojson }}
},
"Links": {
"Chassis": [
{%- for chassis_ in chassis %}

View File

@ -14,20 +14,20 @@
"WriteProtected": {{ write_protected|tojson }},
"Actions": {
"#VirtualMedia.EjectMedia": {
"target": {{ "/redfish/v1/Managers/%s/VirtualMedia/%s/Actions/VirtualMedia.EjectMedia"|format(identity, device)|string|tojson }}
"target": {{ "/redfish/v1/Systems/%s/VirtualMedia/%s/Actions/VirtualMedia.EjectMedia"|format(identity, device)|string|tojson }}
},
"#VirtualMedia.InsertMedia": {
"target": {{ "/redfish/v1/Managers/%s/VirtualMedia/%s/Actions/VirtualMedia.InsertMedia"|format(identity, device)|string|tojson }}
"target": {{ "/redfish/v1/Systems/%s/VirtualMedia/%s/Actions/VirtualMedia.InsertMedia"|format(identity, device)|string|tojson }}
},
"Oem": {}
},
"UserName": {{ username|string|tojson }},
"Password": "{{ '******' if password else '' }}",
"Certificates": {
"@odata.id": {{ "/redfish/v1/Managers/%s/VirtualMedia/%s/Certificates"|format(identity, device)|tojson }}
"@odata.id": {{ "/redfish/v1/Systems/%s/VirtualMedia/%s/Certificates"|format(identity, device)|tojson }}
},
"VerifyCertificate": {{ verify_certificate|tojson }},
"@odata.context": "/redfish/v1/$metadata#VirtualMedia.VirtualMedia",
"@odata.id": {{ "/redfish/v1/Managers/%s/VirtualMedia/%s"|format(identity, device)|string|tojson }},
"@odata.id": {{ "/redfish/v1/Systems/%s/VirtualMedia/%s"|format(identity, device)|string|tojson }},
"@Redfish.Copyright": "Copyright 2014-2017 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}

View File

@ -6,11 +6,11 @@
"Members": [
{% for device in devices %}
{
"@odata.id": {{ "/redfish/v1/Managers/%s/VirtualMedia/%s"|format(uuid, device)|string|tojson }}
"@odata.id": {{ "/redfish/v1/Systems/%s/VirtualMedia/%s"|format(uuid, device)|string|tojson }}
}{% if not loop.last %},{% endif %}
{% endfor %}
],
"@odata.context": "/redfish/v1/$metadata#VirtualMediaCollection.VirtualMediaCollection",
"@odata.id": {{ "/redfish/v1/Managers/%s/VirtualMedia"|format(uuid)|string|tojson }},
"@odata.id": {{ "/redfish/v1/Systems/%s/VirtualMedia"|format(uuid)|string|tojson }},
"@Redfish.Copyright": "Copyright 2014-2017 Distributed Management Task Force, Inc. (DMTF). For the full DMTF copyright policy, see http://www.dmtf.org/about/policies/copyright."
}
}

View File

@ -16,38 +16,37 @@ from sushy_tools.tests.unit.emulator import test_main
@test_main.patch_resource('vmedia')
@test_main.patch_resource('managers')
@test_main.patch_resource('systems')
class VirtualMediaTestCase(test_main.EmulatorTestCase):
def test_virtual_media_collection(self, managers_mock, vmedia_mock):
managers_mock = managers_mock.return_value
managers_mock.managers = [self.uuid]
managers_mock.get_manager.return_value = {'UUID': self.uuid}
def test_virtual_media_collection(self, systems_mock, vmedia_mock):
systems_mock = systems_mock.return_value
systems_mock.uuid.return_value = self.uuid
vmedia_mock.return_value.devices = ['CD', 'Floppy']
response = self.app.get(
'/redfish/v1/Managers/%s/VirtualMedia' % self.uuid)
'/redfish/v1/Systems/%s/VirtualMedia' % self.uuid)
self.assertEqual(200, response.status_code)
self.assertEqual('Virtual Media Services', response.json['Name'])
self.assertEqual(2, response.json['Members@odata.count'])
self.assertEqual(
['/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid,
'/redfish/v1/Managers/%s/VirtualMedia/Floppy' % self.uuid],
['/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid,
'/redfish/v1/Systems/%s/VirtualMedia/Floppy' % self.uuid],
[m['@odata.id'] for m in response.json['Members']])
def test_virtual_media_collection_empty(self, managers_mock, vmedia_mock):
def test_virtual_media_collection_empty(self, systems_mock, vmedia_mock):
vmedia_mock.return_value.get_devices.return_value = []
response = self.app.get(
'redfish/v1/Managers/' + self.uuid + '/VirtualMedia')
'redfish/v1/Systems/' + self.uuid + '/VirtualMedia')
self.assertEqual(200, response.status_code)
self.assertEqual('Virtual Media Services', response.json['Name'])
self.assertEqual(0, response.json['Members@odata.count'])
self.assertEqual([], response.json['Members'])
def test_virtual_media(self, managers_mock, vmedia_mock):
def test_virtual_media(self, systems_mock, vmedia_mock):
vmedia_mock = vmedia_mock.return_value
vmedia_mock.get_device_name.return_value = 'CD'
vmedia_mock.get_device_media_types.return_value = [
@ -56,7 +55,7 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
'image-of-a-fish', 'fishy.iso', True, True, '', '', False)
response = self.app.get(
'/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid)
'/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid)
self.assertEqual(200, response.status_code, response.json)
self.assertEqual('CD', response.json['Id'])
@ -69,10 +68,10 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
self.assertEqual('', response.json['Password'])
self.assertFalse(response.json['VerifyCertificate'])
self.assertEqual(
'/redfish/v1/Managers/%s/VirtualMedia/CD/Certificates' % self.uuid,
'/redfish/v1/Systems/%s/VirtualMedia/CD/Certificates' % self.uuid,
response.json['Certificates']['@odata.id'])
def test_virtual_media_with_auth(self, managers_mock, vmedia_mock):
def test_virtual_media_with_auth(self, systems_mock, vmedia_mock):
vmedia_mock = vmedia_mock.return_value
vmedia_mock.get_device_name.return_value = 'CD'
vmedia_mock.get_device_media_types.return_value = [
@ -82,7 +81,7 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
False)
response = self.app.get(
'/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid)
'/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid)
self.assertEqual(200, response.status_code, response.json)
self.assertEqual('CD', response.json['Id'])
@ -95,17 +94,17 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
self.assertEqual('******', response.json['Password'])
self.assertFalse(response.json['VerifyCertificate'])
def test_virtual_media_not_found(self, managers_mock, vmedia_mock):
def test_virtual_media_not_found(self, systems_mock, vmedia_mock):
vmedia_mock.return_value.get_device_name.side_effect = error.NotFound
response = self.app.get(
'/redfish/v1/Managers/%s/VirtualMedia/DVD-ROM' % self.uuid)
'/redfish/v1/Systems/%s/VirtualMedia/DVD-ROM' % self.uuid)
self.assertEqual(404, response.status_code)
def test_virtual_media_update(self, managers_mock, vmedia_mock):
def test_virtual_media_update(self, systems_mock, vmedia_mock):
response = self.app.patch(
'/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid,
'/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid,
json={'VerifyCertificate': True})
self.assertEqual(204, response.status_code)
@ -113,32 +112,32 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
vmedia_mock.update_device_info.assert_called_once_with(
self.uuid, 'CD', verify=True)
def test_virtual_media_update_not_found(self, managers_mock, vmedia_mock):
def test_virtual_media_update_not_found(self, systems_mock, vmedia_mock):
vmedia_mock = vmedia_mock.return_value
vmedia_mock.update_device_info.side_effect = error.NotFound
response = self.app.patch(
'/redfish/v1/Managers/%s/VirtualMedia/DVD-ROM' % self.uuid,
'/redfish/v1/Systems/%s/VirtualMedia/DVD-ROM' % self.uuid,
json={'VerifyCertificate': True})
self.assertEqual(404, response.status_code)
def test_virtual_media_update_invalid(self, managers_mock, vmedia_mock):
def test_virtual_media_update_invalid(self, systems_mock, vmedia_mock):
response = self.app.patch(
'/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid,
'/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid,
json={'VerifyCertificate': 'banana'})
self.assertEqual(400, response.status_code)
def test_virtual_media_update_empty(self, managers_mock, vmedia_mock):
def test_virtual_media_update_empty(self, systems_mock, vmedia_mock):
response = self.app.patch(
'/redfish/v1/Managers/%s/VirtualMedia/CD' % self.uuid)
'/redfish/v1/Systems/%s/VirtualMedia/CD' % self.uuid)
self.assertEqual(400, response.status_code)
def test_virtual_media_insert(self, managers_mock, vmedia_mock):
def test_virtual_media_insert(self, systems_mock, vmedia_mock):
response = self.app.post(
'/redfish/v1/Managers/%s/VirtualMedia/CD/Actions/'
'/redfish/v1/Systems/%s/VirtualMedia/CD/Actions/'
'VirtualMedia.InsertMedia' % self.uuid,
json={"Image": "http://fish.iso"})
@ -147,9 +146,9 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
vmedia_mock.return_value.insert_image.called_once_with(
'CD', 'http://fish.iso', True, False)
def test_virtual_media_eject(self, managers_mock, vmedia_mock):
def test_virtual_media_eject(self, systems_mock, vmedia_mock):
response = self.app.post(
'/redfish/v1/Managers/%s/VirtualMedia/CD/Actions/'
'/redfish/v1/Systems/%s/VirtualMedia/CD/Actions/'
'VirtualMedia.EjectMedia' % self.uuid,
json={})
@ -157,67 +156,67 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
vmedia_mock.return_value.eject_image.called_once_with('CD')
def test_virtual_media_certificates(self, managers_mock, vmedia_mock):
def test_virtual_media_certificates(self, systems_mock, vmedia_mock):
vmedia_mock.return_value.list_certificates.return_value = [
vmedia.Certificate('1', 'PEM', 'abcd'),
vmedia.Certificate('2', 'PEM', 'dcba'),
]
response = self.app.get(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates')
self.assertEqual(200, response.status_code, response.json)
self.assertEqual(2, response.json['Members@odata.count'])
for index, member in enumerate(response.json['Members']):
self.assertTrue(member['@odata.id'].endswith(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD'
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD'
f'/Certificates/{index+1}'), member['@odata.id'])
self.assertEqual(['PEM'],
response.json['@Redfish.SupportedCertificates'])
def test_virtual_media_certificates_manager_not_found(self, managers_mock,
vmedia_mock):
managers_mock.return_value.get_manager.side_effect = error.NotFound
def test_virtual_media_certificates_system_not_found(self, systems_mock,
vmedia_mock):
systems_mock.return_value.uuid.side_effect = error.NotFound
response = self.app.get(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates')
self.assertEqual(404, response.status_code, response.json)
def test_virtual_media_add_certificate(self, managers_mock, vmedia_mock):
def test_virtual_media_add_certificate(self, systems_mock, vmedia_mock):
vmedia_mock.return_value.add_certificate.return_value = \
vmedia.Certificate('9', 'abcd', 'PEM')
response = self.app.post(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates',
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates',
json={'CertificateString': 'abcd', 'CertificateType': 'PEM'})
self.assertEqual(204, response.status_code, response.data)
self.assertIn(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates/9',
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates/9',
response.headers['Location'])
def test_virtual_media_add_certificate_no_string(self, managers_mock,
def test_virtual_media_add_certificate_no_string(self, systems_mock,
vmedia_mock):
response = self.app.post(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates',
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates',
json={'CertificateType': 'PEM'})
self.assertEqual(400, response.status_code, response.data)
def test_virtual_media_add_certificate_bad_type(self, managers_mock,
def test_virtual_media_add_certificate_bad_type(self, systems_mock,
vmedia_mock):
response = self.app.post(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates',
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates',
json={'CertificateString': 'abcd', 'CertificateType': 'non-PEM'})
self.assertEqual(400, response.status_code, response.data)
def test_virtual_media_get_certificate(self, managers_mock, vmedia_mock):
def test_virtual_media_get_certificate(self, systems_mock, vmedia_mock):
vmedia_mock.return_value.list_certificates.return_value = [
vmedia.Certificate('1', 'abcd', 'PEM'),
vmedia.Certificate('2', 'dcba', 'PEM'),
]
response = self.app.get(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates/2')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates/2')
self.assertEqual(200, response.status_code, response.json)
self.assertIn('Id', response.json)
@ -225,30 +224,30 @@ class VirtualMediaTestCase(test_main.EmulatorTestCase):
self.assertEqual('dcba', response.json['CertificateString'])
self.assertEqual('PEM', response.json['CertificateType'])
def test_virtual_media_get_certificate_manager_not_found(self,
managers_mock,
vmedia_mock):
managers_mock.return_value.get_manager.side_effect = error.NotFound
def test_virtual_media_get_certificate_system_not_found(self,
systems_mock,
vmedia_mock):
systems_mock.return_value.uuid.side_effect = error.NotFound
response = self.app.get(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates/2')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates/2')
self.assertEqual(404, response.status_code, response.json)
def test_virtual_media_delete_certificate(self, managers_mock,
def test_virtual_media_delete_certificate(self, systems_mock,
vmedia_mock):
response = self.app.delete(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates/2')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates/2')
self.assertEqual(204, response.status_code, response.data)
vmedia_mock.return_value.delete_certificate.assert_called_once_with(
self.uuid, 'CD', '2')
def test_virtual_media_delete_certificate_manager_not_found(self,
managers_mock,
vmedia_mock):
managers_mock.return_value.get_manager.side_effect = error.NotFound
def test_virtual_media_delete_certificate_system_not_found(self,
systems_mock,
vmedia_mock):
systems_mock.return_value.uuid.side_effect = error.NotFound
response = self.app.delete(
f'/redfish/v1/Managers/{self.uuid}/VirtualMedia/CD/Certificates/2')
f'/redfish/v1/Systems/{self.uuid}/VirtualMedia/CD/Certificates/2')
self.assertEqual(404, response.status_code, response.json)
vmedia_mock.return_value.delete_certificate.assert_not_called()