forked from SNIA/Swordfish-API-Emulator
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* issue_17: remove redfish emulator cloning in setup.sh file Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com> * issue_17: remove redfish emulator cloning in setup.sh file Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com> * adapt test to new architecture Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com> * call virtualenv creation option to test.sh Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com> * add DMTF Redfish emulator header Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com> --------- Signed-off-by: Bruno Mesnet <bruno.mesnet@fr.ibm.com>
- Loading branch information
Showing
10 changed files
with
416 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright Notice: | ||
# Copyright 2016-2019 DMTF. All rights reserved. | ||
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/main/LICENSE.md | ||
|
||
# Redfish Emulator Role Service. | ||
# Temporary version, to be removed when AccountService goes dynamic | ||
|
||
class AccountService(object): | ||
|
||
def __init__(self): | ||
self._accounts = { 'Administrator': 'Password', | ||
'User': 'Password' } | ||
self._roles = { 'Administrator': 'Admin', | ||
'User': 'ReadOnlyUser' } | ||
|
||
def checkPriviledgeLevel(self, user, level): | ||
if self._roles[user] == level: | ||
return True | ||
else: | ||
return False | ||
|
||
def getPassword(self, username): | ||
if username in self._accounts: | ||
return self._accounts[username] | ||
else: | ||
return None | ||
|
||
def checkPrivilege(self, privilege, username, errorResponse): | ||
def wrap(func): | ||
def inner(*args, **kwargs): | ||
if self.checkPriviledgeLevel(username(), privilege): | ||
return func(*args, **kwargs) | ||
else: | ||
return errorResponse() | ||
return inner | ||
return wrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Copyright Notice: | ||
# Copyright 2016-2019 DMTF. All rights reserved. | ||
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/main/LICENSE.md | ||
|
||
# Exceptions thrown in the Emulator | ||
|
||
class ConfigurationError(Exception): | ||
pass | ||
|
||
class StaticLoadError(Exception): | ||
pass | ||
|
||
class CreatePooledNodeError(Exception): | ||
pass | ||
|
||
class RemovePooledNodeError(Exception): | ||
pass | ||
|
||
class OVFParseError(Exception): | ||
pass | ||
|
||
class EventSubscriptionError(Exception): | ||
pass | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright Notice: | ||
# Copyright 2016-2019 DMTF. All rights reserved. | ||
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/main/LICENSE.md | ||
|
||
# Resource Dictionary | ||
|
||
# Variable to store resource dictionary | ||
import logging | ||
|
||
resdict = {} | ||
|
||
class ResourceDictionary(object): | ||
|
||
def __init__(self): | ||
logging.info('Init ResourceDictionary.') | ||
|
||
|
||
def get_resource(self, path): | ||
obj = resdict[path].configuration | ||
return obj | ||
|
||
def get_object(self, path): | ||
return resdict[path] | ||
|
||
def add_resource(self, path, obj): | ||
resdict[path] = obj | ||
return obj | ||
|
||
def delete_resource(self, path): | ||
del resdict[path] | ||
|
||
def print_dictionary(self): | ||
for x in resdict: | ||
print('Key: ') | ||
print(x) | ||
print('Value: ') | ||
print(resdict[x]) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright Notice: | ||
# Copyright 2016-2019 DMTF. All rights reserved. | ||
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/main/LICENSE.md | ||
|
||
__version__ = '1.1.9' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.