Skip to content

Commit

Permalink
Merge branch 'master' into storage_volume_issue_368
Browse files Browse the repository at this point in the history
  • Loading branch information
nabhajit-ray authored Sep 2, 2022
2 parents b3d88b8 + 728ec4a commit 0c3a680
Show file tree
Hide file tree
Showing 3 changed files with 251 additions and 46 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html)#

# [v7.2.0] (unreleased)
#### Notes
- This release extends supports of the SDK to Oneview API Version 4400.

### New Changes
- Added support to use portname instead of relative value during LIG creation.

# [v7.2.0](unreleased)
#### Notes
Expand Down
196 changes: 174 additions & 22 deletions examples/logical_interconnect_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package main

import (
"fmt"
"github.com/HewlettPackard/oneview-golang/ov"
"os"
"strconv"

"github.com/HewlettPackard/oneview-golang/ov"
"github.com/HewlettPackard/oneview-golang/utils"
)

func newTrue() *bool {
Expand All @@ -21,7 +23,7 @@ func main() {
clientOV *ov.OVClient
lig_name = "TestLIG-GO"
lig_type = "logical-interconnect-groupV8"
new_lig_name = "RenamedLogicalInterConnectGroup"
new_lig_name = "RenamedLogicalInterConnectGroupGO"
)
apiversion, _ := strconv.Atoi(os.Getenv("ONEVIEW_APIVERSION"))

Expand All @@ -36,13 +38,13 @@ func main() {

fmt.Println("#..........Creating Logical Interconnect Group.....#")
locationEntry_first := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_second := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_second := ov.LocationEntry{Type: "Enclosure", RelativeValue: 3}
locationEntries1 := new([]ov.LocationEntry)
*locationEntries1 = append(*locationEntries1, locationEntry_first)
*locationEntries1 = append(*locationEntries1, locationEntry_second)

locationEntry_third := ov.LocationEntry{Type: "Bay", RelativeValue: 6}
locationEntry_four := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_four := ov.LocationEntry{Type: "Enclosure", RelativeValue: 3}
locationEntries2 := new([]ov.LocationEntry)
*locationEntries2 = append(*locationEntries2, locationEntry_third)
*locationEntries2 = append(*locationEntries2, locationEntry_four)
Expand All @@ -65,14 +67,14 @@ func main() {
logicalLocation3 := ov.LogicalLocation{LocationEntries: *locationEntries3}
logicalLocation4 := ov.LogicalLocation{LocationEntries: *locationEntries4}

locationEntry_nine := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ten := ov.LocationEntry{Type: "Enclosure", RelativeValue: 3}
locationEntry_nine := ov.LocationEntry{Type: "Bay", RelativeValue: 6}
locationEntry_ten := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntries5 := new([]ov.LocationEntry)
*locationEntries5 = append(*locationEntries5, locationEntry_nine)
*locationEntries5 = append(*locationEntries5, locationEntry_ten)

locationEntry_eleven := ov.LocationEntry{Type: "Bay", RelativeValue: 6}
locationEntry_twelle := ov.LocationEntry{Type: "Enclosure", RelativeValue: 3}
locationEntry_eleven := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_twelle := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntries6 := new([]ov.LocationEntry)
*locationEntries6 = append(*locationEntries6, locationEntry_eleven)
*locationEntries6 = append(*locationEntries6, locationEntry_twelle)
Expand All @@ -81,32 +83,34 @@ func main() {
logicalLocation6 := ov.LogicalLocation{LocationEntries: *locationEntries6}

interconnect1, err := ovc.GetInterconnectTypeByName("Virtual Connect SE 40Gb F8 Module for Synergy")
interconnect2, err := ovc.GetInterconnectTypeByName("Synergy 10Gb Interconnect Link Module")
interconnect2, err := ovc.GetInterconnectTypeByName("Synergy 20Gb Interconnect Link Module")

if err != nil {
fmt.Println(err)
}

interconnectMapEntryTemplate1 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation1,
PermittedInterconnectTypeUri: interconnect1.URI,
EnclosureIndex: 1}
PermittedInterconnectTypeUri: interconnect2.URI,
EnclosureIndex: 3}

interconnectMapEntryTemplate2 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation2,
PermittedInterconnectTypeUri: interconnect1.URI,
EnclosureIndex: 1}
PermittedInterconnectTypeUri: interconnect2.URI,
EnclosureIndex: 3}

interconnectMapEntryTemplate3 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation3,
PermittedInterconnectTypeUri: interconnect2.URI,
EnclosureIndex: 2}

interconnectMapEntryTemplate4 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation4,
PermittedInterconnectTypeUri: interconnect2.URI,
PermittedInterconnectTypeUri: interconnect1.URI,
EnclosureIndex: 2}

interconnectMapEntryTemplate5 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation5,
PermittedInterconnectTypeUri: interconnect2.URI,
EnclosureIndex: 3}
EnclosureIndex: 1}
interconnectMapEntryTemplate6 := ov.InterconnectMapEntryTemplate{LogicalLocation: logicalLocation6,
PermittedInterconnectTypeUri: interconnect2.URI,
EnclosureIndex: 3}
PermittedInterconnectTypeUri: interconnect1.URI,
EnclosureIndex: 1}

interconnectMapEntryTemplates := new([]ov.InterconnectMapEntryTemplate)
*interconnectMapEntryTemplates = append(*interconnectMapEntryTemplates, interconnectMapEntryTemplate1)
Expand All @@ -117,7 +121,6 @@ func main() {
*interconnectMapEntryTemplates = append(*interconnectMapEntryTemplates, interconnectMapEntryTemplate6)

interconnectMapTemplate := ov.InterconnectMapTemplate{InterconnectMapEntryTemplates: *interconnectMapEntryTemplates}
fmt.Println(&interconnectMapTemplate)

enclosureIndexes := []int{1, 2, 3}

Expand Down Expand Up @@ -154,6 +157,149 @@ func main() {
qosConfig := ov.QosConfiguration{ActiveQosConfig: &qosActiveConfig,
Type: "qos-aggregated-configuration",
Category: "qos-aggregated-configuration"}
networkUris := []utils.Nstring{"/rest/ethernet-networks/bf5a6091-ef32-4983-90b7-d5a3848c7274"}
networkUris2 := []utils.Nstring{"/rest/fc-networks/5900d2f8-cfde-4ecd-81b9-750843d22a18"}
networkUris3 := []utils.Nstring{"/rest/fc-networks/8a1c4708-6439-4b62-8a2b-841f9b36ceae"}
//************************uplink set 1**************************************************

portname1_1 := "Q1"
interconnectypeUri11 := interconnect1.URI
relativeValueport11, _ := ovc.GetRelativeValue(portname1_1, interconnectypeUri11)
locationEntry_usfirst1 := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ussecond1 := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_usthird1 := ov.LocationEntry{Type: "Port", RelativeValue: relativeValueport11}
locationEntriesus1 := new([]ov.LocationEntry)
*locationEntriesus1 = append(*locationEntriesus1, locationEntry_usfirst1)
*locationEntriesus1 = append(*locationEntriesus1, locationEntry_ussecond1)
*locationEntriesus1 = append(*locationEntriesus1, locationEntry_usthird1)

logicalLocationus1 := ov.LogicalLocation{LocationEntries: *locationEntriesus1}
logicalportconfigInfous1 := ov.LogicalPortConfigInfo{
DesiredSpeed: "Auto",
DesiredFecMode: "Auto",
LogicalLocation: logicalLocationus1,
}

logicalportconfigInfos := new([]ov.LogicalPortConfigInfo)
*logicalportconfigInfos = append(*logicalportconfigInfos, logicalportconfigInfous1)

uplinkSet1 := ov.UplinkSets{
EthernetNetworkType: "Tagged",
LacpTimer: "Short",
LogicalPortConfigInfos: *logicalportconfigInfos,
Mode: "Auto",
FcMode: "NA",
LoadBalancingMode: "SourceAndDestinationMac",
Name: "us1",
NetworkType: "Ethernet",
NetworkUris: networkUris,
}
//*****************************uplink set 2********************************
//First port

//get port relative value

portname2_1 := "Q2:1"
interconnectypeUri21 := interconnect1.URI
relativeValueport21, _ := ovc.GetRelativeValue(portname2_1, interconnectypeUri21)
locationEntry_usfirst2 := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ussecond2 := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_usthird2 := ov.LocationEntry{Type: "Port", RelativeValue: relativeValueport21}
locationEntriesus2 := new([]ov.LocationEntry)
*locationEntriesus2 = append(*locationEntriesus2, locationEntry_usfirst2)
*locationEntriesus2 = append(*locationEntriesus2, locationEntry_ussecond2)
*locationEntriesus2 = append(*locationEntriesus2, locationEntry_usthird2)
logicalLocationus2 := ov.LogicalLocation{LocationEntries: *locationEntriesus2}
logicalportconfigInfous2_1 := ov.LogicalPortConfigInfo{
DesiredSpeed: "Auto",
DesiredFecMode: "Auto",
LogicalLocation: logicalLocationus2,
}
// second port
portname2_2 := "Q2:2"
interconnectypeUri22 := interconnect1.URI
relativeValueport22, _ := ovc.GetRelativeValue(portname2_2, interconnectypeUri22)
locationEntry_usfirst2_2 := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ussecond2_2 := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_usthird2_2 := ov.LocationEntry{Type: "Port", RelativeValue: relativeValueport22}
locationEntriesus2_2 := new([]ov.LocationEntry)
*locationEntriesus2_2 = append(*locationEntriesus2_2, locationEntry_usfirst2_2)
*locationEntriesus2_2 = append(*locationEntriesus2_2, locationEntry_ussecond2_2)
*locationEntriesus2_2 = append(*locationEntriesus2_2, locationEntry_usthird2_2)
logicalLocationus2_2 := ov.LogicalLocation{LocationEntries: *locationEntriesus2_2}
logicalportconfigInfous2_2 := ov.LogicalPortConfigInfo{
DesiredSpeed: "Auto",
DesiredFecMode: "Auto",
LogicalLocation: logicalLocationus2_2,
}

logicalportconfigInfos2 := new([]ov.LogicalPortConfigInfo)
*logicalportconfigInfos2 = append(*logicalportconfigInfos2, logicalportconfigInfous2_1)
*logicalportconfigInfos2 = append(*logicalportconfigInfos2, logicalportconfigInfous2_2)

uplinkSet2 := ov.UplinkSets{
EthernetNetworkType: "NotApplicable",
LogicalPortConfigInfos: *logicalportconfigInfos2,
Mode: "Auto",
FcMode: "NA",
LoadBalancingMode: "None",
Name: "us2",
NetworkType: "FibreChannel",
NetworkUris: networkUris2,
}

//********************************uplink set 3********************************************
//First port
portname3_1 := "Q3:1"
interconnectypeUri31 := interconnect1.URI
relativeValueport31, _ := ovc.GetRelativeValue(portname3_1, interconnectypeUri31)
locationEntry_usfirst3 := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ussecond3 := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_usthird3 := ov.LocationEntry{Type: "Port", RelativeValue: relativeValueport31}
locationEntriesus3 := new([]ov.LocationEntry)
*locationEntriesus3 = append(*locationEntriesus3, locationEntry_usfirst3)
*locationEntriesus3 = append(*locationEntriesus3, locationEntry_ussecond3)
*locationEntriesus3 = append(*locationEntriesus3, locationEntry_usthird3)
logicalLocationus3 := ov.LogicalLocation{LocationEntries: *locationEntriesus3}
logicalportconfigInfous3_1 := ov.LogicalPortConfigInfo{
DesiredSpeed: "Auto",
DesiredFecMode: "Auto",
LogicalLocation: logicalLocationus3,
}
// second port
portname3_2 := "Q3:2"
interconnectypeUri32 := interconnect1.URI
relativeValueport32, _ := ovc.GetRelativeValue(portname3_2, interconnectypeUri32)
locationEntry_usfirst3_2 := ov.LocationEntry{Type: "Bay", RelativeValue: 3}
locationEntry_ussecond3_2 := ov.LocationEntry{Type: "Enclosure", RelativeValue: 1}
locationEntry_usthird3_2 := ov.LocationEntry{Type: "Port", RelativeValue: relativeValueport32}
locationEntriesus3_2 := new([]ov.LocationEntry)
*locationEntriesus3_2 = append(*locationEntriesus3_2, locationEntry_usfirst3_2)
*locationEntriesus3_2 = append(*locationEntriesus3_2, locationEntry_ussecond3_2)
*locationEntriesus3_2 = append(*locationEntriesus3_2, locationEntry_usthird3_2)
logicalLocationus3_2 := ov.LogicalLocation{LocationEntries: *locationEntriesus3_2}
logicalportconfigInfous3_2 := ov.LogicalPortConfigInfo{
DesiredSpeed: "Auto",
DesiredFecMode: "Auto",
LogicalLocation: logicalLocationus3_2,
}

logicalportconfigInfos3 := new([]ov.LogicalPortConfigInfo)
*logicalportconfigInfos3 = append(*logicalportconfigInfos3, logicalportconfigInfous3_1)
*logicalportconfigInfos3 = append(*logicalportconfigInfos3, logicalportconfigInfous3_2)

uplinkSet3 := ov.UplinkSets{
EthernetNetworkType: "NotApplicable",
LogicalPortConfigInfos: *logicalportconfigInfos3,
Mode: "Auto",
FcMode: "NA",
LoadBalancingMode: "None",
Name: "us3",
NetworkType: "FibreChannel",
NetworkUris: networkUris3,
}

uplinkSets := []ov.UplinkSets{uplinkSet1, uplinkSet2, uplinkSet2, uplinkSet3}

logicalInterconnectGroup := ov.LogicalInterconnectGroup{Type: lig_type,
EthernetSettings: &ethernetSettings,
Expand All @@ -164,21 +310,27 @@ func main() {
EnclosureType: "SY12000",
EnclosureIndexes: enclosureIndexes,
InterconnectBaySet: 3,
RedundancyType: "Redundant",
RedundancyType: "HighlyAvailable",
SnmpConfiguration: &snmpConfig,
QosConfiguration: &qosConfig}
QosConfiguration: &qosConfig,
UplinkSets: uplinkSets}
er := ovc.CreateLogicalInterconnectGroup(logicalInterconnectGroup)
if er != nil {
fmt.Println("........Logical Interconnect Group Creation failed:", er)
} else {
fmt.Println(".....Logical Interconnect Group Creation Success....")
}

logicalInterconnectGroupAuto := ov.LogicalInterconnectGroup{Type: lig_type,
EthernetSettings: &ethernetSettings,
IgmpSettings: &igmpSettings,
Name: "Auto-LIG",
Name: "Auto-LIG1",
TelemetryConfiguration: &telemetryConfig,
InterconnectMapTemplate: &interconnectMapTemplate,
EnclosureType: "SY12000",
EnclosureIndexes: enclosureIndexes,
InterconnectBaySet: 3,
RedundancyType: "Redundant",
RedundancyType: "HighlyAvailable",
SnmpConfiguration: &snmpConfig,
QosConfiguration: &qosConfig}
er = ovc.CreateLogicalInterconnectGroup(logicalInterconnectGroupAuto)
Expand Down
Loading

0 comments on commit 0c3a680

Please sign in to comment.