Documentation ¶
Index ¶
- Constants
- Variables
- func BackupNfs(password, ip string, dest io.Writer) (err error)
- func ExtractEncryptionKey(dest io.Writer, deploymentDir string) (err error)
- func GetDeploymentName(jsonObj InstallationCompareObject) (deploymentName string, err error)
- func GetPasswordAndIP(jsonObj InstallationCompareObject, product, component, username string) (ip, password string, err error)
- func RunBackupPipeline(hostname, username, password, tempestpassword, destination string) (err error)
- func RunRestorePipeline(hostname, username, password, tempestpassword, destination string) (err error)
- func SetLogger(logger log.Logger)
- type BackupContext
- type CCJob
- type CloudController
- type CloudControllerDeploymentParser
- type CloudControllerJobs
- type ElasticRuntime
- type InstallationCompareObject
- type IpPasswordParser
- type MysqlInfo
- type NFSBackup
- type NfsInfo
- type OpsManager
- type PersistanceBackup
- type PgInfo
- type SystemDump
- type SystemInfo
- type Tile
- type VMObject
Constants ¶
const ( BACKUP_LOGGER_NAME = "Backup" RESTORE_LOGGER_NAME = "Restore" )
const ( ER_DEFAULT_SYSTEM_USER = "vcap" ER_DIRECTOR_INFO_URL = "https://%s:25555/info" ER_BACKUP_DIR = "elasticruntime" ER_VMS_URL = "https://%s:25555/deployments/%s/vms" ER_DIRECTOR = "DirectorInfo" ER_CONSOLE = "ConsoledbInfo" ER_UAA = "UaadbInfo" ER_CC = "CcdbInfo" ER_MYSQL = "MysqldbInfo" ER_NFS = "NfsInfo" ER_BACKUP_FILE_FORMAT = "%s.backup" ER_INVALID_DIRECTOR_CREDS_MSG = "invalid director credentials" ER_NO_PERSISTENCE_ARCHIVES = "there are no persistence stores in the list" ER_FILE_DOES_NOT_EXIST = "file does not exist" ER_DB_BACKUP_FAILURE = "failed to backup database" )
const ( IMPORT_ARCHIVE = iota EXPORT_ARCHIVE )
const ( NFS_DIR_PATH string = "/var/vcap/store" NFS_ARCHIVE_DIR string = "shared" NFS_DEFAULT_SSH_USER string = "vcap" )
const ( OPSMGR_INSTALLATION_SETTINGS_FILENAME string = "installation.json" OPSMGR_INSTALLATION_SETTINGS_POSTFIELD_NAME string = "installation[file]" OPSMGR_INSTALLATION_ASSETS_FILENAME string = "installation.zip" OPSMGR_INSTALLATION_ASSETS_POSTFIELD_NAME string = "installation[file]" OPSMGR_DEPLOYMENTS_FILENAME string = "deployments.tar.gz" OPSMGR_ENCRYPTIONKEY_FILENAME string = "cc_db_encryption_key.txt" OPSMGR_BACKUP_DIR string = "opsmanager" OPSMGR_DEPLOYMENTS_DIR string = "deployments" OPSMGR_DEFAULT_USER string = "tempest" OPSMGR_INSTALLATION_SETTINGS_URL string = "https://%s/api/installation_settings" OPSMGR_INSTALLATION_ASSETS_URL string = "https://%s/api/installation_asset_collection" OPSMGR_DEPLOYMENTS_FILE string = "/var/tempest/workspaces/default/deployments/bosh-deployments.yml" )
Variables ¶
var ( TILE_RESTORE_ACTION = func(t Tile) func() error { return t.Restore } TILE_BACKUP_ACTION = func(t Tile) func() error { return t.Backup } )
var ( ER_ERROR_DIRECTOR_CREDS = errors.New(ER_INVALID_DIRECTOR_CREDS_MSG) ER_ERROR_EMPTY_DB_LIST = errors.New(ER_NO_PERSISTENCE_ARCHIVES) ER_ERROR_INVALID_PATH = &os.PathError{Err: errors.New(ER_FILE_DOES_NOT_EXIST)} ER_DB_BACKUP = errors.New(ER_DB_BACKUP_FAILURE) )
var NewDirector = func(ip, username, password string, port int) bosh.Bosh { return bosh.NewBoshDirector(ip, username, password, port, NewHttpGateway()) }
var NewElasticRuntime = func(jsonFile string, target string, logger log.Logger) *ElasticRuntime { var ( uaadbInfo *PgInfo = &PgInfo{ SystemInfo: SystemInfo{ Product: "cf", Component: "uaadb", Identity: "root", }, Database: "uaa", } consoledbInfo *PgInfo = &PgInfo{ SystemInfo: SystemInfo{ Product: "cf", Component: "consoledb", Identity: "root", }, Database: "console", } ccdbInfo *PgInfo = &PgInfo{ SystemInfo: SystemInfo{ Product: "cf", Component: "ccdb", Identity: "admin", }, Database: "ccdb", } mysqldbInfo *MysqlInfo = &MysqlInfo{ SystemInfo: SystemInfo{ Product: "cf", Component: "mysql", Identity: "root", }, Database: "mysql", } directorInfo *SystemInfo = &SystemInfo{ Product: "microbosh", Component: "director", Identity: "director", } nfsInfo *NfsInfo = &NfsInfo{ SystemInfo: SystemInfo{ Product: "cf", Component: "nfs_server", Identity: "vcap", }, } ) context := &ElasticRuntime{ JsonFile: jsonFile, BackupContext: BackupContext{ TargetDir: target, }, SystemsInfo: map[string]SystemDump{ ER_DIRECTOR: directorInfo, ER_CONSOLE: consoledbInfo, ER_UAA: uaadbInfo, ER_CC: ccdbInfo, ER_MYSQL: mysqldbInfo, ER_NFS: nfsInfo, }, PersistentSystems: []SystemDump{ consoledbInfo, uaadbInfo, ccdbInfo, nfsInfo, mysqldbInfo, }, Logger: logger, } return context }
NewElasticRuntime initializes an ElasticRuntime intance
var NewOpsManager = func(hostname string, username string, password string, tempestpassword string, target string, logger log.Logger) (context *OpsManager, err error) { var remoteExecuter command.Executer if remoteExecuter, err = createExecuter(hostname, tempestpassword); err == nil { settingsHttpRequestor := ghttp.NewHttpGateway() settingsMultiHttpRequestor := ghttp.MultiPartUpload assetsHttpRequestor := ghttp.NewHttpGateway() assetsMultiHttpRequestor := ghttp.MultiPartUpload context = &OpsManager{ SettingsUploader: settingsMultiHttpRequestor, AssetsUploader: assetsMultiHttpRequestor, SettingsRequestor: settingsHttpRequestor, AssetsRequestor: assetsHttpRequestor, DeploymentDir: path.Join(target, OPSMGR_BACKUP_DIR, OPSMGR_DEPLOYMENTS_DIR), Hostname: hostname, Username: username, Password: password, BackupContext: BackupContext{ TargetDir: target, }, Executer: remoteExecuter, LocalExecuter: command.NewLocalExecuter(), OpsmanagerBackupDir: OPSMGR_BACKUP_DIR, Logger: logger, } } return }
NewOpsManager initializes an OpsManager instance
var NfsNewRemoteExecuter func(command.SshConfig) (command.Executer, error) = command.NewRemoteExecutor
var RunPipeline = func(actionBuilder func(Tile) func() error, tiles []Tile) (err error) { var pipeline []action for _, tile := range tiles { pipeline = append(pipeline, actionBuilder(tile)) } err = runActions(pipeline) return }
Runs a pipeline action (restore/backup) on a list of tiles
var TaskPingFreq time.Duration = 1000 * time.Millisecond
Not ping server so frequently and exausted the resources
Functions ¶
func ExtractEncryptionKey ¶
func GetDeploymentName ¶
func GetDeploymentName(jsonObj InstallationCompareObject) (deploymentName string, err error)
func GetPasswordAndIP ¶
func GetPasswordAndIP(jsonObj InstallationCompareObject, product, component, username string) (ip, password string, err error)
func RunBackupPipeline ¶
func RunBackupPipeline(hostname, username, password, tempestpassword, destination string) (err error)
Backup the list of all default tiles
func RunRestorePipeline ¶
func RunRestorePipeline(hostname, username, password, tempestpassword, destination string) (err error)
Restore the list of all default tiles
Types ¶
type BackupContext ¶
type BackupContext struct {
TargetDir string
}
type CloudController ¶
type CloudController struct {
// contains filtered or unexported fields
}
func NewCloudController ¶
func NewCloudController(ip, username, password, deploymentName, manifest string, cloudControllers CloudControllerJobs) *CloudController
func (*CloudController) Start ¶
func (c *CloudController) Start() error
func (*CloudController) Stop ¶
func (c *CloudController) Stop() error
type CloudControllerDeploymentParser ¶
type CloudControllerDeploymentParser struct {
// contains filtered or unexported fields
}
type CloudControllerJobs ¶
type CloudControllerJobs []CCJob
type ElasticRuntime ¶
type ElasticRuntime struct { JsonFile string SystemsInfo map[string]SystemDump PersistentSystems []SystemDump HttpGateway HttpGateway InstallationName string BackupContext Logger log.Logger }
ElasticRuntime contains information about a Pivotal Elastic Runtime deployment
func (*ElasticRuntime) Backup ¶
func (context *ElasticRuntime) Backup() (err error)
Backup performs a backup of a Pivotal Elastic Runtime deployment
func (*ElasticRuntime) ReadAllUserCredentials ¶
func (context *ElasticRuntime) ReadAllUserCredentials() (err error)
func (*ElasticRuntime) Restore ¶
func (context *ElasticRuntime) Restore() (err error)
Restore performs a restore of a Pivotal Elastic Runtime deployment
func (*ElasticRuntime) RunDbAction ¶
func (context *ElasticRuntime) RunDbAction(dbInfoList []SystemDump, action int) (err error)
type InstallationCompareObject ¶
type InstallationCompareObject struct { Guid string Installation_Version string Products []productCompareObject Infrastructure infrastructure }
func ReadAndUnmarshal ¶
func ReadAndUnmarshal(src io.Reader) (jsonObj InstallationCompareObject, err error)
type IpPasswordParser ¶
type IpPasswordParser struct { Product string Component string Username string // contains filtered or unexported fields }
func (*IpPasswordParser) Parse ¶
func (s *IpPasswordParser) Parse(jsonObj InstallationCompareObject) (ip, password string, err error)
type MysqlInfo ¶
type MysqlInfo struct { SystemInfo Database string }
func (*MysqlInfo) GetPersistanceBackup ¶
func (s *MysqlInfo) GetPersistanceBackup() (dumper PersistanceBackup, err error)
type NFSBackup ¶
func NewNFSBackup ¶
type NfsInfo ¶
type NfsInfo struct {
SystemInfo
}
func (*NfsInfo) GetPersistanceBackup ¶
func (s *NfsInfo) GetPersistanceBackup() (dumper PersistanceBackup, err error)
type OpsManager ¶
type OpsManager struct { BackupContext Hostname string Username string Password string TempestPassword string DbEncryptionKey string Executer command.Executer LocalExecuter command.Executer SettingsUploader httpUploader AssetsUploader httpUploader SettingsRequestor httpRequestor AssetsRequestor httpRequestor DeploymentDir string OpsmanagerBackupDir string Logger log.Logger }
OpsManager contains the location and credentials of a Pivotal Ops Manager instance
func (*OpsManager) Backup ¶
func (context *OpsManager) Backup() (err error)
Backup performs a backup of a Pivotal Ops Manager instance
func (*OpsManager) Restore ¶
func (context *OpsManager) Restore() (err error)
Restore performs a restore of a Pivotal Ops Manager instance
type PersistanceBackup ¶
type PgInfo ¶
type PgInfo struct { SystemInfo Database string }
func (*PgInfo) GetPersistanceBackup ¶
func (s *PgInfo) GetPersistanceBackup() (dumper PersistanceBackup, err error)
type SystemDump ¶
type SystemDump interface { Error() error GetPersistanceBackup() (dumper PersistanceBackup, err error) // contains filtered or unexported methods }
type SystemInfo ¶
type SystemInfo struct { goutil.GetSet Product string Component string Identity string Ip string User string Pass string VcapUser string VcapPass string }
func (*SystemInfo) Error ¶
func (s *SystemInfo) Error() (err error)
func (*SystemInfo) Get ¶
func (s *SystemInfo) Get(name string) string
func (*SystemInfo) GetPersistanceBackup ¶
func (s *SystemInfo) GetPersistanceBackup() (dumper PersistanceBackup, err error)
func (*SystemInfo) Set ¶
func (s *SystemInfo) Set(name string, val string)