service

package
v0.0.0-...-0a82276 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Provider

type Provider interface {
	environs.Networking
}

Provider is the interface that the network service requires to be able to interact with the underlying provider.

type ProviderService

type ProviderService struct {
	Service
	// contains filtered or unexported fields
}

ProviderService provides the API for working with network spaces.

func NewProviderService

func NewProviderService(
	st State,
	provider providertracker.ProviderGetter[Provider],
	logger logger.Logger,
) *ProviderService

NewProviderService returns a new service reference wrapping the input state.

func (*ProviderService) ReloadSpaces

func (s *ProviderService) ReloadSpaces(ctx context.Context) error

ReloadSpaces loads spaces and subnets from the provider into state.

func (*ProviderService) SupportsSpaceDiscovery

func (s *ProviderService) SupportsSpaceDiscovery(ctx context.Context) (bool, error)

SupportsSpaceDiscovery returns whether the provider supports discovering spaces from the provider.

func (*ProviderService) SupportsSpaces

func (s *ProviderService) SupportsSpaces(ctx context.Context) (bool, error)

SupportsSpaces returns whether the provider supports spaces.

type ProviderSpaces

type ProviderSpaces struct {
	// contains filtered or unexported fields
}

ProviderSpaces defines a set of operations to perform when dealing with provider spaces. SaveSpaces, DeleteSpaces are operations for setting state in the persistence layer.

func NewProviderSpaces

func NewProviderSpaces(spaceService *ProviderService, logger logger.Logger) *ProviderSpaces

NewProviderSpaces creates a new ProviderSpaces to perform a series of operations.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service provides the API for working with spaces.

func NewService

func NewService(st State, logger logger.Logger) *Service

NewService returns a new service reference wrapping the input state.

func (*Service) AddSpace

func (s *Service) AddSpace(ctx context.Context, space network.SpaceInfo) (network.Id, error)

AddSpace creates and returns a new space.

func (*Service) AddSubnet

func (s *Service) AddSubnet(ctx context.Context, args network.SubnetInfo) (network.Id, error)

AddSubnet creates and returns a new subnet.

func (*Service) GetAllSpaces

func (s *Service) GetAllSpaces(ctx context.Context) (network.SpaceInfos, error)

GetAllSpaces returns all spaces for the model.

func (*Service) GetAllSubnets

func (s *Service) GetAllSubnets(ctx context.Context) (network.SubnetInfos, error)

GetAllSubnets returns all the subnets for the model.

func (*Service) RemoveSpace

func (s *Service) RemoveSpace(ctx context.Context, uuid string) error

RemoveSpace deletes a space identified by its uuid. If the space is not found, an error is returned matching github.com/juju/juju/domain/network/errors.SpaceNotFound.

func (*Service) RemoveSubnet

func (s *Service) RemoveSubnet(ctx context.Context, uuid string) error

Remove deletes a subnet identified by its uuid.

func (*Service) Space

func (s *Service) Space(ctx context.Context, uuid string) (*network.SpaceInfo, error)

Space returns a space from state that matches the input ID. If the space is not found, an error is returned matching github.com/juju/juju/domain/network/errors.SpaceNotFound.

func (*Service) SpaceByName

func (s *Service) SpaceByName(ctx context.Context, name string) (*network.SpaceInfo, error)

SpaceByName returns a space from state that matches the input name. If the space is not found, an error is returned matching github.com/juju/juju/domain/network/errors.SpaceNotFound.

func (*Service) Subnet

func (s *Service) Subnet(ctx context.Context, uuid string) (*network.SubnetInfo, error)

Subnet returns the subnet identified by the input UUID, or an error if it is not found.

func (*Service) SubnetsByCIDR

func (s *Service) SubnetsByCIDR(ctx context.Context, cidrs ...string) ([]network.SubnetInfo, error)

SubnetsByCIDR returns the subnets matching the input CIDRs.

func (*Service) UpdateSpace

func (s *Service) UpdateSpace(ctx context.Context, uuid string, name string) error

UpdateSpace updates the space name identified by the passed uuid. If the space is not found, an error is returned matching github.com/juju/juju/domain/network/errors.SpaceNotFound.

func (*Service) UpdateSubnet

func (s *Service) UpdateSubnet(ctx context.Context, uuid, spaceUUID string) error

UpdateSubnet updates the spaceUUID of the subnet identified by the input UUID.

type SpaceState

type SpaceState interface {
	// AddSpace creates a space.
	AddSpace(ctx context.Context, uuid string, name string, providerID network.Id, subnetIDs []string) error
	// GetSpace returns the space by UUID. If the space is not found, an error
	// is returned matching
	// [github.com/juju/juju/domain/network/errors.SpaceNotFound].
	GetSpace(ctx context.Context, uuid string) (*network.SpaceInfo, error)
	// GetSpaceByName returns the space by name. If the space is not found, an
	// error is returned matching
	// [github.com/juju/juju/domain/network/errors.SpaceNotFound].
	GetSpaceByName(ctx context.Context, name string) (*network.SpaceInfo, error)
	// GetAllSpaces returns all spaces for the model.
	GetAllSpaces(ctx context.Context) (network.SpaceInfos, error)
	// UpdateSpace updates the space identified by the passed uuid. If the
	// space is not found, an error is returned matching
	// [github.com/juju/juju/domain/network/errors.SpaceNotFound].
	UpdateSpace(ctx context.Context, uuid string, name string) error
	// DeleteSpace deletes the space identified by the passed uuid. If the
	// space is not found, an error is returned matching
	// [github.com/juju/juju/domain/network/errors.SpaceNotFound].
	DeleteSpace(ctx context.Context, uuid string) error
}

SpaceState describes persistence layer methods for the space (sub-) domain.

type State

type State interface {
	SpaceState
	SubnetState
}

State describes retrieval and persistence methods needed for the network domain service.

type SubnetState

type SubnetState interface {
	// AddSubnet creates a subnet.
	AddSubnet(ctx context.Context, subnet network.SubnetInfo) error
	// GetAllSubnets returns all known subnets in the model.
	GetAllSubnets(ctx context.Context) (network.SubnetInfos, error)
	// GetSubnet returns the subnet by UUID.
	GetSubnet(ctx context.Context, uuid string) (*network.SubnetInfo, error)
	// GetSubnetsByCIDR returns the subnets by CIDR.
	// Deprecated, this method should be removed when we re-work the API
	// for moving subnets.
	GetSubnetsByCIDR(ctx context.Context, cidrs ...string) (network.SubnetInfos, error)
	// UpdateSubnet updates the subnet identified by the passed uuid.
	UpdateSubnet(ctx context.Context, uuid string, spaceID string) error
	// DeleteSubnet deletes the subnet identified by the passed uuid.
	DeleteSubnet(ctx context.Context, uuid string) error
	// UpsertSubnets updates or adds each one of the provided subnets in one
	// transaction.
	UpsertSubnets(ctx context.Context, subnets []network.SubnetInfo) error
	// AllSubnetsQuery returns the SQL query that finds all subnet UUIDs from the
	// subnet table, needed for the subnets watcher.
	AllSubnetsQuery(ctx context.Context, db database.TxnRunner) ([]string, error)
}

SubnetState describes persistence layer methods for the subnet (sub-) domain.

type WatchableService

type WatchableService struct {
	ProviderService
	// contains filtered or unexported fields
}

WatchableService provides the API for working with external controllers and the ability to create watchers.

func NewWatchableService

func NewWatchableService(st State, provider providertracker.ProviderGetter[Provider], watcherFactory WatcherFactory, logger logger.Logger) *WatchableService

NewWatchableService returns a new watchable service reference wrapping the input state and provider.

func (*WatchableService) WatchSubnets

func (s *WatchableService) WatchSubnets(ctx context.Context, subnetUUIDsToWatch set.Strings) (watcher.StringsWatcher, error)

Watch returns a watcher that observes changes to subnets and their association (fan underlays), filtered based on the provided list of subnets to watch.

type WatcherFactory

type WatcherFactory interface {
	// NewNamespaceMapperWatcher returns a new namespace watcher
	// for events based on the input change mask and mapper.
	NewNamespaceMapperWatcher(namespace string, changeMask changestream.ChangeType, initialStateQuery eventsource.NamespaceQuery, mapper eventsource.Mapper) (watcher.StringsWatcher, error)
}

WatcherFactory describes methods for creating watchers.

Jump to

Keyboard shortcuts

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