state

package
v0.0.0-...-b9bb202 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AvailabilityZone

type AvailabilityZone struct {
	// Name is the name of the availability zone.
	Name string `db:"name"`
	// UUID is the unique ID of the availability zone.
	UUID string `db:"uuid"`
}

AvailabilityZone represents a row from the availability_zone table.

type AvailabilityZoneSubnet

type AvailabilityZoneSubnet struct {
	// UUID is the unique ID of the availability zone.
	AZUUID string `db:"availability_zone_uuid"`
	// SubnetUUID is the unique ID of the Subnet.
	SubnetUUID string `db:"subnet_uuid"`
}

AvailabilityZoneSubnet represents a row from the availability_zone_subnet table.

type ProviderNetwork

type ProviderNetwork struct {
	// ProviderNetworkUUID is the provider network UUID.
	ProviderNetworkUUID string `db:"uuid"`
	// ProviderNetworkID is the provider-specific ID of the network
	// containing this subnet.
	ProviderNetworkID network.Id `db:"provider_network_id"`
}

ProviderNetwork represents a single row from the provider_network table.

type ProviderNetworkSubnet

type ProviderNetworkSubnet struct {
	// SubnetUUID is the UUID of the subnet.
	SubnetUUID string `db:"subnet_uuid"`
	// ProviderNetworkUUID is the provider network UUID.
	ProviderNetworkUUID string `db:"provider_network_uuid"`
}

ProviderNetworkSubnet represents a single row from the provider_network_subnet mapping table.

type ProviderSpace

type ProviderSpace struct {
	// SpaceUUID is the unique ID of the space.
	SpaceUUID string `db:"space_uuid"`
	// ProviderID is a provider-specific space ID.
	ProviderID network.Id `db:"provider_id"`
}

ProviderSpace represents a single row from the provider_space table.

type ProviderSubnet

type ProviderSubnet struct {
	// SubnetUUID is the UUID of the subnet.
	SubnetUUID string `db:"subnet_uuid"`
	// ProviderID is the provider-specific subnet ID.
	ProviderID network.Id `db:"provider_id"`
}

ProviderSubnet represents a single row from the provider_subnet table.

type Space

type Space struct {
	// Name is the space name.
	Name string `db:"name"`
	// UUID is the unique ID of the space.
	UUID string `db:"uuid"`
}

Space represents a single row from the space table.

type SpaceSubnetRow

type SpaceSubnetRow struct {
	// SubnetRow is embedded by SpaceSubnetRow since every row corresponds to a
	// subnet of the space. This allows SubnetRow to be
	SubnetRow

	// UUID is the space UUID.
	SpaceUUID string `db:"uuid"`

	// Name is the space name.
	SpaceName string `db:"name"`

	// ProviderID is the space provider id.
	SpaceProviderID sql.NullString `db:"provider_id"`
}

SpaceSubnetRow represents a single row from the v_space_subnets view.

type SpaceSubnetRows

type SpaceSubnetRows []SpaceSubnetRow

SpaceSubnetRows is a slice of SpaceSubnet rows.

func (SpaceSubnetRows) ToSpaceInfos

func (sp SpaceSubnetRows) ToSpaceInfos() network.SpaceInfos

ToSpaceInfos converts Spaces to a slice of network.SpaceInfo structs. This method makes sure only unique subnets are mapped and flattens them into each space. No sorting is applied.

type State

type State struct {
	*domain.StateBase
	// contains filtered or unexported fields
}

State represents a type for interacting with the underlying state.

func NewState

func NewState(factory coreDB.TxnRunnerFactory, logger logger.Logger) *State

NewState returns a new State for interacting with the underlying state.

func (*State) AddSpace

func (st *State) AddSpace(
	ctx context.Context,
	uuid string,
	name string,
	providerID network.Id,
	subnetIDs []string,
) error

AddSpace creates and returns a new space.

func (*State) AddSubnet

func (st *State) AddSubnet(
	ctx context.Context,
	subnet network.SubnetInfo,
) error

AddSubnet creates a subnet.

func (*State) AllSubnetsQuery

func (st *State) AllSubnetsQuery(ctx context.Context, db database.TxnRunner) ([]string, error)

AllSubnetsQuery returns the SQL query that finds all subnet UUIDs from the subnet table, needed for the subnets' watcher.

func (*State) DeleteSpace

func (st *State) DeleteSpace(
	ctx context.Context,
	uuid string,
) error

DeleteSpace deletes the space identified by the passed uuid. If the space is not found, an error is returned matching networkerrors.SpaceNotFound.

func (*State) DeleteSubnet

func (st *State) DeleteSubnet(
	ctx context.Context,
	uuid string,
) error

DeleteSubnet deletes the subnet identified by the passed uuid.

func (*State) GetAllSpaces

func (st *State) GetAllSpaces(
	ctx context.Context,
) (network.SpaceInfos, error)

GetAllSpaces returns all spaces for the model.

func (*State) GetAllSubnets

func (st *State) GetAllSubnets(
	ctx context.Context,
) (network.SubnetInfos, error)

GetAllSubnets returns all known subnets in the model.

func (*State) GetSpace

func (st *State) GetSpace(
	ctx context.Context,
	uuid string,
) (*network.SpaceInfo, error)

GetSpace returns the space by UUID. If the space is not found, an error is returned matching networkerrors.SpaceNotFound.

func (*State) GetSpaceByName

func (st *State) GetSpaceByName(
	ctx context.Context,
	name string,
) (*network.SpaceInfo, error)

GetSpaceByName returns the space by name. If the space is not found, an error is returned matching networkerrors.SpaceNotFound.

func (*State) GetSubnet

func (st *State) GetSubnet(
	ctx context.Context,
	uuid string,
) (*network.SubnetInfo, error)

GetSubnet returns the subnet by UUID.

func (*State) GetSubnetsByCIDR

func (st *State) GetSubnetsByCIDR(
	ctx context.Context,
	cidrs ...string,
) (network.SubnetInfos, error)

GetSubnetsByCIDR returns the subnets by CIDR. Deprecated, this method should be removed when we re-work the API for moving subnets.

func (*State) UpdateSpace

func (st *State) UpdateSpace(
	ctx context.Context,
	uuid string,
	name string,
) error

UpdateSpace updates the space identified by the passed uuid. If the space is not found, an error is returned matching networkerrors.SpaceNotFound.

func (*State) UpdateSubnet

func (st *State) UpdateSubnet(
	ctx context.Context,
	uuid string,
	spaceID string,
) error

UpdateSubnet updates the subnet identified by the passed uuid.

func (*State) UpsertSubnets

func (st *State) UpsertSubnets(ctx context.Context, subnets []network.SubnetInfo) error

UpsertSubnets updates or adds each one of the provided subnets in one transaction.

type Subnet

type Subnet struct {
	// UUID is the subnet's UUID.
	UUID string `db:"uuid"`
	// CIDR of the network, in 123.45.67.89/24 format.
	CIDR string `db:"cidr"`
	// VLANtag is the subnet's vlan tag.
	VLANtag int `db:"vlan_tag"`
	// SpaceUUID is the space UUID.
	SpaceUUID string `db:"space_uuid"`
}

Subnet represents a single row from the subnet table.

type SubnetRow

type SubnetRow struct {
	// UUID is the subnet UUID.
	UUID string `db:"subnet_uuid"`

	// CIDR is the one of the subnet's cidr.
	CIDR string `db:"subnet_cidr"`

	// VLANTag is the subnet's vlan tag.
	VLANTag int `db:"subnet_vlan_tag"`

	// ProviderID is the subnet's provider id.
	ProviderID string `db:"subnet_provider_id"`

	// ProviderNetworkID is the subnet's provider network id.
	ProviderNetworkID string `db:"subnet_provider_network_id"`

	// ProviderSpaceUUID is the subnet's space uuid.
	ProviderSpaceUUID sql.NullString `db:"subnet_provider_space_uuid"`

	// SpaceUUID is the space uuid.
	SpaceUUID sql.NullString `db:"subnet_space_uuid"`

	// SpaceName is the name of the space the subnet is associated with.
	SpaceName sql.NullString `db:"subnet_space_name"`

	// AZ is the availability zones on the subnet.
	AZ string `db:"subnet_az"`
}

SubnetRow represents the subnet fields of a single row from the v_space_subnets view.

func (SubnetRow) ToSubnetInfo

func (s SubnetRow) ToSubnetInfo() *network.SubnetInfo

ToSubnetInfo deserializes a row containing subnet fields to a SubnetInfo struct.

type SubnetRows

type SubnetRows []SubnetRow

SubnetRows is a slice of Subnet rows.

func (SubnetRows) ToSubnetInfos

func (sn SubnetRows) ToSubnetInfos() network.SubnetInfos

ToSubnetInfos converts Subnets to a slice of network.SubnetInfo structs. This method makes sure only unique AZs are mapped and flattens them into each subnet. No sorting is applied.

Jump to

Keyboard shortcuts

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