Skip to content

Commit

Permalink
Merge a2c86c8 into 4d0c7a2
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogpsf committed Oct 31, 2018
2 parents 4d0c7a2 + a2c86c8 commit 14a036e
Show file tree
Hide file tree
Showing 9 changed files with 885 additions and 1,201 deletions.
19 changes: 8 additions & 11 deletions oneview_redfish_toolkit/api/computer_system_collection.py
Expand Up @@ -35,7 +35,7 @@ class ComputerSystemCollection(RedfishJsonValidator):
SCHEMA_NAME = 'ComputerSystemCollection'

def __init__(self,
sh_with_profile_applied,
server_profile_list,
server_profile_templates,
zone_ids):
"""ComputerSystemCollection constructor
Expand All @@ -45,8 +45,7 @@ def __init__(self,
Server Profile applied and all server profile templates.
Args:
sh_with_profile_applied: A list of dicts of server hardware
with profile applied.
server_profile_list: A list of dicts of Server Profile applied
server_profile_templates: A list of dicts of server profile
templates
zone_ids: A list of Zone Ids
Expand All @@ -56,7 +55,7 @@ def __init__(self,
self.redfish["@odata.type"] = self.get_odata_type()
self.redfish["Name"] = "Computer System Collection"
server_profile_members_list = \
self._get_server_profile_members_list(sh_with_profile_applied)
self._get_server_profile_members_list(server_profile_list)
self.redfish["Members@odata.count"] = \
len(server_profile_members_list)
self.redfish["Members"] = server_profile_members_list
Expand All @@ -70,27 +69,25 @@ def __init__(self,

self._validate()

def _get_server_profile_members_list(self, server_hardware_list):
def _get_server_profile_members_list(self, server_profile_list):
"""Returns a redfish members list with all server profiles applied
Iterate over the server hardware list, filter the
UUIDs of server profiles that are applied and mounts
the member item to be filled on Redfish Members.
Args:
server_hardware_list: list of Oneview's server
hardwares information.
server_profile_list: list of Oneview's Server
Profiles information.
Returns:
list: list of computer system members to be filled on
Redfish Members.
"""
members = list()
for server_hardware in server_hardware_list:
server_profile_uuid = \
server_hardware["serverProfileUri"].split("/")[-1]
for server_profile in server_profile_list:
members.append({
"@odata.id": "/redfish/v1/Systems/" + server_profile_uuid
"@odata.id": "/redfish/v1/Systems/" + server_profile["uuid"]
})

return members
Expand Down
Expand Up @@ -36,17 +36,18 @@ def get_computer_system_collection():
Returns:
JSON: JSON with ComputerSystemCollection.
"""
server_hardware_list = g.oneview_client.server_hardware.get_all(
filter="NOT 'serverProfileUri' = NULL"
)

server_profile_list = g.oneview_client.server_profiles.get_all()
server_profile_list = list(filter(lambda i: i.get('serverHardwareUri'),
server_profile_list))

server_profile_tmpls = \
g.oneview_client.server_profile_templates.get_all()

zone_service = ZoneService(g.oneview_client)
zone_ids = zone_service.get_zone_ids_by_templates(server_profile_tmpls)

csc = ComputerSystemCollection(server_hardware_list,
csc = ComputerSystemCollection(server_profile_list,
server_profile_tmpls,
zone_ids)

Expand Down
1 change: 1 addition & 0 deletions oneview_redfish_toolkit/handler_multiple_oneview.py
Expand Up @@ -73,6 +73,7 @@
"server_profiles": {
"delete": st.delete_server_profile,
"get": st.first_parameter_resource,
"get_all": st.all_oneviews_resource,
"get_available_targets": st.first_parameter_resource,
},
"server_profile_templates": {
Expand Down

0 comments on commit 14a036e

Please sign in to comment.