import "github.com/analog-substance/carbon"
Carbon main package
This is the multi-page printable view of this section. Click here to print.
import "github.com/analog-substance/carbon/pkg/carbon"
Package carbon provides core application functionality and constants
const CloudInitDir = "cloud-init"
const ISOVarUsage = "var.iso_url"
const PackerFileIsoVars = "iso-variables.pkr.hcl"
const PackerFileLocalVars = "local-variables.pkr.hcl"
const PackerFilePacker = "packer.pkr.hcl"
const PackerFilePrivateVarsExample = "private.auto.pkrvars.hcl.example"
const PackerFileSuffixAnsible = "-ansible.pkr.hcl"
const PackerFileSuffixCloudInit = "-cloud-init.pkr.hcl"
const PackerFileSuffixVariables = "-variables.pkr.hcl"
var AllProviders = []types.Provider{
aws.New(),
qemu.New(),
virtualbox.New(),
multipass.New(),
digitalocean.New(),
vsphere.New(),
}
func AvailableProviders() []types.Provider
type Carbon struct {
// contains filtered or unexported fields
}
func New(config common.CarbonConfig) *Carbon
func (c *Carbon) FindVMByID(id string) []types.VM
func (c *Carbon) FindVMByName(name string) []types.VM
func (c *Carbon) GetConfig() common.CarbonConfig
func (c *Carbon) GetImage(imageID string) (types.Image, error)
func (c *Carbon) GetImageBuild(name, provider, provisioner string) (types.ImageBuild, error)
func (c *Carbon) GetImageBuildTemplates() []string
func (c *Carbon) GetImageBuilds() ([]types.ImageBuild, error)
func (c *Carbon) GetImages() ([]types.Image, error)
func (c *Carbon) GetProject(name string) (types.Project, error)
func (c *Carbon) GetProjects() ([]types.Project, error)
func (c *Carbon) GetProvider(providerType string) (types.Provider, error)
func (c *Carbon) GetVMs() []types.VM
func (c *Carbon) Profiles() []types.Profile
func (c *Carbon) Providers() []types.Provider
func (c *Carbon) VMsFromHosts(hostnames []string) []types.VM
type Options struct {
Providers []string
Profiles []string
Environments []string
}
import "github.com/analog-substance/carbon/pkg/cloud_init"
type AptSource struct {
Source string `yaml:"source"`
Keyid string `yaml:"keyid"`
}
type CloudConfig struct {
Timezone string `yaml:"timezone"`
SSHDeletekeys bool `yaml:"ssh_deletekeys"`
SSHAuthorizedKeys []string `yaml:"ssh_authorized_keys"`
Apt struct {
Sources map[string]AptSource `yaml:"sources"`
} `yaml:"apt"`
WriteFiles []WriteFile `yaml:"write_files"`
PackageUpgrade bool `yaml:"package_upgrade"`
Packages []string `yaml:"packages"`
Runcmd [][]string `yaml:"runcmd"`
}
func (c *CloudConfig) MergeWith(otherConfig *CloudConfig)
type WriteFile struct {
Path string `yaml:"path"`
Content string `yaml:"content"`
Owner string `yaml:"owner"`
Permissions string `yaml:"permissions"`
Encoding string `yaml:"encoding,omitempty"`
}
import "github.com/analog-substance/carbon/pkg/cmd"
CarbonCmd represents the base command when called without any subcommands
var CarbonCmd = &cobra.Command{
Use: "carbon",
Short: "Carbon - Infrastructure automation for offensive operations.",
Long: `Infrastructure automation for offensive operations.
- ℹ️ Checkout the latest docs [here](https://analog-substance.github.io/carbon/)
- 😢 Have a problem? [Create an Issue](https://github.com/analog-substance/carbon/issues/new?title=Something%20is%20broken)
- ❤️ Enjoying Carbon? [Star the Repo](https://github.com/analog-substance/carbon)
## Purpose
Carbon's primary purpose is to provide a consistent execution environment to
facilitate offensive security assessments.
## Dependencies
- Packer to build images.
- Terraform to provision infrastructure.
- Golang project structure.
## Supported Providers
- AWS
- QEMU (Local)
- VirtualBox (Local)
- vSphere (in progress)
- Multipass (Local)
There are plans to bring support to the following:
- GCP
- Azure
- VMware (Local)
- QEMU (Remote)
`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if debug {
common.LogLevel(slog.LevelDebug)
}
log.Debug("debug mode", "debug", debug)
carbonConfigFile := common.GetConfig()
home, err := homedir.Dir()
if err != nil {
log.Debug("error getting home directory", "error", err)
} else {
err := carbonConfigFile.MergeInConfigFile(filepath.Join(home, cfgFileName))
if err != nil {
log.Debug("error loading carbon config from home", "error", err)
}
}
err = carbonConfigFile.MergeInConfigFile(cfgFileName)
if err != nil {
log.Debug("error loading carbon config from home", "error", err)
}
carbonObj = carbon.New(carbonConfigFile.Carbon)
updateConfigHelp()
return nil
},
}
func AskIfSure(msg string) bool
func Execute()
Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.
func ListingDir(dir string)
import "github.com/analog-substance/carbon/pkg/common"
const DefaultDeploymentsDirName = "deployments"
const DefaultImagesDirName = "images"
const DefaultInstanceConfigKey = "instance"
const DefaultInstanceDir = "."
const DefaultPackerDirName = "packer"
const DefaultProjectsDirName = "projects"
const DefaultTerraformDirName = "terraform"
const DeploymentsConfigKey = "deployments"
const ImagesConfigKey = "images"
const PackerConfigKey = "packer"
const TerraformConfigKey = "terraform"
const TerraformProjectConfigKey = "projects"
func Get(s string) any
func ImagesDir() string
func Keys() []string
func LogLevel(level slog.Level)
func Logger() *slog.Logger
func PackerDir() string
func ProjectsDir() string
func Set(s string, v any) any
func SetProvidersTypes(p []string)
func Time(what string) func()
func WithGroup(groupName string) *slog.Logger
type CarbonConfig struct {
Dir map[string]string `yaml:"dir"`
Providers map[string]ProviderConfig `yaml:"providers"`
}
func (cc *CarbonConfig) Get(search []string) any
func (cc *CarbonConfig) Keys(prefix string) []string
func (cc *CarbonConfig) Set(search []string, val any) *CarbonConfig
type CarbonConfigFile struct {
Carbon CarbonConfig `yaml:"carbon"`
}
func GetConfig() *CarbonConfigFile
func (cf *CarbonConfigFile) Get(search []string) any
func (cf *CarbonConfigFile) Keys() []string
func (cf *CarbonConfigFile) MergeInConfigFile(cfgFile string) error
func (cf *CarbonConfigFile) Set(search []string, val any) *CarbonConfigFile
type ProfileConfig struct {
Enabled bool `yaml:"enabled"`
Username string `yaml:"username" `
Password string `yaml:"password" `
PasswordCommand string `yaml:"password_command"`
Use1PassCLI bool `yaml:"use_1pass_cli" `
URL string `yaml:"url"`
Environments map[string]bool `yaml:"environments"`
}
func DefaultProfileConfig() ProfileConfig
func (pc *ProfileConfig) Get(search []string) any
func (pc *ProfileConfig) GetPassword() string
func (pc *ProfileConfig) Keys(prefix string) []string
func (pc *ProfileConfig) Set(search []string, val any) *ProfileConfig
func (pc *ProfileConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
type ProviderConfig struct {
Enabled bool `yaml:"enabled"`
AutoDiscover bool `yaml:"auto_discover"`
Profiles map[string]ProfileConfig `yaml:"profiles"`
}
func DefaultProviderConfig() ProviderConfig
func (pc *ProviderConfig) Get(search []string) any
func (pc *ProviderConfig) Keys(prefix string) []string
func (pc *ProviderConfig) Set(search []string, val any) *ProviderConfig
func (pc *ProviderConfig) UnmarshalYAML(unmarshal func(interface{}) error) error
import "github.com/analog-substance/carbon/pkg/models"
func GetImageBuildsForProvider(provider string) ([]types.ImageBuild, error)
func NewImage(imageID string, imageName string, createdAt time.Time, env types.Environment) types.Image
type BuildBlock struct {
Name string `hcl:"name,optional"`
Description string `hcl:"description,optional"`
FromSources []string `hcl:"sources,optional"`
Config hcl.Body `hcl:",remain"`
}
type Image struct {
// contains filtered or unexported fields
}
func (i *Image) CreatedAt() string
func (i *Image) Destroy() error
func (i *Image) Environment() types.Environment
func (i *Image) ID() string
func (i *Image) Launch(imageLaunchOptions types.ImageLaunchOptions) error
func (i *Image) MarshalJSON() ([]byte, error)
func (i *Image) Name() string
func (i *Image) Profile() types.Profile
func (i *Image) Provider() types.Provider
type ImageBuild struct {
// contains filtered or unexported fields
}
func NewImageBuild(buildPath, provider, provisioner string) *ImageBuild
func (b *ImageBuild) Build() error
func (b *ImageBuild) MarshalJSON() ([]byte, error)
func (b *ImageBuild) Name() string
func (b *ImageBuild) ProviderType() string
func (b *ImageBuild) Provisioner() string
type Machine struct {
InstanceName string `json:"name"`
InstanceID string `json:"id"`
CurrentUpTime time.Duration `json:"up_time"`
InstanceType string `json:"type"`
PublicIPAddresses []string `json:"public_ip_addresses"`
PrivateIPAddresses []string `json:"private_ip_addresses"`
CurrentState types.MachineState `json:"current_state"`
Env types.Environment `json:"-"`
}
func (m *Machine) Cmd(user string, privateIP bool, cmdArgs ...string) (string, error)
func (m *Machine) Destroy() error
func (m *Machine) Environment() types.Environment
func (m *Machine) ExecSSH(user string, privateIP bool, cmdArgs ...string) error
func (m *Machine) ID() string
func (m *Machine) IPAddress() string
func (m *Machine) Name() string
func (m *Machine) NewSSHSession(user string, privateIP bool) (*ssh_util.Session, error)
func (m *Machine) PrivateIPAddress() string
func (m *Machine) Profile() types.Profile
func (m *Machine) Provider() types.Provider
func (m *Machine) Restart() error
func (m *Machine) Start() error
func (m *Machine) StartRDPClient(user string, privateIP bool) error
func (m *Machine) StartVNC(user string, privateIP bool, killVNC bool) error
StartVNC will create a VNC session on the virtual machine It accomplishes this by:
Requires TigerVNC to be installed.
func (m *Machine) State() string
func (m *Machine) Stop() error
func (m *Machine) Type() string
func (m *Machine) UpTime() time.Duration
type PackerConfig struct {
Source SourceBlock `hcl:"source,block"`
Build BuildBlock `hcl:"build,block"`
}
type Project struct {
// contains filtered or unexported fields
}
func NewProject(buildPath string) *Project
func (d *Project) AddMachine(machine *types.ProjectMachine, noApply bool) error
func (d *Project) GetConfig() (*types.ProjectConfig, error)
func (d *Project) MarshalJSON() ([]byte, error)
func (d *Project) Name() string
func (d *Project) SaveConfig() error
func (d *Project) TerraformApply() error
type SourceBlock struct {
Type string `hcl:"type,label"`
Name string `hcl:"name,label"`
Config hcl.Body `hcl:",remain"`
}
import "github.com/analog-substance/carbon/pkg/providers/aws"
Package aws handles communications with AWS APIs
func New() types.Provider
New creates new instance of an AWS Provider and returns it. Defaults to no awsProfileNames, this forces a query of the AWS config at runtime.
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) AWSProfiles() []string
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/base"
const CloudInitDir = "cloud-init"
const ISOVarUsage = "var.iso_url"
const PackerFileIsoVars = "iso-variables.pkr.hcl"
const PackerFileLocalVars = "local-variables.pkr.hcl"
const PackerFilePacker = "packer.pkr.hcl"
const PackerFilePrivateVarsExample = "private.auto.pkrvars.hcl.example"
const PackerFileSuffixAnsible = "-ansible.pkr.hcl"
const PackerFileSuffixCloudInit = "-cloud-init.pkr.hcl"
const PackerFileSuffixVariables = "-variables.pkr.hcl"
func DestroyImageForFileBasedProvider(imageID string) error
func GetImagesForFileBasedProvider(providerType string, e types.Environment) ([]types.Image, error)
func New() types.Provider
func NewProfile(name string, providerInstance types.Provider, config common.ProfileConfig) types.Profile
func NewWithName(name string) types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type ImageBuildDate struct {
Name string
}
type Profile struct {
// contains filtered or unexported fields
}
func (p *Profile) Environments() []types.Environment
func (p *Profile) GetConfig() common.ProfileConfig
func (p *Profile) Name() string
func (p *Profile) Provider() types.Provider
func (p *Profile) SetConfig(config common.ProfileConfig)
func (p *Profile) ShouldIncludeEnvironment(envName string) bool
type Provider struct {
// contains filtered or unexported fields
}
func (p *Provider) GetConfig() common.ProviderConfig
func (p *Provider) IsAvailable() bool
func (p *Provider) Name() string
func (p *Provider) NewImageBuild(name, tplDir string) (types.ImageBuild, error)
func (p *Provider) NewProject(name string, force bool) (types.Project, error)
func (p *Provider) Profiles() []types.Profile
func (p *Provider) SetConfig(config common.ProviderConfig)
func (p *Provider) Type() string
import "github.com/analog-substance/carbon/pkg/providers/digitalocean"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
// contains filtered or unexported fields
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/example"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/multipass"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/multipass/api"
func AppPath() string
func RestartVM(id string) error
func SleepVM(id string) error
func StartVM(id string) error
type MultipassListOutput struct {
List []MultipassVM `json:"list"`
}
type MultipassVM struct {
Ipv4 []string `json:"ipv4"`
Name string `json:"name"`
Release string `json:"release"`
State string `json:"state"`
}
func ListVMs() []MultipassVM
import "github.com/analog-substance/carbon/pkg/providers/qemu"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/qemu/api"
type Domain struct {
LVDomain *libvirt.Domain
LVDomainState *libvirt.DomainState
ID string
Name string
PublicIPAddresses []string
PrivateIPAddresses []string
CurrentUpTime time.Duration
// contains filtered or unexported fields
}
func (d *Domain) Destroy() error
func (d *Domain) Reboot() error
func (d *Domain) Start() error
func (d *Domain) Suspend() error
type QEMU struct {
// contains filtered or unexported fields
}
func Connect(libVirtURL string) (*QEMU, error)
func (q *QEMU) AllNetworks() ([]libvirt.Network, error)
func (q *QEMU) Close() error
func (q *QEMU) CreateDomain(name string, storageVol *StorageVolume) (*Domain, error)
func (q *QEMU) GetDomain(id string) (*Domain, error)
func (q *QEMU) GetDomains() ([]*Domain, error)
func (q *QEMU) GetStoragePool(name string) (*StoragePool, error)
func (q *QEMU) GetStoragePools() ([]*StoragePool, error)
type StoragePool struct {
LVStoragePool *libvirt.StoragePool
Volumes []*StorageVolume
// contains filtered or unexported fields
}
func (s *StoragePool) GetVolumes() ([]*StorageVolume, error)
func (s *StoragePool) ImportImage(name string, imageFile string) (*StorageVolume, error)
type StorageVolume struct {
LVStorageVolume *libvirt.StorageVol
// contains filtered or unexported fields
}
import "github.com/analog-substance/carbon/pkg/providers/virtualbox"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/providers/virtualbox/api"
func AppPath() string
func RestartVM(id string) error
func SleepVM(id string) error
func StartVM(id string) error
type VBoxVM struct {
Name string
ID string
State string
GuestOS string
UpTime time.Duration
PrivateIPAddresses []string
// contains filtered or unexported fields
}
func ListVMs() []VBoxVM
import "github.com/analog-substance/carbon/pkg/providers/vsphere"
func New() types.Provider
type Environment struct {
// contains filtered or unexported fields
}
func (e *Environment) CreateVM(options types.MachineLaunchOptions) error
func (e *Environment) DestroyImage(imageID string) error
func (e *Environment) DestroyVM(id string) error
func (e *Environment) ImageBuilds() ([]types.ImageBuild, error)
func (e *Environment) Images() ([]types.Image, error)
func (e *Environment) Name() string
func (e *Environment) Profile() types.Profile
func (e *Environment) RestartVM(id string) error
func (e *Environment) StartVM(id string) error
func (e *Environment) StopVM(id string) error
func (e *Environment) VMs() []types.VM
type Profile struct {
types.Profile
// contains filtered or unexported fields
}
func NewProfile(name string, providerInstance *Provider, config common.ProfileConfig) *Profile
func (p *Profile) Environments() []types.Environment
type Provider struct {
types.Provider
// contains filtered or unexported fields
}
func (p *Provider) IsAvailable() bool
func (p *Provider) Profiles() []types.Profile
import "github.com/analog-substance/carbon/pkg/rdp_client"
func Start(options Options) error
func StartRDPClient(options Options) error
type Options struct {
Delay int
User string
Host string
}
import "github.com/analog-substance/carbon/pkg/ssh_util"
type Session struct {
Session *ssh.Session
Client *ssh.Client
// contains filtered or unexported fields
}
func NewSession() (*Session, error)
func (session *Session) ClientConfig(user string) *ssh.ClientConfig
func (session *Session) Close()
func (session *Session) Connect(serverAddr, user string) error
func (session *Session) ForwardAgent() error
func (session *Session) ForwardLocalPort(localPort, remotePort int) error
func (session *Session) Output(cmd string) (string, error)
Output uses ssh_util.Session to run cmd on the remote host and returns its standard output.
import "github.com/analog-substance/carbon/pkg/types"
var StateRunning = MachineState{"Running"}
var StateSleeping = MachineState{"Sleeping"}
var StateStarting = MachineState{"Starting"}
var StateStopped = MachineState{"Stopped"}
var StateStopping = MachineState{"Stopping"}
var StateTerminated = MachineState{"Terminated"}
var StateTerminating = MachineState{"Terminating"}
var StateUnknown = MachineState{"Unknown"}
type Environment interface {
Name() string
VMs() []VM
Profile() Profile
StartVM(string) error
StopVM(string) error
RestartVM(string) error
ImageBuilds() ([]ImageBuild, error)
Images() ([]Image, error)
CreateVM(MachineLaunchOptions) error
DestroyVM(string) error
DestroyImage(string) error
}
type Image interface {
ID() string
Name() string
CreatedAt() string
Environment() Environment
Profile() Profile
Provider() Provider
Launch(imageLaunchOptions ImageLaunchOptions) error
Destroy() error
}
type ImageBuild interface {
Name() string
ProviderType() string
Provisioner() string
Build() error
}
type ImageLaunchOptions struct {
Name string
}
type MachineLaunchOptions struct {
CloudInitTpl string `json:"cloud-init"`
Image Image `json:"image"`
Name string `json:"name"`
}
type MachineState struct {
Name string `json:"name"`
}
type Profile interface {
Environments() []Environment
Name() string
Provider() Provider
SetConfig(config common.ProfileConfig)
GetConfig() common.ProfileConfig
ShouldIncludeEnvironment(envName string) bool
}
type Project interface {
Name() string
TerraformApply() error
AddMachine(machine *ProjectMachine, noApply bool) error
}
type ProjectConfig struct {
Machines []*ProjectMachine `yaml:"machines"`
}
type ProjectMachine struct {
Name string `yaml:"name"`
Image string `yaml:"image,omitempty"`
Type string `yaml:"type,omitempty"`
Profile string `yaml:"profile,omitempty"`
Purpose string `yaml:"purpose,omitempty"`
VolumeSize int `yaml:"volume_size,omitempty"`
Provider string `yaml:"provider,omitempty"`
}
type Provider interface {
Profiles() []Profile
Name() string
Type() string
IsAvailable() bool
SetConfig(config common.ProviderConfig)
GetConfig() common.ProviderConfig
NewImageBuild(name string, tplDir string) (ImageBuild, error)
NewProject(name string, force bool) (Project, error)
}
VM interface provides access to useful information and actions related to Virtual Machines
type VM interface {
// Name returns the name of a virtual machine
Name() string
// ID returns the ID of the virtual machine
ID() string
// IPAddress returns the public IP address of the virtual machine
IPAddress() string
// PrivateIPAddress of the virtual machine
PrivateIPAddress() string
UpTime() time.Duration
State() string
Type() string
Environment() Environment
Profile() Profile
Provider() Provider
Destroy() error
Start() error
Stop() error
Restart() error
ExecSSH(string, bool, ...string) error
StartVNC(user string, privateIP bool, killVNC bool) error
StartRDPClient(user string, privateIP bool) error
Cmd(string, bool, ...string) (string, error)
NewSSHSession(string, bool) (*ssh_util.Session, error)
}
import "github.com/analog-substance/carbon/pkg/vnc_viewer"
func Start(options Options) error
func StartViewer(options Options) error
type Options struct {
Delay int
PasswordFile string
Host string
}