github.com/vmware/govmomi@v0.51.0/object/host_network_system.go (about) 1 // © Broadcom. All Rights Reserved. 2 // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. 3 // SPDX-License-Identifier: Apache-2.0 4 5 package object 6 7 import ( 8 "context" 9 10 "github.com/vmware/govmomi/vim25" 11 "github.com/vmware/govmomi/vim25/methods" 12 "github.com/vmware/govmomi/vim25/types" 13 ) 14 15 type HostNetworkSystem struct { 16 Common 17 } 18 19 func NewHostNetworkSystem(c *vim25.Client, ref types.ManagedObjectReference) *HostNetworkSystem { 20 return &HostNetworkSystem{ 21 Common: NewCommon(c, ref), 22 } 23 } 24 25 // AddPortGroup wraps methods.AddPortGroup 26 func (o HostNetworkSystem) AddPortGroup(ctx context.Context, portgrp types.HostPortGroupSpec) error { 27 req := types.AddPortGroup{ 28 This: o.Reference(), 29 Portgrp: portgrp, 30 } 31 32 _, err := methods.AddPortGroup(ctx, o.c, &req) 33 if err != nil { 34 return err 35 } 36 37 return nil 38 } 39 40 // AddServiceConsoleVirtualNic wraps methods.AddServiceConsoleVirtualNic 41 func (o HostNetworkSystem) AddServiceConsoleVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error) { 42 req := types.AddServiceConsoleVirtualNic{ 43 This: o.Reference(), 44 Portgroup: portgroup, 45 Nic: nic, 46 } 47 48 res, err := methods.AddServiceConsoleVirtualNic(ctx, o.c, &req) 49 if err != nil { 50 return "", err 51 } 52 53 return res.Returnval, nil 54 } 55 56 // AddVirtualNic wraps methods.AddVirtualNic 57 func (o HostNetworkSystem) AddVirtualNic(ctx context.Context, portgroup string, nic types.HostVirtualNicSpec) (string, error) { 58 req := types.AddVirtualNic{ 59 This: o.Reference(), 60 Portgroup: portgroup, 61 Nic: nic, 62 } 63 64 res, err := methods.AddVirtualNic(ctx, o.c, &req) 65 if err != nil { 66 return "", err 67 } 68 69 return res.Returnval, nil 70 } 71 72 // AddVirtualSwitch wraps methods.AddVirtualSwitch 73 func (o HostNetworkSystem) AddVirtualSwitch(ctx context.Context, vswitchName string, spec *types.HostVirtualSwitchSpec) error { 74 req := types.AddVirtualSwitch{ 75 This: o.Reference(), 76 VswitchName: vswitchName, 77 Spec: spec, 78 } 79 80 _, err := methods.AddVirtualSwitch(ctx, o.c, &req) 81 if err != nil { 82 return err 83 } 84 85 return nil 86 } 87 88 // QueryNetworkHint wraps methods.QueryNetworkHint 89 func (o HostNetworkSystem) QueryNetworkHint(ctx context.Context, device []string) ([]types.PhysicalNicHintInfo, error) { 90 req := types.QueryNetworkHint{ 91 This: o.Reference(), 92 Device: device, 93 } 94 95 res, err := methods.QueryNetworkHint(ctx, o.c, &req) 96 if err != nil { 97 return nil, err 98 } 99 100 return res.Returnval, err 101 } 102 103 // RefreshNetworkSystem wraps methods.RefreshNetworkSystem 104 func (o HostNetworkSystem) RefreshNetworkSystem(ctx context.Context) error { 105 req := types.RefreshNetworkSystem{ 106 This: o.Reference(), 107 } 108 109 _, err := methods.RefreshNetworkSystem(ctx, o.c, &req) 110 if err != nil { 111 return err 112 } 113 114 return nil 115 } 116 117 // RemovePortGroup wraps methods.RemovePortGroup 118 func (o HostNetworkSystem) RemovePortGroup(ctx context.Context, pgName string) error { 119 req := types.RemovePortGroup{ 120 This: o.Reference(), 121 PgName: pgName, 122 } 123 124 _, err := methods.RemovePortGroup(ctx, o.c, &req) 125 if err != nil { 126 return err 127 } 128 129 return nil 130 } 131 132 // RemoveServiceConsoleVirtualNic wraps methods.RemoveServiceConsoleVirtualNic 133 func (o HostNetworkSystem) RemoveServiceConsoleVirtualNic(ctx context.Context, device string) error { 134 req := types.RemoveServiceConsoleVirtualNic{ 135 This: o.Reference(), 136 Device: device, 137 } 138 139 _, err := methods.RemoveServiceConsoleVirtualNic(ctx, o.c, &req) 140 if err != nil { 141 return err 142 } 143 144 return nil 145 } 146 147 // RemoveVirtualNic wraps methods.RemoveVirtualNic 148 func (o HostNetworkSystem) RemoveVirtualNic(ctx context.Context, device string) error { 149 req := types.RemoveVirtualNic{ 150 This: o.Reference(), 151 Device: device, 152 } 153 154 _, err := methods.RemoveVirtualNic(ctx, o.c, &req) 155 if err != nil { 156 return err 157 } 158 159 return nil 160 } 161 162 // RemoveVirtualSwitch wraps methods.RemoveVirtualSwitch 163 func (o HostNetworkSystem) RemoveVirtualSwitch(ctx context.Context, vswitchName string) error { 164 req := types.RemoveVirtualSwitch{ 165 This: o.Reference(), 166 VswitchName: vswitchName, 167 } 168 169 _, err := methods.RemoveVirtualSwitch(ctx, o.c, &req) 170 if err != nil { 171 return err 172 } 173 174 return nil 175 } 176 177 // RestartServiceConsoleVirtualNic wraps methods.RestartServiceConsoleVirtualNic 178 func (o HostNetworkSystem) RestartServiceConsoleVirtualNic(ctx context.Context, device string) error { 179 req := types.RestartServiceConsoleVirtualNic{ 180 This: o.Reference(), 181 Device: device, 182 } 183 184 _, err := methods.RestartServiceConsoleVirtualNic(ctx, o.c, &req) 185 if err != nil { 186 return err 187 } 188 189 return nil 190 } 191 192 // UpdateConsoleIpRouteConfig wraps methods.UpdateConsoleIpRouteConfig 193 func (o HostNetworkSystem) UpdateConsoleIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error { 194 req := types.UpdateConsoleIpRouteConfig{ 195 This: o.Reference(), 196 Config: config, 197 } 198 199 _, err := methods.UpdateConsoleIpRouteConfig(ctx, o.c, &req) 200 if err != nil { 201 return err 202 } 203 204 return nil 205 } 206 207 // UpdateDnsConfig wraps methods.UpdateDnsConfig 208 func (o HostNetworkSystem) UpdateDnsConfig(ctx context.Context, config types.BaseHostDnsConfig) error { 209 req := types.UpdateDnsConfig{ 210 This: o.Reference(), 211 Config: config, 212 } 213 214 _, err := methods.UpdateDnsConfig(ctx, o.c, &req) 215 if err != nil { 216 return err 217 } 218 219 return nil 220 } 221 222 // UpdateIpRouteConfig wraps methods.UpdateIpRouteConfig 223 func (o HostNetworkSystem) UpdateIpRouteConfig(ctx context.Context, config types.BaseHostIpRouteConfig) error { 224 req := types.UpdateIpRouteConfig{ 225 This: o.Reference(), 226 Config: config, 227 } 228 229 _, err := methods.UpdateIpRouteConfig(ctx, o.c, &req) 230 if err != nil { 231 return err 232 } 233 234 return nil 235 } 236 237 // UpdateIpRouteTableConfig wraps methods.UpdateIpRouteTableConfig 238 func (o HostNetworkSystem) UpdateIpRouteTableConfig(ctx context.Context, config types.HostIpRouteTableConfig) error { 239 req := types.UpdateIpRouteTableConfig{ 240 This: o.Reference(), 241 Config: config, 242 } 243 244 _, err := methods.UpdateIpRouteTableConfig(ctx, o.c, &req) 245 if err != nil { 246 return err 247 } 248 249 return nil 250 } 251 252 // UpdateNetworkConfig wraps methods.UpdateNetworkConfig 253 func (o HostNetworkSystem) UpdateNetworkConfig(ctx context.Context, config types.HostNetworkConfig, changeMode string) (*types.HostNetworkConfigResult, error) { 254 req := types.UpdateNetworkConfig{ 255 This: o.Reference(), 256 Config: config, 257 ChangeMode: changeMode, 258 } 259 260 res, err := methods.UpdateNetworkConfig(ctx, o.c, &req) 261 if err != nil { 262 return nil, err 263 } 264 265 return &res.Returnval, nil 266 } 267 268 // UpdatePhysicalNicLinkSpeed wraps methods.UpdatePhysicalNicLinkSpeed 269 func (o HostNetworkSystem) UpdatePhysicalNicLinkSpeed(ctx context.Context, device string, linkSpeed *types.PhysicalNicLinkInfo) error { 270 req := types.UpdatePhysicalNicLinkSpeed{ 271 This: o.Reference(), 272 Device: device, 273 LinkSpeed: linkSpeed, 274 } 275 276 _, err := methods.UpdatePhysicalNicLinkSpeed(ctx, o.c, &req) 277 if err != nil { 278 return err 279 } 280 281 return nil 282 } 283 284 // UpdatePortGroup wraps methods.UpdatePortGroup 285 func (o HostNetworkSystem) UpdatePortGroup(ctx context.Context, pgName string, portgrp types.HostPortGroupSpec) error { 286 req := types.UpdatePortGroup{ 287 This: o.Reference(), 288 PgName: pgName, 289 Portgrp: portgrp, 290 } 291 292 _, err := methods.UpdatePortGroup(ctx, o.c, &req) 293 if err != nil { 294 return err 295 } 296 297 return nil 298 } 299 300 // UpdateServiceConsoleVirtualNic wraps methods.UpdateServiceConsoleVirtualNic 301 func (o HostNetworkSystem) UpdateServiceConsoleVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error { 302 req := types.UpdateServiceConsoleVirtualNic{ 303 This: o.Reference(), 304 Device: device, 305 Nic: nic, 306 } 307 308 _, err := methods.UpdateServiceConsoleVirtualNic(ctx, o.c, &req) 309 if err != nil { 310 return err 311 } 312 313 return nil 314 } 315 316 // UpdateVirtualNic wraps methods.UpdateVirtualNic 317 func (o HostNetworkSystem) UpdateVirtualNic(ctx context.Context, device string, nic types.HostVirtualNicSpec) error { 318 req := types.UpdateVirtualNic{ 319 This: o.Reference(), 320 Device: device, 321 Nic: nic, 322 } 323 324 _, err := methods.UpdateVirtualNic(ctx, o.c, &req) 325 if err != nil { 326 return err 327 } 328 329 return nil 330 } 331 332 // UpdateVirtualSwitch wraps methods.UpdateVirtualSwitch 333 func (o HostNetworkSystem) UpdateVirtualSwitch(ctx context.Context, vswitchName string, spec types.HostVirtualSwitchSpec) error { 334 req := types.UpdateVirtualSwitch{ 335 This: o.Reference(), 336 VswitchName: vswitchName, 337 Spec: spec, 338 } 339 340 _, err := methods.UpdateVirtualSwitch(ctx, o.c, &req) 341 if err != nil { 342 return err 343 } 344 345 return nil 346 }