commands

package
v0.0.0-...-a002913 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2015 License: AGPL-3.0 Imports: 84 Imported by: 0

Documentation

Index

Constants

View Source
const JujuPluginPrefix = "juju-"
View Source
const PluginTopicText = `` /* 166-byte string literal not displayed */

Variables

View Source
var DefaultLogLocation = "/var/log/juju/all-machines.log"
View Source
var DoubleEnvironmentError = stderrors.New("you cannot supply both -e and the envname as a positional argument")
View Source
var NoEnvironmentError = stderrors.New("no environment specified")

Functions

func ConvertRunResults

func ConvertRunResults(runResults []params.RunResult) interface{}

ConvertRunResults takes the results from the api and creates a map suitable for format converstion to YAML or JSON.

func Main

func Main(args []string)

Main registers subcommands for the juju executable, and hands over control to the cmd package. This function is not redundant with main, because it provides an entry point for testing with arbitrary command line arguments.

func NewAuthorizedKeysCommand

func NewAuthorizedKeysCommand() cmd.Command

func NewJujuCommand

func NewJujuCommand(ctx *cmd.Context) cmd.Command

func PluginHelpTopic

func PluginHelpTopic() string

func RunPlugin

func RunPlugin(ctx *cmd.Context, subcommand string, args []string) error

Types

type APIInfoCommand

type APIInfoCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

APIInfoCommand returns the fields used to connect to an API server.

func (*APIInfoCommand) Info

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

func (*APIInfoCommand) Init

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

func (*APIInfoCommand) Run

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

Print out the addresses of the API server endpoints.

func (*APIInfoCommand) SetFlags

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

type AddKeysCommand

type AddKeysCommand struct {
	AuthorizedKeysBase
	// contains filtered or unexported fields
}

AddKeysCommand is used to add a new authorized ssh key for a user.

func (*AddKeysCommand) Info

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

func (*AddKeysCommand) Init

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

func (*AddKeysCommand) Run

func (c *AddKeysCommand) Run(context *cmd.Context) error

func (*AddKeysCommand) SetFlags

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

type AddRelationCommand

type AddRelationCommand struct {
	envcmd.EnvCommandBase
	Endpoints []string
}

AddRelationCommand adds a relation between two service endpoints.

func (*AddRelationCommand) Info

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

func (*AddRelationCommand) Init

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

func (*AddRelationCommand) Run

func (c *AddRelationCommand) Run(_ *cmd.Context) error

type AuthorizedKeysBase

type AuthorizedKeysBase struct {
	envcmd.EnvCommandBase
}

func (*AuthorizedKeysBase) NewKeyManagerClient

func (c *AuthorizedKeysBase) NewKeyManagerClient() (*keymanager.Client, error)

NewKeyManagerClient returns a keymanager client for the root api endpoint that the environment command returns.

type AuthorizedKeysCommand

type AuthorizedKeysCommand struct {
	*cmd.SuperCommand
}

func (*AuthorizedKeysCommand) SetFlags

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

type BootstrapCommand

type BootstrapCommand struct {
	envcmd.EnvCommandBase
	Constraints constraints.Value
	UploadTools bool
	Series      []string

	MetadataSource        string
	Placement             string
	KeepBrokenEnvironment bool
	NoAutoUpgrade         bool
	AgentVersionParam     string
	AgentVersion          *version.Number
	// contains filtered or unexported fields
}

BootstrapCommand is responsible for launching the first machine in a juju environment, and setting up everything necessary to continue working.

func (*BootstrapCommand) Info

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

func (*BootstrapCommand) Init

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

func (*BootstrapCommand) Run

func (c *BootstrapCommand) Run(ctx *cmd.Context) (resultErr error)

Run connects to the environment specified on the command line and bootstraps a juju in that environment if none already exists. If there is as yet no environments.yaml file, the user is informed how to create one.

func (*BootstrapCommand) SetBootstrapEndpointAddress

func (c *BootstrapCommand) SetBootstrapEndpointAddress(environ environs.Environ) error

SetBootstrapEndpointAddress writes the API endpoint address of the bootstrap server into the connection information. This should only be run once directly after Bootstrap. It assumes that there is just one instance in the environment - the bootstrap instance.

func (*BootstrapCommand) SetFlags

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

type BootstrapInterface

type BootstrapInterface interface {
	EnsureNotBootstrapped(env environs.Environ) error
	Bootstrap(ctx environs.BootstrapContext, environ environs.Environ, args bootstrap.BootstrapParams) error
}

bootstrap functionality that Run calls to support cleaner testing

type DebugHooksCommand

type DebugHooksCommand struct {
	SSHCommand
	// contains filtered or unexported fields
}

DebugHooksCommand is responsible for launching a ssh shell on a given unit or machine.

func (*DebugHooksCommand) Info

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

func (*DebugHooksCommand) Init

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

func (*DebugHooksCommand) Run

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

Run ensures c.Target is a unit, and resolves its address, and connects to it via SSH to execute the debug-hooks script.

type DebugLogAPI

type DebugLogAPI interface {
	WatchDebugLog(params api.DebugLogParams) (io.ReadCloser, error)
	Close() error
}

type DebugLogCommand

type DebugLogCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

func (*DebugLogCommand) Info

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

func (*DebugLogCommand) Init

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

func (*DebugLogCommand) Run

func (c *DebugLogCommand) Run(ctx *cmd.Context) (err error)

Run retrieves the debug log via the API.

func (*DebugLogCommand) SetFlags

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

type DeleteKeysCommand

type DeleteKeysCommand struct {
	AuthorizedKeysBase
	// contains filtered or unexported fields
}

DeleteKeysCommand is used to delete authorised ssh keys for a user.

func (*DeleteKeysCommand) Info

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

func (*DeleteKeysCommand) Init

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

func (*DeleteKeysCommand) Run

func (c *DeleteKeysCommand) Run(context *cmd.Context) error

func (*DeleteKeysCommand) SetFlags

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

type DeployCommand

type DeployCommand struct {
	envcmd.EnvCommandBase
	service.UnitCommandBase
	CharmName    string
	ServiceName  string
	Config       cmd.FileVar
	Constraints  constraints.Value
	Networks     string // TODO(dimitern): Drop this in a follow-up and fix docs.
	BumpRevision bool   // Remove this once the 1.16 support is dropped.
	RepoPath     string // defaults to JUJU_REPOSITORY
	RegisterURL  string

	// TODO(axw) move this to UnitCommandBase once we support --storage
	// on add-unit too.
	//
	// Storage is a map of storage constraints, keyed on the storage name
	// defined in charm storage metadata.
	Storage map[string]storage.Constraints
}

func (*DeployCommand) Info

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

func (*DeployCommand) Init

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

func (*DeployCommand) Run

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

func (*DeployCommand) SetFlags

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

type DestroyEnvironmentCommand

type DestroyEnvironmentCommand struct {
	envcmd.EnvCommandBase
	cmd.CommandBase
	// contains filtered or unexported fields
}

DestroyEnvironmentCommand destroys an environment.

func (*DestroyEnvironmentCommand) Info

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

func (*DestroyEnvironmentCommand) Init

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

func (*DestroyEnvironmentCommand) Run

func (c *DestroyEnvironmentCommand) Run(ctx *cmd.Context) (result error)

func (*DestroyEnvironmentCommand) SetFlags

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

type EndpointCommand

type EndpointCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

EndpointCommand returns the API endpoints

func (*EndpointCommand) Info

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

func (*EndpointCommand) Run

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

Print out the addresses of the API server endpoints.

func (*EndpointCommand) SetFlags

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

type EnsureAvailabilityClient

type EnsureAvailabilityClient interface {
	Close() error
	EnsureAvailability(
		numStateServers int, cons constraints.Value, series string,
		placement []string) (params.StateServersChanges, error)
}

EnsureAvailabilityClient defines the methods on the client api that the ensure availability command calls.

type EnsureAvailabilityCommand

type EnsureAvailabilityCommand struct {
	envcmd.EnvCommandBase

	// NumStateServers specifies the number of state servers to make available.
	NumStateServers int
	// Series is used for newly created machines, if specified.
	// Otherwise,  the environment's default-series is used.
	Series string
	// Constraints, if specified, will be merged with those already
	// in the environment when creating new machines.
	Constraints constraints.Value
	// Placement specifies specific machine(s) which will be used to host
	// new state servers. If there are more state servers required than
	// machines specified, new machines will be created.
	// Placement is passed verbatim to the API, to be evaluated and used server-side.
	Placement []string
	// PlacementSpec holds the unparsed placement directives argument (--to).
	PlacementSpec string
	// contains filtered or unexported fields
}

EnsureAvailabilityCommand makes the system highly available.

func (*EnsureAvailabilityCommand) Info

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

func (*EnsureAvailabilityCommand) Init

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

func (*EnsureAvailabilityCommand) Run

Run connects to the environment specified on the command line and calls EnsureAvailability.

func (*EnsureAvailabilityCommand) SetFlags

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

type ExposeCommand

type ExposeCommand struct {
	envcmd.EnvCommandBase
	ServiceName string
}

ExposeCommand is responsible exposing services.

func (*ExposeCommand) Info

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

func (*ExposeCommand) Init

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

func (*ExposeCommand) Run

func (c *ExposeCommand) Run(_ *cmd.Context) error

Run changes the juju-managed firewall to expose any ports that were also explicitly marked by units as open.

type GetCommand

type GetCommand struct {
	envcmd.EnvCommandBase
	ServiceName string
	// contains filtered or unexported fields
}

GetCommand retrieves the configuration of a service.

func (*GetCommand) Info

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

func (*GetCommand) Init

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

func (*GetCommand) Run

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

Run fetches the configuration of the service and formats the result as a YAML string.

func (*GetCommand) SetFlags

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

type HelpToolCommand

type HelpToolCommand struct {
	cmd.CommandBase
	// contains filtered or unexported fields
}

func (*HelpToolCommand) Info

func (t *HelpToolCommand) Info() *cmd.Info

func (*HelpToolCommand) Init

func (t *HelpToolCommand) Init(args []string) error

func (*HelpToolCommand) Run

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

type ImportKeysCommand

type ImportKeysCommand struct {
	AuthorizedKeysBase
	// contains filtered or unexported fields
}

ImportKeysCommand is used to add new authorized ssh keys for a user.

func (*ImportKeysCommand) Info

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

func (*ImportKeysCommand) Init

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

func (*ImportKeysCommand) Run

func (c *ImportKeysCommand) Run(context *cmd.Context) error

func (*ImportKeysCommand) SetFlags

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

type InfoData

type InfoData struct {
	User         string   `json:"user,omitempty" yaml:",omitempty"`
	Password     string   `json:"password,omitempty" yaml:",omitempty"`
	EnvironUUID  string   `json:"environ-uuid,omitempty" yaml:"environ-uuid,omitempty"`
	ServerUUID   string   `json:"server-uuid,omitempty" yaml:"server-uuid,omitempty"`
	StateServers []string `json:"state-servers,omitempty" yaml:"state-servers,omitempty"`
	CACert       string   `json:"ca-cert,omitempty" yaml:"ca-cert,omitempty"`
}

type InitCommand

type InitCommand struct {
	cmd.CommandBase
	WriteFile bool
	Show      bool
}

InitCommand is used to write out a boilerplate environments.yaml file.

func (*InitCommand) Info

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

func (*InitCommand) Run

func (c *InitCommand) Run(context *cmd.Context) error

Run checks to see if there is already an environments.yaml file. In one does not exist already, a boilerplate version is created so that the user can edit it to get started.

func (*InitCommand) SetFlags

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

type ListKeysCommand

type ListKeysCommand struct {
	AuthorizedKeysBase
	// contains filtered or unexported fields
}

ListKeysCommand is used to list the authorized ssh keys.

func (*ListKeysCommand) Info

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

func (*ListKeysCommand) Run

func (c *ListKeysCommand) Run(context *cmd.Context) error

func (*ListKeysCommand) SetFlags

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

type PluginCommand

type PluginCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

func (*PluginCommand) Info

func (*PluginCommand) Info() *cmd.Info

Info is just a stub so that PluginCommand implements cmd.Command. Since this is never actually called, we can happily return nil.

func (*PluginCommand) Init

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

func (*PluginCommand) Run

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

type PluginDescription

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

func GetPluginDescriptions

func GetPluginDescriptions() []PluginDescription

GetPluginDescriptions runs each plugin with "--description". The calls to the plugins are run in parallel, so the function should only take as long as the longest call.

type PublishCommand

type PublishCommand struct {
	envcmd.EnvCommandBase
	URL       string
	CharmPath string
	// contains filtered or unexported fields
}

func (*PublishCommand) ChangePushLocation

func (c *PublishCommand) ChangePushLocation(change func(string) string)

func (*PublishCommand) Info

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

func (*PublishCommand) Init

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

func (*PublishCommand) Run

func (c *PublishCommand) Run(ctx *cmd.Context) (err error)

func (*PublishCommand) SetFlags

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

func (*PublishCommand) SetPollDelay

func (c *PublishCommand) SetPollDelay(delay time.Duration)

type RemoveRelationCommand

type RemoveRelationCommand struct {
	envcmd.EnvCommandBase
	Endpoints []string
}

RemoveRelationCommand causes an existing service relation to be shut down.

func (*RemoveRelationCommand) Info

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

func (*RemoveRelationCommand) Init

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

func (*RemoveRelationCommand) Run

type RemoveServiceCommand

type RemoveServiceCommand struct {
	envcmd.EnvCommandBase
	ServiceName string
}

RemoveServiceCommand causes an existing service to be destroyed.

func (*RemoveServiceCommand) Info

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

func (*RemoveServiceCommand) Init

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

func (*RemoveServiceCommand) Run

type RemoveUnitCommand

type RemoveUnitCommand struct {
	envcmd.EnvCommandBase
	UnitNames []string
}

RemoveUnitCommand is responsible for destroying service units.

func (*RemoveUnitCommand) Info

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

func (*RemoveUnitCommand) Init

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

func (*RemoveUnitCommand) Run

func (c *RemoveUnitCommand) Run(_ *cmd.Context) error

Run connects to the environment specified on the command line and destroys units therein.

type ResolvedCommand

type ResolvedCommand struct {
	envcmd.EnvCommandBase
	UnitName string
	Retry    bool
}

ResolvedCommand marks a unit in an error state as ready to continue.

func (*ResolvedCommand) Info

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

func (*ResolvedCommand) Init

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

func (*ResolvedCommand) Run

func (c *ResolvedCommand) Run(_ *cmd.Context) error

func (*ResolvedCommand) SetFlags

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

type RunClient

type RunClient interface {
	Close() error
	RunOnAllMachines(commands string, timeout time.Duration) ([]params.RunResult, error)
	Run(run params.RunParams) ([]params.RunResult, error)
}

type RunCommand

type RunCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

RunCommand is responsible for running arbitrary commands on remote machines.

func (*RunCommand) Info

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

func (*RunCommand) Init

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

func (*RunCommand) Run

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

func (*RunCommand) SetFlags

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

type SCPCommand

type SCPCommand struct {
	SSHCommon
}

SCPCommand is responsible for launching a scp command to copy files to/from remote machine(s)

func (*SCPCommand) Info

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

func (*SCPCommand) Init

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

func (*SCPCommand) Run

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

Run resolves c.Target to a machine, or host of a unit and forks ssh with c.Args, if provided.

type SSHCommand

type SSHCommand struct {
	SSHCommon
}

SSHCommand is responsible for launching a ssh shell on a given unit or machine.

func (*SSHCommand) Info

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

func (*SSHCommand) Init

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

func (*SSHCommand) Run

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

Run resolves c.Target to a machine, to the address of a i machine or unit forks ssh passing any arguments provided.

type SSHCommon

type SSHCommon struct {
	envcmd.EnvCommandBase

	Target string
	Args   []string
	// contains filtered or unexported fields
}

SSHCommon provides common methods for SSHCommand, SCPCommand and DebugHooksCommand.

func (*SSHCommon) AllowInterspersedFlags

func (c *SSHCommon) AllowInterspersedFlags() bool

AllowInterspersedFlags for ssh/scp is set to false so that flags after the unit name are passed through to ssh, for eg. `juju ssh -v service-name/0 uname -a`.

func (*SSHCommon) SetFlags

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

type SwitchCommand

type SwitchCommand struct {
	cmd.CommandBase
	EnvName string
	List    bool
}

func (*SwitchCommand) Info

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

func (*SwitchCommand) Init

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

func (*SwitchCommand) Run

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

func (*SwitchCommand) SetFlags

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

type SyncToolsCommand

type SyncToolsCommand struct {
	envcmd.EnvCommandBase
	// contains filtered or unexported fields
}

SyncToolsCommand copies all the tools from the us-east-1 bucket to the local bucket.

func (*SyncToolsCommand) Info

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

func (*SyncToolsCommand) Init

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

func (*SyncToolsCommand) Run

func (c *SyncToolsCommand) Run(ctx *cmd.Context) (resultErr error)

func (*SyncToolsCommand) SetFlags

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

type UnexposeCommand

type UnexposeCommand struct {
	envcmd.EnvCommandBase
	ServiceName string
}

UnexposeCommand is responsible exposing services.

func (*UnexposeCommand) Info

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

func (*UnexposeCommand) Init

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

func (*UnexposeCommand) Run

func (c *UnexposeCommand) Run(_ *cmd.Context) error

Run changes the juju-managed firewall to hide any ports that were also explicitly marked by units as closed.

type UpgradeCharmCommand

type UpgradeCharmCommand struct {
	envcmd.EnvCommandBase
	ServiceName string
	Force       bool
	RepoPath    string // defaults to JUJU_REPOSITORY
	SwitchURL   string
	Revision    int // defaults to -1 (latest)
}

UpgradeCharm is responsible for upgrading a service's charm.

func (*UpgradeCharmCommand) Info

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

func (*UpgradeCharmCommand) Init

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

func (*UpgradeCharmCommand) Run

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

Run connects to the specified environment and starts the charm upgrade process.

func (*UpgradeCharmCommand) SetFlags

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

type UpgradeJujuCommand

type UpgradeJujuCommand struct {
	envcmd.EnvCommandBase

	Version       version.Number
	UploadTools   bool
	DryRun        bool
	ResetPrevious bool
	AssumeYes     bool
	Series        []string
	// contains filtered or unexported fields
}

UpgradeJujuCommand upgrades the agents in a juju installation.

func (*UpgradeJujuCommand) Info

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

func (*UpgradeJujuCommand) Init

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

func (*UpgradeJujuCommand) Run

func (c *UpgradeJujuCommand) Run(ctx *cmd.Context) (err error)

Run changes the version proposed for the juju envtools.

func (*UpgradeJujuCommand) SetFlags

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

Jump to

Keyboard shortcuts

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