space

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ReloadCommandDoc = `
Reloades spaces and subnets from substrate
`
View Source
const ShowSpaceCommandDoc = `` /* 312-byte string literal not displayed */

Variables

This section is empty.

Functions

func CheckCIDRs

func CheckCIDRs(args []string, cidrsOptional bool) (set.Strings, error)

CheckCIDRs parses the list of strings as CIDRs, checking for correct formatting, no duplication and no overlaps. Returns error if no CIDRs are provided, unless cidrsOptional is true.

func CheckName

func CheckName(name string) (string, error)

CheckName checks whether name is a valid space name.

func NewAddCommand

func NewAddCommand() modelcmd.ModelCommand

NewAddCommand returns a command used to add a network space.

func NewListCommand

func NewListCommand() modelcmd.ModelCommand

NewListCommand returns a command used to list spaces.

func NewMoveCommand

func NewMoveCommand() modelcmd.ModelCommand

NewMoveCommand returns a command used to move an existing space to a different subnet.

func NewReloadCommand

func NewReloadCommand() modelcmd.ModelCommand

NewListCommand returns a command used to list spaces.

func NewRemoveCommand

func NewRemoveCommand() modelcmd.ModelCommand

NewRemoveCommand returns a command used to remove a space.

func NewRenameCommand

func NewRenameCommand() modelcmd.ModelCommand

NewRenameCommand returns a command used to rename an existing space.

func NewShowSpaceCommand

func NewShowSpaceCommand() modelcmd.ModelCommand

NewAddCommand returns a command used to add a network space.

func ParseNameAndCIDRs

func ParseNameAndCIDRs(args []string, cidrsOptional bool) (
	name string, CIDRs set.Strings, err error,
)

ParseNameAndCIDRs verifies the input args and returns any errors, like missing/invalid name or CIDRs (validated when given, but it's an error for CIDRs to be empty if cidrsOptional is false).

Types

type API

type API interface {
	io.Closer

	SpaceAPI
	SubnetAPI
}

API defines the contract for requesting the API facades.

type APIShim

type APIShim struct {
	SpaceAPI
	// contains filtered or unexported fields
}

APIShim forwards SpaceAPI methods to the real API facade for implemented methods only.

func (*APIShim) AddSpace

func (m *APIShim) AddSpace(name string, subnetIds []string, public bool) error

AddSpace adds a new Juju network space, associating the specified subnets with it (optional; can be empty), setting the space and subnets access to public or private.

func (*APIShim) Close

func (m *APIShim) Close() error

func (*APIShim) ListSpaces

func (m *APIShim) ListSpaces() ([]params.Space, error)

ListSpaces returns all Juju network spaces and their subnets.

func (*APIShim) MoveSubnets

func (m *APIShim) MoveSubnets(space names.SpaceTag, subnets []names.SubnetTag, force bool) (params.MoveSubnetsResult, error)

MoveSubnets ensures that the input subnets are in the input space.

func (*APIShim) ReloadSpaces

func (m *APIShim) ReloadSpaces() error

ReloadSpaces fetches spaces and subnets from substrate

func (*APIShim) RemoveSpace

func (m *APIShim) RemoveSpace(name string, force bool, dryRun bool) (params.RemoveSpaceResult, error)

RemoveSpace removes an existing Juju network space, transferring any associated subnets to the default space.

func (*APIShim) RenameSpace

func (m *APIShim) RenameSpace(oldName, newName string) error

RenameSpace changes the name of the space.

func (*APIShim) ShowSpace

func (m *APIShim) ShowSpace(name string) (params.ShowSpaceResult, error)

ShowSpace fetches space information.

func (*APIShim) SubnetsByCIDR

func (m *APIShim) SubnetsByCIDR(cidrs []string) ([]params.SubnetsResult, error)

SubnetsByCIDR returns the collection of subnets matching each CIDR in the input.

type AddCommand

type AddCommand struct {
	SpaceCommandBase
	Name  string
	CIDRs set.Strings
}

AddCommand calls the API to add a new network space.

func (*AddCommand) Info

func (c *AddCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*AddCommand) Init

func (c *AddCommand) Init(args []string) error

Init is defined on the cmd.Command interface. It checks the arguments for sanity and sets up the command to run.

func (*AddCommand) Run

func (c *AddCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

type FanCIDRs

type FanCIDRs struct {
	// FanLocalUnderlay is the CIDR of the local underlying fan network.
	// It allows easy identification of the device the fan is running on.
	FanLocalUnderlay string `json:"fan-local-underlay" yaml:"fan-local-underlay"`

	// FanOverlay is the CIDR of the complete fan setup.
	FanOverlay string `json:"fan-overlay" yaml:"fan-overlay"`
}

FanCIDRs describes the subnets relevant to a fan network.

type ListCommand

type ListCommand struct {
	SpaceCommandBase
	Short bool
	// contains filtered or unexported fields
}

listCommand displays a list of all spaces known to Juju.

func (*ListCommand) Info

func (c *ListCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*ListCommand) Init

func (c *ListCommand) Init(args []string) error

Init is defined on the cmd.Command interface. It checks the arguments for sanity and sets up the command to run.

func (*ListCommand) Run

func (c *ListCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

func (*ListCommand) SetFlags

func (c *ListCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags is defined on the cmd.Command interface.

type MoveCommand

type MoveCommand struct {
	SpaceCommandBase

	Name  string
	CIDRs set.Strings

	Force bool
	// contains filtered or unexported fields
}

MoveCommand calls the API to attempt to move an existing space to a different subnet.

func (*MoveCommand) Info

func (c *MoveCommand) Info() *cmd.Info

Info returns a cmd.Info that details the move command information.

func (*MoveCommand) Init

func (c *MoveCommand) Init(args []string) error

Init checks the arguments for valid arguments and sets up the command to run. Defined on the cmd.Command interface.

func (*MoveCommand) Run

func (c *MoveCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

func (*MoveCommand) SetFlags

func (c *MoveCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags defines the move command flags it wants to offer.

type MovedSpace

type MovedSpace struct {
	// SpaceFrom is the name of the space which the CIDR left.
	SpaceFrom string `json:"from" yaml:"from"`

	// SpaceTo is the name of the space which the CIDR goes to.
	SpaceTo string `json:"to" yaml:"to"`

	// CIDR of the subnet that is moving.
	CIDR string `json:"cidr" yaml:"cidr"`
}

MovedSpace represents a CIDR movement from space `a` to space `b`

type ReloadCommand

type ReloadCommand struct {
	SpaceCommandBase
}

listCommand displays a list of all spaces known to Juju.

func (*ReloadCommand) Info

func (c *ReloadCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*ReloadCommand) Run

func (c *ReloadCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

type RemoveCommand

type RemoveCommand struct {
	SpaceCommandBase
	// contains filtered or unexported fields
}

RemoveCommand calls the API to remove an existing network space.

func (*RemoveCommand) Info

func (c *RemoveCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*RemoveCommand) Init

func (c *RemoveCommand) Init(args []string) (err error)

Init is defined on the cmd.Command interface. It checks the arguments for sanity and sets up the command to run.

func (*RemoveCommand) Run

func (c *RemoveCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

func (*RemoveCommand) SetFlags

func (c *RemoveCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements Command.SetFlags.

type RemoveSpace

type RemoveSpace struct {
	// The space which cannot be removed. Only with --force.
	Space string `json:"space" yaml:"space"`
	// HasModelConstraint is the model constraint.
	HasModelConstraint bool `json:"has-model-constraint" yaml:"has-model-constraint"`
	// Constraints are the constraints which blocks the remove. Blocking Constraints are: Application.
	Constraints []string `json:"constraints,omitempty" yaml:"constraints,omitempty"`
	// Bindings are the application bindings which blocks the remove.
	Bindings []string `json:"bindings,omitempty" yaml:"bindings,omitempty"`
	// ControllerConfig are the config settings of the controller model which are using the space.
	// This is only valid if the current model is a controller model.
	ControllerConfig []string `json:"controller-settings,omitempty" yaml:"controller-settings,omitempty"`
}

RemoveSpace represents space information why a space could not be removed.

type RenameCommand

type RenameCommand struct {
	SpaceCommandBase
	Name    string
	NewName string
}

RenameCommand calls the API to rename an existing network space.

func (*RenameCommand) Info

func (c *RenameCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*RenameCommand) Init

func (c *RenameCommand) Init(args []string) (err error)

Init is defined on the cmd.Command interface. It checks the arguments for sanity and sets up the command to run.

func (*RenameCommand) Run

func (c *RenameCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

func (*RenameCommand) SetFlags

func (c *RenameCommand) SetFlags(f *gnuflag.FlagSet)

type RunOnAPI

type RunOnAPI func(api API, ctx *cmd.Context) error

type RunOnSpaceAPI

type RunOnSpaceAPI func(api SpaceAPI, ctx *cmd.Context) error

type ShowSpace

type ShowSpace struct {
	// Information about a given space.
	Space SpaceInfo `json:"space" yaml:"space"`
	// Application names which are bound to a given space.
	Applications []string `json:"applications" yaml:"applications"`
	// MachineCount is the number of machines connected to a given space.
	MachineCount int `json:"machine-count" yaml:"machine-count"`
}

ShowSpace represents space information output by the CLI client.

type ShowSpaceCommand

type ShowSpaceCommand struct {
	SpaceCommandBase
	Name string
	// contains filtered or unexported fields
}

ShowSpaceCommand calls the API to add a new network space.

func (*ShowSpaceCommand) Info

func (c *ShowSpaceCommand) Info() *cmd.Info

Info is defined on the cmd.Command interface.

func (*ShowSpaceCommand) Init

func (c *ShowSpaceCommand) Init(args []string) error

Init is defined on the cmd.Command interface. It checks the arguments for sanity and sets up the command to run.

func (*ShowSpaceCommand) Run

func (c *ShowSpaceCommand) Run(ctx *cmd.Context) error

Run implements Command.Run.

func (*ShowSpaceCommand) SetFlags

func (c *ShowSpaceCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags implements part of the cmd.Command interface.

type SpaceAPI

type SpaceAPI interface {
	// ListSpaces returns all Juju network spaces and their subnets.
	ListSpaces() ([]params.Space, error)

	// AddSpace adds a new Juju network space, associating the
	// specified subnets with it (optional; can be empty), setting the
	// space and subnets access to public or private.
	AddSpace(name string, subnetIds []string, public bool) error

	// RemoveSpace removes an existing Juju network space, transferring
	// any associated subnets to the default space.
	RemoveSpace(name string, force bool, dryRun bool) (params.RemoveSpaceResult, error)

	// RenameSpace changes the name of the space.
	RenameSpace(name, newName string) error

	// ReloadSpaces fetches spaces and subnets from substrate
	ReloadSpaces() error

	// ShowSpace fetches space information.
	ShowSpace(name string) (params.ShowSpaceResult, error)

	// MoveSubnets ensures that the input subnets are in the input space.
	MoveSubnets(names.SpaceTag, []names.SubnetTag, bool) (params.MoveSubnetsResult, error)
}

SpaceAPI defines the necessary API methods needed by the space subcommands.

type SpaceCommandBase

type SpaceCommandBase struct {
	modelcmd.ModelCommandBase
	modelcmd.IAASOnlyCommand
	// contains filtered or unexported fields
}

SpaceCommandBase is the base type embedded into all space subcommands.

func (*SpaceCommandBase) NewAPI

func (c *SpaceCommandBase) NewAPI() (API, error)

NewAPI returns a API for the root api endpoint that the environment command returns.

func (*SpaceCommandBase) RunWithAPI

func (c *SpaceCommandBase) RunWithAPI(ctx *cmd.Context, toRun RunOnAPI) error

func (*SpaceCommandBase) RunWithSpaceAPI

func (c *SpaceCommandBase) RunWithSpaceAPI(ctx *cmd.Context, toRun RunOnSpaceAPI) error

type SpaceInfo

type SpaceInfo struct {
	// ID is the unique identifier for the space.
	ID string `json:"id" yaml:"id"`

	// Name is the name of the space.
	// It is used by operators for identifying a space and should be unique.
	Name string `json:"name" yaml:"name"`

	// ProviderId is the provider's unique identifier for the space,
	// such as used by MAAS.
	ProviderId string `json:"provider-id,omitempty" yaml:"provider-id,omitempty"`

	// Subnets are the subnets that have been grouped into this network space.
	Subnets []SubnetInfo `json:"subnets" yaml:"subnets"`
}

SpaceInfo defines a network space.

type SubnetAPI

type SubnetAPI interface {

	// SubnetsByCIDR returns the collection of subnets matching each CIDR in the input.
	SubnetsByCIDR([]string) ([]params.SubnetsResult, error)
}

SubnetAPI defines the necessary API methods needed by the subnet subcommands.

type SubnetInfo

type SubnetInfo struct {
	// CIDR of the network, in 123.45.67.89/24 format.
	CIDR string `json:"cidr" yaml:"cidr"`

	// ProviderId is a provider-specific subnet ID.
	ProviderId string `json:"provider-id,omitempty" yaml:"provider-id,omitempty"`

	// ProviderSpaceId holds the provider ID of the space associated
	// with this subnet. Can be empty if not supported.
	ProviderSpaceId string `json:"provider-space-id,omitempty" yaml:"provider-space-id,omitempty"`

	// ProviderNetworkId holds the provider ID of the network
	// containing this subnet, for example VPC id for EC2.
	ProviderNetworkId string `json:"provider-network-id,omitempty" yaml:"provider-network-id,omitempty"`

	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
	// normal networks. It's defined by IEEE 802.1Q standard, and used
	// to define a VLAN network. For more information, see:
	// http://en.wikipedia.org/wiki/IEEE_802.1Q.
	VLANTag int `json:"vlan-tag" yaml:"vlan-tag"`

	// AvailabilityZones describes which availability zones this
	// subnet is in. It can be empty if the provider does not support
	// availability zones.
	AvailabilityZones []string `json:"zones,omitempty" yaml:"zones,omitempty"`

	// SpaceID is the id of the space the subnet is associated with.
	// Default value should be AlphaSpaceId. It can be empty if
	// the subnet is returned from an networkingEnviron. SpaceID is
	// preferred over SpaceName in state and non networkingEnviron use.
	SpaceID string `json:"space-id,omitempty" yaml:"space-id,omitempty"`

	// SpaceName is the name of the space the subnet is associated with.
	// An empty string indicates it is part of the AlphaSpaceName OR
	// if the SpaceID is set. Should primarily be used in an networkingEnviron.
	SpaceName string `json:"space-name,omitempty" yaml:"space-name,omitempty"`

	// FanInfo describes the fan networking setup for the subnet.
	// It may be empty if this is not a fan subnet,
	// or if this subnet information comes from a provider.
	FanInfo *network.FanCIDRs `json:"fan-info,omitempty" yaml:"fan-info,omitempty"`

	// IsPublic describes whether a subnet is public or not.
	IsPublic bool `json:"is-public,omitempty" yaml:"is-public,omitempty"`
}

SubnetInfo is a source-agnostic representation of a subnet. It may originate from state, or from a provider.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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