Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Bug 1942686: Extend trunk configuration to port level in machineset #176

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/apis/openstackproviderconfig/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ type PortOpts struct {
// enable or disable security on a given port
// incompatible with securityGroups and allowedAddressPairs
PortSecurity *bool `json:"portSecurity,omitempty"`

// Port is to be part of a trunk
Trunk bool `json:"trunnk,omitempty"`
}

type FixedIPs struct {
Expand Down
19 changes: 17 additions & 2 deletions pkg/cloud/openstack/clients/machineservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,14 +438,27 @@ func GetSecurityGroups(is *InstanceService, sg_param []openstackconfigv1.Securit
return sgIDs, nil
}


func configNeedsTrunk( config *openstackconfigv1.OpenstackProviderSpec) bool {
if config.Trunk == true {
return true
}
for _, portCreateOpts := range config.Ports {
if portCreateOpts.Trunk {
return true
}
}
return false
}

// InstanceCreate creates a compute instance.
// If ServerGroupName is nonempty and no server group exists with that name,
// then InstanceCreate creates a server group with that name.
func (is *InstanceService) InstanceCreate(clusterName string, name string, clusterSpec *openstackconfigv1.OpenstackClusterProviderSpec, config *openstackconfigv1.OpenstackProviderSpec, cmd string, keyName string, configClient configclient.ConfigV1Interface) (instance *Instance, err error) {
if config == nil {
return nil, fmt.Errorf("create Options need be specified to create instace")
}
if config.Trunk == true {
if configNeedsTrunk(config) == true {
trunkSupport, err := GetTrunkSupport(is)
if err != nil {
return nil, fmt.Errorf("There was an issue verifying whether trunk support is available, please disable it: %v", err)
Expand Down Expand Up @@ -494,6 +507,7 @@ func (is *InstanceService) InstanceCreate(clusterName string, name string, clust
Tags: net.PortTags,
VNICType: net.VNICType,
PortSecurity: net.PortSecurity,
Trunk: config.Trunk,
})
}

Expand All @@ -519,6 +533,7 @@ func (is *InstanceService) InstanceCreate(clusterName string, name string, clust
Tags: append(net.PortTags, snetParam.PortTags...),
VNICType: net.VNICType,
PortSecurity: portSecurity,
Trunk: config.Trunk,
})
}
}
Expand Down Expand Up @@ -575,7 +590,7 @@ func (is *InstanceService) InstanceCreate(clusterName string, name string, clust
Port: port.ID,
})

if config.Trunk == true {
if portOpt.Trunk == true {
allPages, err := trunks.List(is.networkClient, trunks.ListOpts{
Name: name,
PortID: port.ID,
Expand Down