Exemple #1
0
func (c *VaultCommand) doDeleteGlacierVault(config *aws.Config, name string) {
	c.UI.Info(fmt.Sprintf("Delete vault : %s", name))
	result, err := glacier.DeleteVault(
		glacier.GetGlacierClient(config), name)
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	log.Printf("[DEBUG] %s", awsutil.Prettify(result))
}
Exemple #2
0
func (c *VaultCommand) doDescribeGlacierVault(config *aws.Config, name string) {
	c.UI.Info(fmt.Sprintf("Describe vault %s :", name))
	vault, err := glacier.DescribeVault(
		glacier.GetGlacierClient(config), name)
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	log.Printf("[DEBUG] %s", awsutil.Prettify(vault))
	c.UI.Output(fmt.Sprintf("- %s %s [%d]",
		*vault.VaultName,
		*vault.CreationDate,
		*vault.NumberOfArchives))
}
Exemple #3
0
func (c *VaultCommand) doListGlacierVaults(config *aws.Config) {
	c.UI.Info("List Vaults :")
	result, err := glacier.ListVaults(glacier.GetGlacierClient(config))
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	log.Printf("[DEBUG] %s", awsutil.Prettify(result))
	for _, vault := range result.VaultList {
		c.UI.Output(fmt.Sprintf("- %s %s [%d]",
			*vault.VaultName,
			*vault.CreationDate,
			*vault.NumberOfArchives))
	}
}
Exemple #4
0
func (c *ArchiveCommand) doPutArchive(config *aws.Config, name string, key string, file string) {
	c.UI.Info(fmt.Sprintf("Upload archive %s : %s\n", key, file))
	data, err := ioutil.ReadFile(file)
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	result, err := glacier.UploadArchive(
		glacier.GetGlacierClient(config),
		name,
		data,
		key)
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	c.UI.Info(awsutil.Prettify(result))
}
Exemple #5
0
func (c *VaultCommand) doDisplayGlacierVault(config *aws.Config, name string) {
	c.UI.Info(fmt.Sprintf("Display vault inventory : %s", name))
	client := glacier.GetGlacierClient(config)
	job, err := glacier.DisplayVault(client, name)
	if err != nil {
		c.UI.Error(err.Error())
		return
	}
	log.Printf("[DEBUG] %s", awsutil.Prettify(job))
	statusCode := "InProgress"
	for statusCode == "InProgress" {
		desc, err := glacier.DescribeJob(client, name, *job.JobId)
		if err != nil {
			c.UI.Error(err.Error())
			return
		}
		log.Printf("[DEBUG] %s", awsutil.Prettify(desc))
		c.UI.Output(fmt.Sprintf("- %s ", *desc.StatusCode))
		time.Sleep(2000 * time.Millisecond)
	}
}