Skip to content

Commit

Permalink
Merge pull request #125 from SNIA/update-autogen-rfsf-126
Browse files Browse the repository at this point in the history
Update emulator to match latest RF 2023.3 and SF 1.2.6
  • Loading branch information
rahlvers authored Mar 26, 2024
2 parents 66646dd + 834e58d commit 35d2778
Show file tree
Hide file tree
Showing 2,861 changed files with 65,618 additions and 13,556 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

*/__pycache__
__pycache__/*
.vs/*
.vs

2 changes: 1 addition & 1 deletion api_emulator/redfish/AccelerationFunction0_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AccelerationFunction1_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AccelerationFunction2_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AccelerationFunction3_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AccelerationFunction4_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
10 changes: 6 additions & 4 deletions api_emulator/redfish/AccountService0_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -33,15 +33,17 @@
import g
import json, os
import traceback
import logging
import logging, random, requests, string, jwt

from flask import Flask, request
from flask import Flask, request, session
from flask_restful import Resource
from .constants import *
from api_emulator.utils import check_authentication, create_path, get_json_data, create_and_patch_object, delete_object, patch_object, put_object, delete_collection, create_collection

config = {}

members = []
member_ids = []
INTERNAL_ERROR = 500

# AccountService0 does not have a Collection API
Expand All @@ -60,7 +62,7 @@ def get(self):
msg, code = check_authentication(self.auth)

if code == 200:
path = os.path.join(self.root, 'AccountService', 'index.json')
path = os.path.join(self.root, 'index.json')
return get_json_data (path)
else:
return msg, code
Expand Down
8 changes: 5 additions & 3 deletions api_emulator/redfish/AccountService1_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -33,15 +33,17 @@
import g
import json, os
import traceback
import logging
import logging, random, requests, string, jwt

from flask import Flask, request
from flask import Flask, request, session
from flask_restful import Resource
from .constants import *
from api_emulator.utils import check_authentication, create_path, get_json_data, create_and_patch_object, delete_object, patch_object, put_object, delete_collection, create_collection

config = {}

members = []
member_ids = []
INTERNAL_ERROR = 500

# AccountService1 does not have a Collection API
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AddressPool_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/Aggregate_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
8 changes: 5 additions & 3 deletions api_emulator/redfish/AggregationService_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -33,15 +33,17 @@
import g
import json, os
import traceback
import logging
import logging, random, requests, string, jwt

from flask import Flask, request
from flask import Flask, request, session
from flask_restful import Resource
from .constants import *
from api_emulator.utils import check_authentication, create_path, get_json_data, create_and_patch_object, delete_object, patch_object, put_object, delete_collection, create_collection

config = {}

members = []
member_ids = []
INTERNAL_ERROR = 500

# AggregationService does not have a Collection API
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AggregationSource_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
2 changes: 1 addition & 1 deletion api_emulator/redfish/AllowDeny0_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down
52 changes: 26 additions & 26 deletions api_emulator/redfish/AllowDeny1_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2021, The Storage Networking Industry Association.
# Copyright (c) 2017-2024, The Storage Networking Industry Association.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -27,7 +27,7 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.

# Resource implementation for - /redfish/v1/Systems/{ComputerSystemId}/NetworkInterfaces/{NetworkInterfaceId}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{AllowDenyId}
# Resource implementation for - /redfish/v1/Systems/{ComputerSystemId}/NetworkInterfaces/{NetworkInterfaceId}/NetworkDeviceFunctions/{NetworkDeviceFunctionId}/AllowDeny/{AllowDenyId}
# Program name - AllowDeny1_api.py

import g
Expand All @@ -53,18 +53,18 @@ def __init__(self, **kwargs):
self.auth = kwargs['auth']

# HTTP GET
def get(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId):
def get(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId):
logging.info('AllowDeny1 Collection get called')
msg, code = check_authentication(self.auth)

if code == 200:
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId)
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId)
return get_json_data(path)
else:
return msg, code

# HTTP POST Collection
def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId):
def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId):
logging.info('AllowDeny1 Collection post called')
msg, code = check_authentication(self.auth)

Expand All @@ -75,10 +75,10 @@ def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetwo
if "Collection" in config["@odata.type"]:
return "Invalid data in POST body", 400

if NetworkDeviceFunctionsNetworkDeviceFunctionId in members:
if NetworkDeviceFunctionId in members:
resp = 404
return resp
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId)
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId)
parent_path = os.path.dirname(path)
if not os.path.exists(path):
os.mkdir(path)
Expand All @@ -88,11 +88,11 @@ def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetwo
if request.data:
config = json.loads(request.data)
if "@odata.id" in config:
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, os.path.basename(config['@odata.id']))
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, os.path.basename(config['@odata.id']))
else:
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, str(res))
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, str(res))
else:
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, str(res))
return AllowDeny1API.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, str(res))
else:
return msg, code

Expand All @@ -104,12 +104,12 @@ def __init__(self, **kwargs):
self.auth = kwargs['auth']

# HTTP GET
def get(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId):
def get(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId):
logging.info('AllowDeny1 get called')
msg, code = check_authentication(self.auth)

if code == 200:
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
return get_json_data (path)
else:
return msg, code
Expand All @@ -119,24 +119,24 @@ def get(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetwor
# - Update the members and members.id lists
# - Attach the APIs of subordinate resources (do this only once)
# - Finally, create an instance of the subordiante resources
def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId):
def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId):
logging.info('AllowDeny1 post called')
msg, code = check_authentication(self.auth)

if code == 200:
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{3}').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
collection_path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId)
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny/{3}').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
collection_path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId)

# Check if collection exists:
if not os.path.exists(collection_path):
AllowDeny1CollectionAPI.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId)
AllowDeny1CollectionAPI.post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId)

if AllowDenyId in members:
resp = 404
return resp
try:
global config
wildcards = {'ComputerSystemId':ComputerSystemId, 'NetworkInterfaceId':NetworkInterfaceId, 'NetworkDeviceFunctionsNetworkDeviceFunctionId':NetworkDeviceFunctionsNetworkDeviceFunctionId, 'AllowDenyId':AllowDenyId, 'rb':g.rest_base}
wildcards = {'ComputerSystemId':ComputerSystemId, 'NetworkInterfaceId':NetworkInterfaceId, 'NetworkDeviceFunctionId':NetworkDeviceFunctionId, 'AllowDenyId':AllowDenyId, 'rb':g.rest_base}
config=get_AllowDeny1_instance(wildcards)
config = create_and_patch_object (config, members, member_ids, path, collection_path)
resp = config, 200
Expand All @@ -150,37 +150,37 @@ def post(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetwo
return msg, code

# HTTP PUT
def put(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId):
def put(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId):
logging.info('AllowDeny1 put called')
msg, code = check_authentication(self.auth)

if code == 200:
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
put_object(path)
return self.get(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
return self.get(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
else:
return msg, code

# HTTP PATCH
def patch(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId):
def patch(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId):
logging.info('AllowDeny1 patch called')
msg, code = check_authentication(self.auth)

if code == 200:
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
path = os.path.join(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny/{3}', 'index.json').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
patch_object(path)
return self.get(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
return self.get(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
else:
return msg, code

# HTTP DELETE
def delete(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId):
def delete(self, ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId):
logging.info('AllowDeny1 delete called')
msg, code = check_authentication(self.auth)

if code == 200:
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny/{3}').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId, AllowDenyId)
base_path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions{NetworkDeviceFunctionId}/AllowDeny').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionsNetworkDeviceFunctionId)
path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny/{3}').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId, AllowDenyId)
base_path = create_path(self.root, 'Systems/{0}/NetworkInterfaces/{1}/NetworkDeviceFunctions/{2}/AllowDeny').format(ComputerSystemId, NetworkInterfaceId, NetworkDeviceFunctionId)
return delete_object(path, base_path)
else:
return msg, code
Expand Down
Loading

0 comments on commit 35d2778

Please sign in to comment.