Skip to content

Commit

Permalink
Bug 1942686: Extend trunk configuration to port level in machineset
Browse files Browse the repository at this point in the history
With the introduction of new technologies, like SR-IOV,
it is required that the user have the ability to
configured trunked and not-trunked ports for the same machines.
  • Loading branch information
Adolfo Duarte committed Apr 16, 2021
1 parent fc80c59 commit 961e021
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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

0 comments on commit 961e021

Please sign in to comment.