|
| 1 | +// SPDX-FileCopyrightText: 2025 SAP SE or an SAP affiliate company and IronCore contributors |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package v1alpha1 |
| 5 | + |
| 6 | +import ( |
| 7 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 8 | +) |
| 9 | + |
| 10 | +// kind: NXOSVirtualPortchannel |
| 11 | + |
| 12 | +// spec: |
| 13 | +// id: 69 |
| 14 | +// rolePriority: 100 |
| 15 | +// systemPriority: 10 |
| 16 | +// delayRestore: 150 |
| 17 | + |
| 18 | +// peer: |
| 19 | +// switch: |
| 20 | +// enabled: true |
| 21 | +// gateway: |
| 22 | +// enabled: true |
| 23 | +// router: # layer3 peer-router |
| 24 | +// enabled: true |
| 25 | +// keepalive: |
| 26 | +// source: 10.114.235.155 |
| 27 | +// destination: 10.114.235.156 |
| 28 | +// autoRecovery: |
| 29 | +// reloadDelay: 360 |
| 30 | +// fastConvergence: |
| 31 | +// enabled: true |
| 32 | +// peerLinkRef: # could also go into peer.linkRef |
| 33 | +// - name: ora-sw1101a-bb101-po104 |
| 34 | + |
| 35 | +// NXOSVPCSpec defines the desired state of NXOSVPC (Cisco's NXOS Virtual Port Channel) |
| 36 | +type NXOSVPCSpec struct { |
| 37 | + // DeviceName is the name of the Device this object belongs to. The Device object must exist in the same namespace. |
| 38 | + // Immutable. |
| 39 | + // +required |
| 40 | + // +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceRef is immutable" |
| 41 | + DeviceRef LocalObjectReference `json:"deviceRef"` |
| 42 | + |
| 43 | + // ID is the vPC domain ID. |
| 44 | + // +required |
| 45 | + // +kubebuilder:validation:Minimum=1 |
| 46 | + // +kubebuilder:validation:Maximum=1000 |
| 47 | + DomainID int32 `json:"domainId"` |
| 48 | + |
| 49 | + // AdminState is the administrative state of the vPC domain. |
| 50 | + // +optional |
| 51 | + // +kubebuilder:default="enabled" |
| 52 | + AdminState string `json:"adminState,omitempty"` |
| 53 | + |
| 54 | + // RolePriority is the role priority for this vPC domain. |
| 55 | + // +optional |
| 56 | + // +kubebuilder:validation:Minimum=1 |
| 57 | + // +kubebuilder:validation:Maximum=65535 |
| 58 | + RolePriority int32 `json:"rolePriority,omitempty"` |
| 59 | + |
| 60 | + // SystemPriority is the system priority for this vPC domain. |
| 61 | + // +optional |
| 62 | + // +kubebuilder:validation:Minimum=1 |
| 63 | + // +kubebuilder:validation:Maximum=65535 |
| 64 | + SystemPriority int32 `json:"systemPriority,omitempty"` |
| 65 | + |
| 66 | + // DelayRestoreSVI is the delay in bringing up bringing-up the interface-vlan |
| 67 | + // +optional |
| 68 | + // +kubebuilder:validation:Minimum=1 |
| 69 | + // +kubebuilder:validation:Maximum=3600 |
| 70 | + DelayRestoreSVI int32 `json:"delayRestoreSVI,omitempty"` |
| 71 | + |
| 72 | + // DelayRestoreVPC is the delay in bringing up the vPC links after restoring the peer-link |
| 73 | + // +optional |
| 74 | + // +kubebuilder:validation:Minimum=1 |
| 75 | + // +kubebuilder:validation:Maximum=3600 |
| 76 | + DelayRestoreVPC int32 `json:"delayRestoreVPC,omitempty"` |
| 77 | + |
| 78 | + // +optional |
| 79 | + FastConvergence AdminSt `json:"fastConvergence,omitzero"` |
| 80 | + |
| 81 | + // +optional |
| 82 | + Peer Peer `json:"peer,omitzero"` |
| 83 | +} |
| 84 | + |
| 85 | +// AdminSt represents administrative state (enabled/disabled) |
| 86 | +type AdminSt struct { |
| 87 | + // +required |
| 88 | + Enabled bool `json:"enabled"` |
| 89 | +} |
| 90 | + |
| 91 | +type Peer struct { |
| 92 | + // TODO |
| 93 | + //LinkRef []LocalObjectReference `json:"linkRef,omitempty"` |
| 94 | + // +optional |
| 95 | + KeepAlive KeepAlive `json:"keepalive,omitzero"` |
| 96 | + AutoRecovery AutoRecovery `json:"autoRecovery"` |
| 97 | + PeerSwitch AdminSt `json:"peerSwitch"` |
| 98 | + PeerGateway AdminSt `json:"peerGateway"` |
| 99 | + // Router defines layer3 peer-router settings |
| 100 | + Router AdminSt `json:"router"` |
| 101 | +} |
| 102 | + |
| 103 | +type KeepAlive struct { |
| 104 | + // Source IP address for keepalive messages |
| 105 | + // +kubebuilder:validation:MinLength=1 |
| 106 | + // +kubebuilder:validation:MaxLength=253 |
| 107 | + Source string `json:"source,omitempty"` |
| 108 | + // Destination IP address for keepalive messages |
| 109 | + // +kubebuilder:validation:MinLength=1 |
| 110 | + // +kubebuilder:validation:MaxLength=253 |
| 111 | + Destination string `json:"destination,omitempty"` |
| 112 | +} |
| 113 | + |
| 114 | +type AutoRecovery struct { |
| 115 | + Enabled bool `json:"enabled,omitempty"` |
| 116 | + // +optional |
| 117 | + // +kubebuilder:validation:Minimum=60 |
| 118 | + // +kubebuilder:validation:Maximum=3600 |
| 119 | + ReloadDelay uint32 `json:"reloadDelay,omitempty"` |
| 120 | +} |
| 121 | + |
| 122 | +// NXOSVPCStatus defines the observed state of NXOSVPC. |
| 123 | +type NXOSVPCStatus struct { |
| 124 | + // The conditions are a list of status objects that describe the state of the VPC. |
| 125 | + //+listType=map |
| 126 | + //+listMapKey=type |
| 127 | + //+patchStrategy=merge |
| 128 | + //+patchMergeKey=type |
| 129 | + //+optional |
| 130 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 131 | +} |
| 132 | + |
| 133 | +// +kubebuilder:object:root=true |
| 134 | +// +kubebuilder:subresource:status |
| 135 | +// +kubebuilder:resource:path=nxosvpcs |
| 136 | +// +kubebuilder:resource:singular=nxosvpc |
| 137 | +// +kubebuilder:resource:shortName=vpc |
| 138 | +// +kubebuilder:printcolumn:name="Domain",type=string,JSONPath=`.spec.domainId` |
| 139 | +// +kubebuilder:printcolumn:name="AdminState",type=string,JSONPath=`.spec.adminState` |
| 140 | +// +kubebuilder:printcolumn:name="Device",type=string,JSONPath=`.spec.deviceRef.name` |
| 141 | +// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status` |
| 142 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 143 | + |
| 144 | +// NXOSVPC is the Schema for the nxosvpcs API |
| 145 | +type NXOSVPC struct { |
| 146 | + metav1.TypeMeta `json:",inline"` |
| 147 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 148 | + |
| 149 | + // spec defines the desired state of NXOSVPC |
| 150 | + // +required |
| 151 | + Spec NXOSVPCSpec `json:"spec,omitempty"` |
| 152 | + |
| 153 | + // status defines the observed state of NXOSVPC |
| 154 | + // +optional |
| 155 | + Status NXOSVPCStatus `json:"status,omitempty,omitzero"` |
| 156 | +} |
| 157 | + |
| 158 | +// +kubebuilder:object:root=true |
| 159 | + |
| 160 | +// NXOSVPCList contains a list of NXOSVPC |
| 161 | +type NXOSVPCList struct { |
| 162 | + metav1.TypeMeta `json:",inline"` |
| 163 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 164 | + Items []NXOSVPC `json:"items"` |
| 165 | +} |
| 166 | + |
| 167 | +func init() { |
| 168 | + SchemeBuilder.Register(&NXOSVPC{}, &NXOSVPCList{}) |
| 169 | +} |
0 commit comments