Skip to content

Commit

Permalink
Port Opts YAML did not follow proper conventions
Browse files Browse the repository at this point in the history
The yaml for the vnic type required an argument "binding:vnicType" when
it should have been "vnicType". The HostID had the same issue. We also
created a struct for the FixedIPs to ensure the api remains camel case.
  • Loading branch information
Emilio Garcia committed Apr 13, 2021
1 parent 223c5de commit 4492710
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
11 changes: 8 additions & 3 deletions pkg/apis/openstackproviderconfig/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,25 +205,30 @@ type PortOpts struct {
Description string `json:"description,omitempty"`
AdminStateUp *bool `json:"adminStateUp,omitempty"`
MACAddress string `json:"macAddress,omitempty"`
FixedIPs []ports.IP `json:"fixedIPs,omitempty"`
FixedIPs []FixedIPs `json:"fixedIPs,omitempty"`
TenantID string `json:"tenantID,omitempty"`
ProjectID string `json:"projectID,omitempty"`
SecurityGroups *[]string `json:"securityGroups,omitempty"`
AllowedAddressPairs []ports.AddressPair `json:"allowedAddressPairs,omitempty"`
Tags []string `json:"tags,omitempty"`

// The ID of the host where the port is allocated
HostID string `json:"binding:hostID,omitempty"`
HostID string `json:"hostID,omitempty"`

// The virtual network interface card (vNIC) type that is bound to the
// neutron port.
VNICType string `json:"binding:vnicType,omitempty"`
VNICType string `json:"vnicType,omitempty"`

// enable or disable security on a given port
// incompatible with securityGroups and allowedAddressPairs
PortSecurity *bool `json:"portSecurity,omitempty"`
}

type FixedIPs struct {
SubnetID string `json:"subnetID"`
IPAddress string `json:"ipAddress,omitempty"`
}

type RootVolume struct {
SourceType string `json:"sourceType,omitempty"`
SourceUUID string `json:"sourceUUID,omitempty"`
Expand Down
9 changes: 7 additions & 2 deletions pkg/cloud/openstack/clients/machineservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ func getOrCreatePort(is *InstanceService, name string, portOpts openstackconfigv
AllowedAddressPairs: portOpts.AllowedAddressPairs,
}
if len(portOpts.FixedIPs) != 0 {
createOpts.FixedIPs = portOpts.FixedIPs
fixedIPs := make([]ports.IP, len(portOpts.FixedIPs))
for i, fixedIP := range portOpts.FixedIPs {
fixedIPs[i].SubnetID = fixedIP.SubnetID
fixedIPs[i].IPAddress = fixedIP.IPAddress
}
createOpts.FixedIPs = fixedIPs
}
newPort, err := ports.Create(is.networkClient, portsbinding.CreateOptsExt{
CreateOptsBuilder: createOpts,
Expand Down Expand Up @@ -510,7 +515,7 @@ func (is *InstanceService) InstanceCreate(clusterName string, name string, clust
for _, snet := range snetResults {
nets = append(nets, openstackconfigv1.PortOpts{
NetworkID: snet.NetworkID,
FixedIPs: []ports.IP{{SubnetID: snet.ID}},
FixedIPs: []openstackconfigv1.FixedIPs{{SubnetID: snet.ID}},
Tags: append(net.PortTags, snetParam.PortTags...),
VNICType: net.VNICType,
PortSecurity: portSecurity,
Expand Down

0 comments on commit 4492710

Please sign in to comment.