Skip to content

Commit

Permalink
remove CT "FromFile" experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismarget-j committed Jul 19, 2023
1 parent 42f927d commit 41231e5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
54 changes: 0 additions & 54 deletions apstra/two_stage_l3_clos_connectivity_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"fmt"
"net/http"
"net/url"
"os"
)

const (
Expand Down Expand Up @@ -666,56 +665,3 @@ func (o *TwoStageL3ClosClient) GetAllConnectivityTemplateStates(ctx context.Cont

return result, nil
}

func GetAllConnectivityTemplatesFromFile(file string) ([]ConnectivityTemplate, error) {
b, err := os.ReadFile(file)
if err != nil {
return nil, err
}

var raw rawConnectivityTemplate
err = json.Unmarshal(b, &raw)
if err != nil {
return nil, err
}

ids := raw.rootBatchIds()
result := make([]ConnectivityTemplate, len(ids))
for i, id := range ids {
polished, err := raw.polish(id)
if err != nil {
return nil, err
}
result[i] = *polished
}

return result, nil
}

func GetAllConnectivityTemplateStatesFromFile(file string) ([]ConnectivityTemplateState, error) {
b, err := os.ReadFile(file)
if err != nil {
return nil, err
}

var response struct {
EndpointPolicies []rawConnectivityTemplateState `json:"endpoint_policies"`
}
err = json.Unmarshal(b, &response)
if err != nil {
return nil, err
}

result := make([]ConnectivityTemplateState, 0, len(response.EndpointPolicies)/3)
for _, rawPolicy := range response.EndpointPolicies {
if rawPolicy.Visible {
polished, err := rawPolicy.polish()
if err != nil {
return nil, err
}
result = append(result, *polished)
}
}

return result, nil
}
28 changes: 0 additions & 28 deletions apstra/two_stage_l3_clos_connectivity_template_unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package apstra

import (
"encoding/json"
"log"
"testing"
)

Expand Down Expand Up @@ -240,30 +239,3 @@ func TestBgpOverL3Connectivity(t *testing.T) {
t.Fatalf("expected:\n %s\n\n got:\n%s", expectedUserData, *resultUserData)
}
}

func TestGetAllConnectivityTemplatesFromFile(t *testing.T) {
file := "/Users/cmarget/20230717-090911/42a2f25d-ba82-423c-9bf2-c715c7ce9748/obj-policy-export"
cts, err := GetAllConnectivityTemplatesFromFile(file)
if err != nil {
t.Fatal(err)
}

for i, ct := range cts {
if ct.Id == nil {
t.Fatalf("CT at index %d has nil ID", i)
}
log.Println(ct.Id)
}
}

func TestGetAllConnectivityTemplateStatesFromFile(t *testing.T) {
file := "/Users/cmarget/20230717-090911/42a2f25d-ba82-423c-9bf2-c715c7ce9748/endpoint-policies"
ctStates, err := GetAllConnectivityTemplateStatesFromFile(file)
if err != nil {
t.Fatal(err)
}

for _, ctState := range ctStates {
log.Println(ctState.Id)
}
}

0 comments on commit 41231e5

Please sign in to comment.