subnet

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: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddCommand

func NewAddCommand() modelcmd.ModelCommand

NewAddCommand returns a command used to add an existing subnet to Juju.

func NewListCommand

func NewListCommand() modelcmd.ModelCommand

NewListCommand returns a cammin used to list all subnets known to Juju.

Types

type AddCommand

type AddCommand struct {
	SubnetCommandBase

	CIDR       string
	RawCIDR    string // before normalizing (e.g. 10.10.0.0/8 to 10.0.0.0/8)
	ProviderId string
	Space      names.SpaceTag
	Zones      []string
}

AddCommand calls the API to add an existing subnet to Juju.

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) (err 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 ListCommand

type ListCommand struct {
	SubnetCommandBase

	SpaceName string
	ZoneName  string

	Out cmd.Output
	// contains filtered or unexported fields
}

ListCommand displays a list of all subnets 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 RunOnAPI

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

type SubnetAPI

type SubnetAPI interface {
	io.Closer

	// AddSubnet adds an existing subnet to Juju.
	AddSubnet(cidr string, id network.Id, spaceTag names.SpaceTag, zones []string) error

	// ListSubnets returns information about subnets known to Juju,
	// optionally filtered by space and/or zone (both can be empty).
	ListSubnets(withSpace *names.SpaceTag, withZone string) ([]params.Subnet, error)

	// AllZones returns all availability zones known to Juju.
	AllZones() ([]string, error)

	// AllSpaces returns all Juju network spaces.
	AllSpaces() ([]names.Tag, error)
}

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

type SubnetCommandBase

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

SubnetCommandBase is the base type embedded into all subnet subcommands.

func (*SubnetCommandBase) CheckNumArgs

func (s *SubnetCommandBase) CheckNumArgs(args []string, errors []error) error

CheckNumArgs is a helper used to validate the number of arguments passed to Init(). If the number of arguments is X, errors[X] (if set) will be returned, otherwise no error occurs.

func (*SubnetCommandBase) NewAPI

func (c *SubnetCommandBase) NewAPI() (SubnetAPI, error)

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

func (*SubnetCommandBase) RunWithAPI

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

func (*SubnetCommandBase) ValidateCIDR

func (s *SubnetCommandBase) ValidateCIDR(given string, strict bool) (string, error)

ValidateCIDR parses given and returns an error if it's not valid. If the CIDR is incorrectly specified (e.g. 10.10.10.0/16 instead of 10.10.0.0/16) and strict is false, the correctly parsed CIDR in the expected format is returned instead without an error. Otherwise, when strict is true and given is incorrectly formatted, an error will be returned.

func (*SubnetCommandBase) ValidateSpace

func (s *SubnetCommandBase) ValidateSpace(given string) (names.SpaceTag, error)

ValidateSpace parses given and returns an error if it's not a valid space name, otherwise returns the parsed tag and no error.

Jump to

Keyboard shortcuts

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