Skip to content

Commit

Permalink
Merge pull request #192 from Juniper/remove-deprecated-spine-features
Browse files Browse the repository at this point in the history
Remove support for deprecated template->spine attributes
  • Loading branch information
chrismarget-j authored Jan 19, 2024
2 parents 94b0e94 + 9261211 commit 7a110b1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 92 deletions.
91 changes: 26 additions & 65 deletions apstra/api_design_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,27 +518,19 @@ type RackBasedTemplateCount struct {
}

type Spine struct {
Count int
ExternalLinkSpeed LogicalDevicePortSpeed
LinkPerSuperspineSpeed LogicalDevicePortSpeed
LogicalDevice LogicalDeviceData
LinkPerSuperspineCount int
Tags []DesignTagData
ExternalLinksPerNode int
ExternalFacingNodeCount int
ExternalLinkCount int
Count int
LinkPerSuperspineSpeed LogicalDevicePortSpeed
LogicalDevice LogicalDeviceData
LinkPerSuperspineCount int
Tags []DesignTagData
}

type TemplateElementSpineRequest struct {
Count int
ExternalLinkSpeed LogicalDevicePortSpeed
LinkPerSuperspineSpeed LogicalDevicePortSpeed
LogicalDevice ObjectId
LinkPerSuperspineCount int
Tags []ObjectId
ExternalLinksPerNode int
ExternalFacingNodeCount int
ExternalLinkCount int
Count int
LinkPerSuperspineSpeed LogicalDevicePortSpeed
LogicalDevice ObjectId
LinkPerSuperspineCount int
Tags []ObjectId
}

func (o *TemplateElementSpineRequest) raw(ctx context.Context, client *Client) (*rawSpine, error) {
Expand All @@ -557,72 +549,51 @@ func (o *TemplateElementSpineRequest) raw(ctx context.Context, client *Client) (
}

return &rawSpine{
Count: o.Count,
ExternalLinkSpeed: o.ExternalLinkSpeed.raw(),
LinkPerSuperspineSpeed: o.LinkPerSuperspineSpeed.raw(),
LogicalDevice: *logicalDevice,
LinkPerSuperspineCount: o.LinkPerSuperspineCount,
Tags: tags,
ExternalLinksPerNode: o.ExternalLinksPerNode,
ExternalFacingNodeCount: o.ExternalFacingNodeCount,
ExternalLinkCount: o.ExternalLinkCount,
Count: o.Count,
LinkPerSuperspineSpeed: o.LinkPerSuperspineSpeed.raw(),
LogicalDevice: *logicalDevice,
LinkPerSuperspineCount: o.LinkPerSuperspineCount,
Tags: tags,
}, nil
}

type rawSpine struct {
Count int `json:"count"`
ExternalLinkSpeed *rawLogicalDevicePortSpeed `json:"external_link_speed,omitempty"`
LinkPerSuperspineSpeed *rawLogicalDevicePortSpeed `json:"link_per_superspine_speed"`
LogicalDevice rawLogicalDevice `json:"logical_device"`
LinkPerSuperspineCount int `json:"link_per_superspine_count"`
Tags []DesignTagData `json:"tags"`
ExternalLinksPerNode int `json:"external_links_per_node,omitempty"`
ExternalFacingNodeCount int `json:"external_facing_node_count,omitempty"`
ExternalLinkCount int `json:"external_link_count,omitempty"`
Count int `json:"count"`
LinkPerSuperspineSpeed *rawLogicalDevicePortSpeed `json:"link_per_superspine_speed"`
LogicalDevice rawLogicalDevice `json:"logical_device"`
LinkPerSuperspineCount int `json:"link_per_superspine_count"`
Tags []DesignTagData `json:"tags"`
}

func (o rawSpine) polish() (*Spine, error) {
ld, err := o.LogicalDevice.polish()

var externalLinkSpeed LogicalDevicePortSpeed
if o.ExternalLinkSpeed != nil {
externalLinkSpeed = o.ExternalLinkSpeed.parse()
}

var linkPerSuperspineSpeed LogicalDevicePortSpeed
if o.LinkPerSuperspineSpeed != nil {
linkPerSuperspineSpeed = o.LinkPerSuperspineSpeed.parse()
}

return &Spine{
Count: o.Count,
ExternalLinkSpeed: externalLinkSpeed,
LinkPerSuperspineSpeed: linkPerSuperspineSpeed,
LogicalDevice: LogicalDeviceData{
DisplayName: ld.Data.DisplayName,
Panels: ld.Data.Panels,
},
LinkPerSuperspineCount: o.LinkPerSuperspineCount,
Tags: o.Tags,
ExternalLinksPerNode: o.ExternalLinksPerNode,
ExternalFacingNodeCount: o.ExternalFacingNodeCount,
ExternalLinkCount: o.ExternalLinkCount,
LinkPerSuperspineCount: o.LinkPerSuperspineCount,
Tags: o.Tags,
}, err
}

type Superspine struct {
PlaneCount int
ExternalLinkCount int
ExternalLinkSpeed LogicalDevicePortSpeed
Tags []DesignTagData
SuperspinePerPlane int
LogicalDevice LogicalDeviceData
}

type TemplateElementSuperspineRequest struct {
PlaneCount int
ExternalLinkCount int
ExternalLinkSpeed LogicalDevicePortSpeed
Tags []ObjectId
SuperspinePerPlane int
LogicalDeviceId ObjectId
Expand All @@ -645,36 +616,26 @@ func (o *TemplateElementSuperspineRequest) raw(ctx context.Context, client *Clie

return &rawSuperspine{
PlaneCount: o.PlaneCount,
ExternalLinkCount: o.ExternalLinkCount,
ExternalLinkSpeed: o.ExternalLinkSpeed.raw(),
Tags: tags,
SuperspinePerPlane: o.SuperspinePerPlane,
LogicalDevice: *logicalDevice,
}, nil
}

type rawSuperspine struct {
PlaneCount int `json:"plane_count"`
ExternalLinkCount int `json:"external_link_count"`
ExternalLinkSpeed *rawLogicalDevicePortSpeed `json:"external_link_speed"`
Tags []DesignTagData `json:"tags"`
SuperspinePerPlane int `json:"superspine_per_plane"`
LogicalDevice rawLogicalDevice `json:"logical_device"`
PlaneCount int `json:"plane_count"`
Tags []DesignTagData `json:"tags"`
SuperspinePerPlane int `json:"superspine_per_plane"`
LogicalDevice rawLogicalDevice `json:"logical_device"`
}

func (o rawSuperspine) polish() (*Superspine, error) {
ld, err := o.LogicalDevice.polish()
if err != nil {
return nil, err
}
var externalLinkSpeed LogicalDevicePortSpeed
if o.ExternalLinkSpeed != nil {
externalLinkSpeed = o.ExternalLinkSpeed.parse()
}
return &Superspine{
PlaneCount: o.PlaneCount,
ExternalLinkCount: o.ExternalLinkCount,
ExternalLinkSpeed: externalLinkSpeed,
Tags: o.Tags,
SuperspinePerPlane: o.SuperspinePerPlane,
LogicalDevice: LogicalDeviceData{
Expand Down
29 changes: 10 additions & 19 deletions apstra/api_design_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,15 +523,11 @@ func TestCreateGetDeleteRackBasedTemplate(t *testing.T) {
DisplayName: dn,
Capability: TemplateCapabilityBlueprint,
Spine: &TemplateElementSpineRequest{
Count: 2,
ExternalLinkSpeed: "10G",
LinkPerSuperspineSpeed: "10G",
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: 1,
Tags: []ObjectId{"firewall", "hypervisor"},
ExternalLinksPerNode: 0,
ExternalFacingNodeCount: 0,
ExternalLinkCount: 0,
Count: 2,
LinkPerSuperspineSpeed: "10G",
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: 1,
Tags: []ObjectId{"firewall", "hypervisor"},
},
RackInfos: map[ObjectId]TemplateRackBasedRackInfo{
"access_switch": {
Expand Down Expand Up @@ -582,14 +578,11 @@ func TestCreateGetDeletePodBasedTemplate(t *testing.T) {
DisplayName: rbtdn,
Capability: TemplateCapabilityBlueprint,
Spine: &TemplateElementSpineRequest{
Count: 2,
LinkPerSuperspineSpeed: "10G",
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: 1,
Tags: nil,
ExternalLinksPerNode: 0,
ExternalFacingNodeCount: 0,
ExternalLinkCount: 0,
Count: 2,
LinkPerSuperspineSpeed: "10G",
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: 1,
Tags: nil,
},
RackInfos: map[ObjectId]TemplateRackBasedRackInfo{
"access_switch": {
Expand All @@ -616,8 +609,6 @@ func TestCreateGetDeletePodBasedTemplate(t *testing.T) {
Capability: TemplateCapabilityPod,
Superspine: &TemplateElementSuperspineRequest{
PlaneCount: 1,
ExternalLinkCount: 0,
ExternalLinkSpeed: "10G",
Tags: nil,
SuperspinePerPlane: 4,
LogicalDeviceId: "AOS-4x40_8x10-1",
Expand Down
12 changes: 4 additions & 8 deletions apstra/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,14 +595,10 @@ func testTemplateB(ctx context.Context, t *testing.T, client *Client) (ObjectId,
DisplayName: rbt.Data.DisplayName,
Capability: rbt.Data.Capability,
Spine: &TemplateElementSpineRequest{
Count: rbt.Data.Spine.Count,
ExternalLinkSpeed: rbt.Data.Spine.ExternalLinkSpeed,
LinkPerSuperspineSpeed: rbt.Data.Spine.LinkPerSuperspineSpeed,
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: rbt.Data.Spine.LinkPerSuperspineCount,
ExternalLinksPerNode: rbt.Data.Spine.ExternalLinksPerNode,
ExternalFacingNodeCount: rbt.Data.Spine.ExternalFacingNodeCount,
ExternalLinkCount: rbt.Data.Spine.ExternalLinkCount,
Count: rbt.Data.Spine.Count,
LinkPerSuperspineSpeed: rbt.Data.Spine.LinkPerSuperspineSpeed,
LogicalDevice: "AOS-7x10-Spine",
LinkPerSuperspineCount: rbt.Data.Spine.LinkPerSuperspineCount,
},
RackInfos: rbt.Data.RackInfo,
DhcpServiceIntent: &rbt.Data.DhcpServiceIntent,
Expand Down

0 comments on commit 7a110b1

Please sign in to comment.