extradhcpopts

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package extradhcpopts allow to work with extra DHCP functionality of Neutron ports.

Example to Get a Port with Extra DHCP Options

portID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2"
var s struct {
	ports.Port
	extradhcpopts.ExtraDHCPOptsExt
}

err := ports.Get(networkClient, portID).ExtractInto(&s)
if err != nil {
	panic(err)
}

Example to Create a Port with Extra DHCP Options

var s struct {
	ports.Port
	extradhcpopts.ExtraDHCPOptsExt
}

adminStateUp := true
portCreateOpts := ports.CreateOpts{
	Name:         "dhcp-conf-port",
	AdminStateUp: &adminStateUp,
	NetworkID:    "a87cc70a-3e15-4acf-8205-9b711a3531b7",
	FixedIPs: []ports.IP{
		{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.2"},
	},
}

createOpts := extradhcpopts.CreateOptsExt{
	CreateOptsBuilder: portCreateOpts,
	ExtraDHCPOpts: []extradhcpopts.CreateExtraDHCPOpt{
		{
			OptName:  "optionA",
			OptValue: "valueA",
		},
	},
}

err := ports.Create(networkClient, createOpts).ExtractInto(&s)
if err != nil {
	panic(err)
}

Example to Update a Port with Extra DHCP Options

var s struct {
	ports.Port
	extradhcpopts.ExtraDHCPOptsExt
}

portUpdateOpts := ports.UpdateOpts{
	Name: "updated-dhcp-conf-port",
	FixedIPs: []ports.IP{
		{SubnetID: "a0304c3a-4f08-4c43-88af-d796509c97d2", IPAddress: "10.0.0.3"},
	},
}

value := "valueB"
updateOpts := extradhcpopts.UpdateOptsExt{
	UpdateOptsBuilder: portUpdateOpts,
	ExtraDHCPOpts: []extradhcpopts.UpdateExtraDHCPOpt{
		{
			OptName:  "optionB",
			OptValue: &value,
		},
	},
}

portID := "46d4bfb9-b26e-41f3-bd2e-e6dcc1ccedb2"
err := ports.Update(networkClient, portID, updateOpts).ExtractInto(&s)
if err != nil {
	panic(err)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateExtraDHCPOpt

type CreateExtraDHCPOpt struct {
	// OptName is the name of a DHCP option.
	OptName string `json:"opt_name" required:"true"`

	// OptValue is the value of the DHCP option.
	OptValue string `json:"opt_value" required:"true"`

	// IPVersion is the IP protocol version of a DHCP option.
	IPVersion gophercloud.IPVersion `json:"ip_version,omitempty"`
}

CreateExtraDHCPOpt represents the options required to create an extra DHCP option on a port.

type CreateOptsExt

type CreateOptsExt struct {
	// CreateOptsBuilder is the interface options structs have to satisfy in order
	// to be used in the main Create operation in this package.
	ports.CreateOptsBuilder

	// ExtraDHCPOpts field is a set of DHCP options for a single port.
	ExtraDHCPOpts []CreateExtraDHCPOpt `json:"extra_dhcp_opts,omitempty"`
}

CreateOptsExt adds extra DHCP options to the base ports.CreateOpts.

func (CreateOptsExt) ToPortCreateMap

func (opts CreateOptsExt) ToPortCreateMap() (map[string]interface{}, error)

ToPortCreateMap casts a CreateOptsExt struct to a map.

type ExtraDHCPOpt

type ExtraDHCPOpt struct {
	// OptName is the name of a single DHCP option.
	OptName string `json:"opt_name"`

	// OptValue is the value of a single DHCP option.
	OptValue string `json:"opt_value"`

	// IPVersion is the IP protocol version of a single DHCP option.
	// Valid value is 4 or 6. Default is 4.
	IPVersion int `json:"ip_version"`
}

ExtraDHCPOpt represents a single set of extra DHCP options for a single port.

type ExtraDHCPOptsExt

type ExtraDHCPOptsExt struct {
	ExtraDHCPOpts []ExtraDHCPOpt `json:"extra_dhcp_opts"`
}

ExtraDHCPOptsExt is a struct that contains different DHCP options for a single port.

type UpdateExtraDHCPOpt

type UpdateExtraDHCPOpt struct {
	// OptName is the name of a DHCP option.
	OptName string `json:"opt_name" required:"true"`

	// OptValue is the value of the DHCP option.
	OptValue *string `json:"opt_value"`

	// IPVersion is the IP protocol version of a DHCP option.
	IPVersion gophercloud.IPVersion `json:"ip_version,omitempty"`
}

UpdateExtraDHCPOpt represents the options required to update an extra DHCP option on a port.

type UpdateOptsExt

type UpdateOptsExt struct {
	// UpdateOptsBuilder is the interface options structs have to satisfy in order
	// to be used in the main Update operation in this package.
	ports.UpdateOptsBuilder

	// ExtraDHCPOpts field is a set of DHCP options for a single port.
	ExtraDHCPOpts []UpdateExtraDHCPOpt `json:"extra_dhcp_opts,omitempty"`
}

UpdateOptsExt adds extra DHCP options to the base ports.UpdateOpts.

func (UpdateOptsExt) ToPortUpdateMap

func (opts UpdateOptsExt) ToPortUpdateMap() (map[string]interface{}, error)

ToPortUpdateMap casts an UpdateOpts struct to a map.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL