cmd

package
v2.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2018 License: Apache-2.0, BSD-3-Clause, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigDir = ".packet"

ConfigDir is the location of the config file under user's $HOME dir

View Source
const ConfigFile = "config"

ConfigFile is the filename of the config file

Variables

View Source
var RootCmd = &cobra.Command{
	Use:          "packet",
	Short:        "CLI tool to manage packet.net services",
	SilenceUsage: true,
	Run: func(cmd *cobra.Command, args []string) {
		showVersion, _ := cmd.Flags().GetBool("version")
		if showVersion {

			fmt.Printf("%s\n", version)
		}
	},
}

RootCmd represents the base command when called without any subcommands

Functions

func AssignIPAddress

func AssignIPAddress(deviceID, ipAddress string) error

AssignIPAddress assigns an IP address to a device by ID

func AttachStorage

func AttachStorage(storageID, deviceID string) error

AttachStorage attaches your volume to a device

func CloneStorage

func CloneStorage(storageID, snapshotTimestamp string) error

CloneStorage clones your volume or snapshot into a new volume. To clone the volume, send an empty body. To promote a volume snapshot into a new volume, include the snapshot_timestamp attribute in the request body.

func Configure

func Configure(profile string) error

Configure prompts the user to configure a default API key

func CreateDevice

func CreateDevice(projectID, hostname, plan, facility, operatingSystem, billingCycle, userData, ipxeScriptURL string, tags []string, spotInstance, alwaysPXE bool, spotPriceMax float64) error

CreateDevice creates a new device

func CreateDeviceVerbose

func CreateDeviceVerbose(projectID, hostname, plan, facility, operatingSystem, billingCycle, userData, ipxeScriptURL string, tags []string, spotInstance, alwaysPXE bool, spotPriceMax float64) error

CreateDeviceVerbose creates a new device and logs events till the device is provisionned

func CreateProject

func CreateProject(orgID, name, paymentID string) error

CreateProject creates a new project with the given project name

func CreateSSHKey

func CreateSSHKey(label, key string) error

CreateSSHKey creates a new ssh key.

func CreateSnapshot

func CreateSnapshot(storageID string) error

CreateSnapshot creates a new snapshot of your volume

func CreateSnapshotPolicy

func CreateSnapshotPolicy(storageID, frequency string, count int) error

CreateSnapshotPolicy creates a snapshot policy

func CreateStorage

func CreateStorage(projectID, description, plan, facility, frequency string, size, count int) error

CreateStorage creates a new volume

func DeleteDevice

func DeleteDevice(deviceID string) error

DeleteDevice deletes the device associated with the given device id.

func DeleteProject

func DeleteProject(id string) error

DeleteProject deletes the project associated with the given project id.

func DeleteSSHKey

func DeleteSSHKey(keyID string) error

DeleteSSHKey deletes the ssh key associated with the given key id.

func DeleteSnapshot

func DeleteSnapshot(storageID, snapshotID string) error

DeleteSnapshot deletes a snapshot

func DeleteSnapshotPolicy

func DeleteSnapshotPolicy(snapshotPolicyID string) error

DeleteSnapshotPolicy deletes a snapshot policy

func DeleteStorage

func DeleteStorage(storageID string) error

DeleteStorage deletes a volume

func DetachStorage

func DetachStorage(attachmentID string) error

DetachStorage detaches your volume from a device

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func GetAPIKey

func GetAPIKey() (string, error)

GetAPIKey returns either the default configured key or the one passed through the CLI. The key passed through the CLI has the highest priority

func GetProjectID

func GetProjectID(cmd *cobra.Command) string

GetProjectID returns the project ID passed to the CLI, otherwise the configure default ID.

func ListDevice

func ListDevice(deviceID string) error

ListDevice prints out the device associated with the given device id.

func ListDeviceEvents

func ListDeviceEvents(id string) error

ListDeviceEvents prints out events by device ID

func ListDevices

func ListDevices(projectID string) error

ListDevices prints out all devices associated with the given project id.

func ListFacilities

func ListFacilities() error

ListFacilities returns a list of packet DCs

func ListIPAddress

func ListIPAddress(ipAddressID string) error

ListIPAddress prints out ip address by ID

func ListIPReservation

func ListIPReservation(id string) error

ListIPReservation returns a single IP reservation object

func ListIPReservations

func ListIPReservations(projectID string) error

ListIPReservations provides a list of IP resevations for a single project

func ListOS

func ListOS() error

ListOS prints out the available operating systems.

func ListPlans

func ListPlans() error

ListPlans prints out the available plans(server types).

func ListProject

func ListProject(projectID string) error

ListProject prints out the project associated with a given project id

func ListProjectEvents

func ListProjectEvents(id string) error

ListProjectEvents prints out events by device ID

func ListProjects

func ListProjects() error

ListProjects prints out all projects of the user.

func ListSSHKey

func ListSSHKey(keyID string) error

ListSSHKey prints out the ssh key associated with the given key id.

func ListSSHKeys

func ListSSHKeys() error

ListSSHKeys prints out all ssh keys generated by the user.

func ListSnapshots

func ListSnapshots(storageID string) error

ListSnapshots returns a list of the current volume’s snapshots

func ListStorage

func ListStorage(storageID string) error

ListStorage returns a volume by ID

func ListStorageEvents

func ListStorageEvents(storageID string) error

ListStorageEvents prints out events by device ID

func ListStorages

func ListStorages(projectID string) error

ListStorages returns a list of the current projects’s volumes

func LockDevice

func LockDevice(deviceID string) error

LockDevice locks the device associated with the given device id.

func MarshallAndPrint

func MarshallAndPrint(v interface{}) error

MarshallAndPrint pretty-prints any object as a JSON string

func NewExtPacketClient

func NewExtPacketClient() (*extpackngo.Client, error)

NewExtPacketClient returns a *extpackngo.Client ready for API calls

func NewPacketClient

func NewPacketClient() (*packngo.Client, error)

NewPacketClient returns a *packngo.Client ready for API calls

func PowerOffDevice

func PowerOffDevice(deviceID string) error

PowerOffDevice powers off the device associated with the given device id.

func PowerOnDevice

func PowerOnDevice(deviceID string) error

PowerOnDevice powers on the device associated with the given device id.

func RebootDevice

func RebootDevice(deviceID string) error

RebootDevice reboots the device associated with the given device id.

func RemoveIPReservation

func RemoveIPReservation(id string) error

RemoveIPReservation removes an IP reservation from the project

func RequestMoreIPReservations

func RequestMoreIPReservations(projectID, ipType, comments string, quantity int) error

RequestMoreIPReservations requests more IP space for a project in order to have additional IP addresses to assign to devices

func RestoreStorage

func RestoreStorage(storageID, restorePoint string) error

RestoreStorage restores a volume to the given snapshot

func SpotMarketPrices

func SpotMarketPrices() error

SpotMarketPrices shows the spot market prices

func UnAssignIPAddress

func UnAssignIPAddress(ipAddressID string) error

UnAssignIPAddress unassigns and IP address from a device

func UnlockDevice

func UnlockDevice(deviceID string) error

UnlockDevice unlocks the device associated with the given device id.

func UpdateDevice

func UpdateDevice(deviceID string, hostname, description, userData, ipxeScriptURL string, tags []string, locked, alwaysPXE bool) error

UpdateDevice updates a device by ID.

func UpdateProject

func UpdateProject(projectID, name, paymentID string) error

UpdateProject updates the project associated with the given project id either by changing the name or the payment method.

func UpdateSSHKey

func UpdateSSHKey(keyID, label, key string) error

UpdateSSHKey updates the ssh key associated with the given key id.

func UpdateSnapshotPolicy

func UpdateSnapshotPolicy(snapshotPolicyID, frequency string, count int) error

UpdateSnapshotPolicy updates a snapshot policy

func UpdateStorage

func UpdateStorage(storageID, description string, size int, locked bool) error

UpdateStorage updates a volume

Types

type Config

type Config struct {
	APIKEY           string `json:"APIKEY"`
	DefaultProjectID string `json:"DEFAULT_PROJECT_ID"`
}

Config represent default configurations

func (*Config) String

func (c *Config) String() string

type Configs

type Configs struct {
	Profiles map[string]*Config `json:"profiles"`
}

Configs represents a set of profiles

func ReadConfigs

func ReadConfigs() (*Configs, error)

ReadConfigs reads the current config file and returns a Config object

Jump to

Keyboard shortcuts

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