Exemple #1
0
func (a *RollbackSnapshotHandler) Run() error {
	req := &profitbricks.RollbackSnapshotRequest{
		StorageId:  a.StorageId,
		SnapshotId: a.SnapshotId,
	}
	return profitbricks.NewFromEnv().RollbackSnapshot(req)
}
Exemple #2
0
func (a *CreateStorage) Run() error {
	req := &profitbricks.CreateStorageRequest{
		DataCenterId: a.DataCenterId,
		StorageName:  a.Name,
		Size:         a.Size,
		MountImageId: a.MountImageId,
	}
	return profitbricks.NewFromEnv().CreateStorage(req)
}
Exemple #3
0
func CreateStorageHandler(args *gocli.Args) error {
	req := &profitbricks.CreateStorageRequest{
		DataCenterId: args.MustGetString(CLI_DATACENTER_ID),
		StorageName:  args.MustGetString(CLI_NAME),
		Size:         args.MustGetInt(CLI_SIZE),
		MountImageId: args.MustGetString(CLI_IMAGE_ID),
	}
	logger.Printf("creating storage with %#v", req)
	return profitbricks.NewFromEnv().CreateStorage(req)
}
Exemple #4
0
func ListAllDataCentersHandler() error {
	dcs, e := profitbricks.NewFromEnv().GetAllDataCenters()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Id", "Name", "Version")
	for _, dc := range dcs {
		table.Add(dc.DataCenterId, dc.DataCenterName, dc.DataCenterVersion)
	}
	fmt.Println(table)
	return nil
}
Exemple #5
0
func (a *CreateServer) Run() error {
	req := &profitbricks.CreateServerRequest{
		DataCenterId:    a.DataCenterId,
		ServerName:      a.Name,
		Ram:             a.Ram,
		Cores:           a.Cores,
		OsType:          a.OsType,
		InternetAccess:  a.InternetAccess,
		LanId:           a.LanId,
		BootFromImageId: a.ImageId,
	}
	return profitbricks.NewFromEnv().CreateServer(req)
}
Exemple #6
0
func ListAllStorages() error {
	client := profitbricks.NewFromEnv()
	storages, e := client.GetAllStorages()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Id", "Name", "ProvisioningState", "Servers", "Image Name", "Image ID")
	for _, storage := range storages {
		table.Add(storage.StorageId, storage.StorageName, storage.ProvisioningState, strings.Join(storage.ServerIds, ","), storage.ImageName, storage.ImageId)
	}
	fmt.Println(table)
	return nil
}
Exemple #7
0
func ListAllServersHandler() error {
	client := profitbricks.NewFromEnv()
	servers, e := client.GetAllServers()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Id", "Name", "ProvisioningState", "VmState", "Ips", "Lans")
	for _, server := range servers {
		table.Add(server.ServerId, server.ServerName, server.ProvisioningState, server.VirtualMachineState, strings.Join(server.Ips, ","), server.Lans())
	}
	fmt.Println(table)
	return nil
}
Exemple #8
0
func ListAllImagesHandler() error {
	client := profitbricks.NewFromEnv()
	images, e := client.GetAllImages()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Id", "Type", "Region", "Name", "Size")
	for _, img := range images {
		table.Add(img.ImageId, img.ImageType, img.Region, img.ImageName, img.ImageSize)
	}
	fmt.Println(table)
	return nil
}
Exemple #9
0
func ListAllSnapshotsHandler() error {
	client := profitbricks.NewFromEnv()
	snapshots, e := client.GetAllSnapshots()
	if e != nil {
		return e
	}
	table := gocli.NewTable()
	table.Add("Id", "OsType", "Name", "Size", "State")
	for _, snapshot := range snapshots {
		table.Add(snapshot.SnapshotId, snapshot.OsType, snapshot.SnapshotName, snapshot.SnapshotSize, snapshot.ProvisioningState)
	}
	fmt.Println(table)
	return nil
}
Exemple #10
0
func (a *DescribeDataCenterHandler) Run() error {
	client := profitbricks.NewFromEnv()
	dc, e := client.GetDataCenter(a.DataCenterId)
	if e != nil {
		return e
	}

	table := gocli.NewTable()
	table.Add("Id", dc.DataCenterId)
	table.Add("Name", dc.DataCenterName)
	table.Add("Region", dc.Region)
	table.Add("State", dc.ProvisioningState)
	table.Add("Version", dc.DataCenterVersion)
	fmt.Println(table)
	fmt.Println("\nServers:")
	if len(dc.Servers) > 0 {
		table = gocli.NewTable()
		table.Add("Id", "Created", "Name", "Lans", "Ip", "AZ", "ProvState", "VMState", "Ram", "Cores", "Internet")
		for _, server := range dc.Servers {
			table.Add(server.ServerId, server.CreationTime.Format("2006-01-02T15:04"), server.ServerName, server.Lans(), strings.Join(server.Ips, ","), server.AvailabilityZone, server.ProvisioningState, server.VirtualMachineState, server.Ram, server.Cores, server.InternetAccess)
		}
		fmt.Println(table)
	} else {
		fmt.Println("* None *")
	}

	fmt.Println("\nStorages:")
	if len(dc.Storages) > 0 {
		table = gocli.NewTable()
		table.Add("Id", "Name", "Size")
		for _, storage := range dc.Storages {
			table.Add(storage.StorageId, storage.StorageName, storage.Size)
		}
		fmt.Println(table)
	} else {
		fmt.Println("* None *")
	}
	return nil
}
Exemple #11
0
func (a *StartServer) Run() error {
	return profitbricks.NewFromEnv().StartServer(a.Id)
}
Exemple #12
0
func (a *DeleteServer) Run() error {
	return profitbricks.NewFromEnv().DeleteServer(a.Id)
}
Exemple #13
0
func StartServerHandler(args *gocli.Args) error {
	return doSomething(args, profitbricks.NewFromEnv().StartServer)
}