ports

package
v0.0.0-...-63319d1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MPL-2.0, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(c *golangsdk.ServiceClient, portID string) *golangsdk.ErrResult

Delete is a method to remove an existing network port by ID.

func List

func List(c *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager

List returns a Pager which allows you to iterate over a collection of ports. It accepts a ListOpts struct, which allows you to filter the returned collection for greater efficiency.

Types

type AddressPair

type AddressPair struct {
	// Specifies the IP address.
	// The IP address cannot be 0.0.0.0/0.
	// Configure an independent security group for the port if a large CIDR block (subnet mask less than 24) is
	// configured for parameter AllowedAddressPairs.
	IpAddress string `json:"ip_address" required:"true"`
	// Specifies the MAC address.
	MacAddress string `json:"mac_address,omitempty"`
}

AddressPair is an Object specifying the IP/Mac addresses pair.

type CreateOpts

type CreateOpts struct {
	// Specifies the ID of the network to which the port belongs.
	NetworkId string `json:"network_id" required:"true"`
	// Specifies the port name. The value can contain no more than 255 characters.
	// This parameter is left blank by default.
	Name string `json:"name,omitempty"`
	// Specifies the administrative state of the port.
	// The value can only be true, and the default value is true.
	AdminStateUp bool `json:"admin_state_up,omitempty"`
	// Specifies the device to which the port belongs.
	// Currently, only ” and neutron:VIP_PORT are supported.
	// 'neutron:VIP_PORT' indicates the port of a virtual IP address.
	DeviceOwner string `json:"device_owner,omitempty"`
	// Specifies the port IP address.
	// A port supports only one fixed IP address that cannot be changed.
	FixedIps []FixedIp `json:"fixed_ips,omitempty"`
	// Specifies the UUID of the security group.
	SecurityGroups []string `json:"security_groups,omitempty"`
	// Specifies a set of zero or more allowed address pairs.
	AllowedAddressPairs []AddressPair `json:"allowed_address_pairs,omitempty"`
	// Specifies the extended option (extended attribute) of DHCP.
	ExtraDhcpOpts []ExtraDhcpOpt `json:"extra_dhcp_opts,omitempty"`
}

CreateOpts is the structure required by the Create method to build a new network port.

type DnsAssignment

type DnsAssignment struct {
	// Specifies the hostname.
	Hostname string `json:"hostname"`
	// Specifies the IP address of the port.
	IpAddress string `json:"ip_address"`
	// Specifies the FQDN.
	Fqdn string `json:"fqdn"`
}

DnsAssignment is an Object specifying the private network domain information.

type ExtraDhcpOpt

type ExtraDhcpOpt struct {
	// Specifies the DHCP option name.
	// Currently, only '51' is supported to indicate the DHCP lease time.
	OptName string `json:"opt_name,omitempty"`
	// Specifies the DHCP option value.
	// When 'OptName' is '51', the parameter format is 'Xh', indicating that the DHCP lease time is X hours.
	// The value range of 'X' is '1~30000' or '-1', '-1' means the DHCP lease time is infinite.
	OptValue string `json:"opt_value,omitempty"`
}

ExtraDhcpOpt is an Object specifying the DHCP extended properties.

type FixedIp

type FixedIp struct {
	// Specifies the subnet ID.
	// You cannot change the parameter value.
	SubnetId string `json:"subnet_id,omitempty"`
	// Specifies the port IP address.
	// You cannot change the parameter value.
	IpAddress string `json:"ip_address,omitempty"`
}

FixedIp is an Object specifying the IP information of the port.

type ListOpts

type ListOpts struct {
	ID                  string `q:"id"`
	Name                string `q:"name"`
	NetworkID           string `q:"network_id"`
	MACAddress          string `q:"mac_address"`
	AdminStateUp        *bool  `q:"admin_state_up"`
	DeviceID            string `q:"device_id"`
	DeviceOwner         string `q:"device_owner"`
	Status              string `q:"status"`
	Marker              string `q:"marker"`
	Limit               int    `q:"limit"`
	EnterpriseProjectID string `q:"enterprise_project_id"`
	// fixed_ips=ip_address={ip_address}&fixed_ips=subnet_id={subnet_id}
	FixedIps []string `q:"fixed_ips"`
}

ListOpts allows the filtering of paginated collections through the API. Filtering is achieved by passing in struct field values that map to the port attributes you want to see returned. Marker and Limit are used for pagination.

func (ListOpts) ToPortListQuery

func (opts ListOpts) ToPortListQuery() (string, error)

ToPortListQuery formats a ListOpts into a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToPortListQuery() (string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type Port

type Port struct {
	// Specifies the administrative state of the port.
	// The value can only be true, and the default value is true.
	AdminStateUp bool `json:"admin_state_up"`
	// Specifies the time when the network VIP was created.
	CreatedAt string `json:"created_at"`
	// Specifies the port ID, which uniquely identifies the port.
	ID string `json:"id"`
	// Specifies the port name.
	// The value can contain no more than 255 characters. This parameter is left blank by default.
	Name string `json:"name"`
	// Specifies the ID of the network to which the port belongs.
	// The network ID must be a real one in the network environment.
	NetworkId string `json:"network_id"`
	// Specifies the port MAC address.
	// The system automatically sets this parameter, and you are not allowed to configure the parameter value.
	MacAddress string `json:"mac_address"`
	// Specifies the port IP address.
	// A port supports only one fixed IP address that cannot be changed.
	FixedIps []FixedIp `json:"fixed_ips"`
	// Specifies the ID of the device to which the port belongs.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	DeviceId string `json:"device_id"`
	// Specifies the belonged device, which can be the DHCP server, router, load balancer, or Nova.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	DeviceOwner string `json:"device_owner"`
	// Specifies the project ID.
	TenantId string `json:"tenant_id"`
	// Specifies the port status. The status of a HANA SR-IOV VM port is always DOWN.
	// The value can be ACTIVE, BUILD, or DOWN.
	Status string `json:"status"`
	// Specifies the security group UUID (extended attribute).
	SecurityGroups []string `json:"security_groups"`
	// Specifies a set of zero or more allowed address pairs. An address pair consists of an IP address and MAC address.
	// The IP address cannot be 0.0.0.0/0.
	// Configure an independent security group for the port if a large CIDR block (subnet mask less than 24) is
	// configured for parameter AllowedAddressPairs.
	AllowedAddressPairs []AddressPair `json:"allowed_address_pairs"`
	// Specifies the extended option (extended attribute) of DHCP.
	ExtraDhcpOpts []ExtraDhcpOpt `json:"extra_dhcp_opts"`
	// Specifies the VIF details. Parameter ovs_hybrid_plug specifies whether the OVS/bridge hybrid mode is used.
	VifDetails VifDetail `json:"binding:vif_details"`
	// Specifies the custom information configured by users. This is an extended attribute.
	Profile interface{} `json:"binding:profile"`
	// Specifies the type of the bound vNIC. The value can be normal or direct.
	// Parameter normal indicates software switching.
	// Parameter direct indicates SR-IOV PCIe passthrough, which is not supported.
	VnicType string `json:"binding:vnic_type"`
	// Specifies the default private network domain name information of the primary NIC.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	DnsAssignment []DnsAssignment `json:"dns_assignment"`
	// Specifies the default private network DNS name of the primary NIC.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	DnsName string `json:"dns_name"`
	// Specifies the ID of the instance to which the port belongs, for example, RDS instance ID.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	InstanceId string `json:"instance_id"`
	// Specifies the type of the instance to which the port belongs, for example, RDS.
	// The system automatically sets this parameter, and you are not allowed to configure or change the parameter value.
	InstanceType string `json:"instance_type"`
	// Specifies whether the security option is enabled for the port.
	// If the option is not enabled, the security group and DHCP snooping do not take effect.
	PortSecurityEnabled bool `json:"port_security_enabled"`
	// Availability zone to which the port belongs.
	ZoneId string `json:"zone_id"`
}

Port is an API response structure of the network VIP.

func Create

func Create(c *golangsdk.ServiceClient, opts CreateOpts) (*Port, error)

Create is a method to build a new network port.

func ExtractPorts

func ExtractPorts(r pagination.Page) ([]Port, error)

ExtractPorts accepts a Page struct, specifically a PortPage struct, and extracts the elements into a slice of Port structs. In other words, a generic collection is mapped into a relevant slice.

func Get

func Get(c *golangsdk.ServiceClient, portID string) (*Port, error)

Get is a method to obtain the network port details.

func Update

func Update(c *golangsdk.ServiceClient, portID string, opts UpdateOpts) (*Port, error)

Update is a method to update the existing network port.

type PortPage

type PortPage struct {
	pagination.MarkerPageBase
}

PortPage is the page returned by a pager when traversing over a collection of network ports.

func (PortPage) IsEmpty

func (p PortPage) IsEmpty() (bool, error)

IsEmpty method checks whether a PortPage struct is empty.

func (PortPage) LastMarker

func (p PortPage) LastMarker() (string, error)

LastMarker method returns the last ID in a ports page.

type UpdateOpts

type UpdateOpts struct {
	// Specifies the ID of the network to which the port belongs.
	Name string `json:"name"`
	// Specifies the UUID of the security group.
	SecurityGroups []string `json:"security_groups"`
	// Specifies a set of zero or more allowed address pairs.
	AllowedAddressPairs []AddressPair `json:"allowed_address_pairs"`
	// Specifies the extended option (extended attribute) of DHCP.
	ExtraDhcpOpts []ExtraDhcpOpt `json:"extra_dhcp_opts"`
}

UpdateOpts is the structure required by the Update method to update the configuration of the specified network port.

type VifDetail

type VifDetail struct {
	// If the value is true, indicating that it is the main network card of the virtual machine.
	PrimaryInterface bool `json:"primary_interface"`
}

VifDetail is an Object specifying the VIF details.

Jump to

Keyboard shortcuts

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