-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: gran <gran@vmware.com>
- Loading branch information
Showing
10 changed files
with
236 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/openlyinc/pointy" | ||
"github.com/vmware/vsphere-automation-sdk-go/runtime/data" | ||
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" | ||
) | ||
|
||
// WrapInfra TODO(gran) refactor existing code in other package | ||
func (service *Service) WrapInfra(children []*data.StructValue) (*model.Infra, error) { | ||
// This is the outermost layer of the hierarchy infra client. | ||
// It doesn't need ID field. | ||
resourceType := ResourceTypeInfra | ||
infraObj := model.Infra{ | ||
Children: children, | ||
ResourceType: &resourceType, | ||
} | ||
return &infraObj, nil | ||
} | ||
|
||
func (service *Service) WrapOrgRoot(children []*data.StructValue) (*model.OrgRoot, error) { | ||
resourceType := ResourceTypeOrgRoot | ||
orgRootObj := model.OrgRoot{ | ||
Children: children, | ||
ResourceType: &resourceType, | ||
} | ||
return &orgRootObj, nil | ||
} | ||
|
||
func (service *Service) WrapOrg(org string, children []*data.StructValue) ([]*data.StructValue, error) { | ||
targetType := ResourceTypeOrg | ||
resourceType := ResourceTypeChildResourceReference | ||
|
||
childOrg := model.ChildResourceReference{ | ||
Id: &org, | ||
ResourceType: resourceType, | ||
TargetType: &targetType, | ||
Children: children, | ||
} | ||
dataValue, errors := NewConverter().ConvertToVapi(childOrg, childOrg.GetType__()) | ||
if len(errors) > 0 { | ||
return nil, errors[0] | ||
} | ||
return []*data.StructValue{dataValue.(*data.StructValue)}, nil | ||
} | ||
|
||
func (service *Service) WrapProject(nsxtProject string, children []*data.StructValue) ([]*data.StructValue, error) { | ||
targetType := ResourceTypeProject | ||
resourceType := ResourceTypeChildResourceReference | ||
|
||
childProject := model.ChildResourceReference{ | ||
Id: &nsxtProject, | ||
ResourceType: resourceType, | ||
TargetType: &targetType, | ||
Children: children, | ||
} | ||
dataValue, errors := NewConverter().ConvertToVapi(childProject, childProject.GetType__()) | ||
if len(errors) > 0 { | ||
return nil, errors[0] | ||
} | ||
return []*data.StructValue{dataValue.(*data.StructValue)}, nil | ||
} | ||
|
||
func (service *Service) WrapVPC(vpc *model.Vpc) ([]*data.StructValue, error) { | ||
vpc.ResourceType = pointy.String(ResourceTypeVpc) | ||
childVpc := model.ChildVpc{ | ||
Id: vpc.Id, | ||
MarkedForDelete: vpc.MarkedForDelete, | ||
ResourceType: "ChildVpc", | ||
Vpc: vpc, | ||
} | ||
dataValue, errs := NewConverter().ConvertToVapi(childVpc, childVpc.GetType__()) | ||
if len(errs) > 0 { | ||
return nil, errs[0] | ||
} | ||
return []*data.StructValue{dataValue.(*data.StructValue)}, nil | ||
} | ||
|
||
func (service *Service) WrapLBS(lbs *model.LBService) ([]*data.StructValue, error) { | ||
lbs.ResourceType = pointy.String(ResourceTypeLBService) | ||
childLBService := model.ChildLBService{ | ||
Id: lbs.Id, | ||
MarkedForDelete: lbs.MarkedForDelete, | ||
ResourceType: "ChildLBService", | ||
LbService: lbs, | ||
} | ||
dataValue, errs := NewConverter().ConvertToVapi(childLBService, childLBService.GetType__()) | ||
if len(errs) > 0 { | ||
return nil, errs[0] | ||
} | ||
return []*data.StructValue{dataValue.(*data.StructValue)}, nil | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package vpc | ||
|
||
import ( | ||
"github.com/vmware/vsphere-automation-sdk-go/runtime/data" | ||
"github.com/vmware/vsphere-automation-sdk-go/services/nsxt/model" | ||
) | ||
|
||
func (s *VPCService) WrapHierarchyVPC(org, nsxtProject string, vpc *model.Vpc, lbs *model.LBService) (*model.OrgRoot, error) { | ||
if lbs != nil { | ||
var vpcChildren []*data.StructValue | ||
childrenLBS, err := s.WrapLBS(lbs) | ||
if err != nil { | ||
return nil, err | ||
} | ||
vpcChildren = append(vpcChildren, childrenLBS...) | ||
vpc.Children = vpcChildren | ||
} | ||
var projectChildren []*data.StructValue | ||
childrenVPC, err := s.WrapVPC(vpc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
projectChildren = append(projectChildren, childrenVPC...) | ||
|
||
var orgChildren []*data.StructValue | ||
childrenProject, err := s.WrapProject(nsxtProject, projectChildren) | ||
if err != nil { | ||
return nil, err | ||
} | ||
orgChildren = append(orgChildren, childrenProject...) | ||
|
||
var orgRootChildren []*data.StructValue | ||
childrenOrg, err := s.WrapOrg(org, orgChildren) | ||
if err != nil { | ||
return nil, err | ||
} | ||
orgRootChildren = append(orgRootChildren, childrenOrg...) | ||
|
||
orgRoot, _ := s.WrapOrgRoot(orgRootChildren) | ||
return orgRoot, nil | ||
} |
not using a lbs_store to save the lbs item to check it later? after nsx-operator restart, how does it update the networkconfiguration?