Last active
November 16, 2017 16:41
-
-
Save jsmartt/fdd804617ae962f899af79b800d8c341 to your computer and use it in GitHub Desktop.
Method to get the network_type of a particular ServerHardware
This file contains hidden or 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
def get_oneview_hw_network_type(client, hw) | |
enclosure = find_oneview_resource(:Enclosure, client, uri: hw['locationUri']) | |
logical_enclosure = find_oneview_resource(:LogicalEnclosure, client, uri: enclosure['logicalEnclosureUri']) | |
interconnect_type_uris = [] # List of InterconnectType URIs in this LogicalEnclosure | |
return 'unmanaged' if logical_enclosure['logicalInterconnectUris'].blank? | |
logical_enclosure['logicalInterconnectUris'].each do |li_uri| | |
li = find_oneview_logical_interconnect!(client, uri: li_uri) | |
# Keep track of the LogicalInterconnect URIs for this LogicalEnclosure | |
interconnect_type_uris |= li['interconnectMap']['interconnectMapEntries'].map { |e| e['permittedInterconnectTypeUri'] }.compact | |
end | |
# Get the full list of InterconnectTypes | |
interconnect_types = client.response_handler(client.rest_get('/rest/interconnect-types'))['members'] | |
# Keep only the InterconnectType names of the types in this LogicalEnclosure | |
interconnect_type_names = interconnect_types.select { |i| interconnect_type_uris.include?(i['uri']) }.pluck('name') | |
# Return the network_type based on InterconnectType names | |
interconnect_type_names.each do |name| | |
case name | |
when /^(?=.*\bSynergy\b)(?=.*\b(VC|Virtual ?Connect)\b).*$/i then return 'synergy-vc' | |
when /\b(VC|Virtual ?Connect)\b/ then return 'vc' | |
end | |
end | |
nil # else return nil (unknown type) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment