-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional information to DC list & get (#62)
- Loading branch information
Maksim Zhylinski
committed
Jul 21, 2016
1 parent
5fd2087
commit 9e9d3e2
Showing
7 changed files
with
438 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/centurylinkcloud/clc-go-cli/base" | ||
"github.com/centurylinkcloud/clc-go-cli/models/datacenter" | ||
) | ||
|
||
type DatacenterGet struct { | ||
CommandBase | ||
} | ||
|
||
func NewDatacenterGet(info CommandExcInfo) *DatacenterGet { | ||
dcGet := DatacenterGet{} | ||
dcGet.ExcInfo = info | ||
dcGet.Input = &datacenter.GetReq{} | ||
return &dcGet | ||
} | ||
|
||
func (dcGet *DatacenterGet) Execute(cn base.Connection) error { | ||
var err error | ||
|
||
input := dcGet.Input.(*datacenter.GetReq) | ||
dcGet.Output, err = datacenter.Get(cn, input.DataCenter, input.WithComputeLimits.Set, | ||
input.WithNetworkLimits.Set, input.WithAvailableOvfs.Set, input.WithLoadBalancers.Set) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package commands | ||
|
||
import ( | ||
"github.com/centurylinkcloud/clc-go-cli/base" | ||
"github.com/centurylinkcloud/clc-go-cli/models/datacenter" | ||
) | ||
|
||
type DatacenterList struct { | ||
CommandBase | ||
} | ||
|
||
func NewDatacenterList(info CommandExcInfo) *DatacenterList { | ||
dcList := DatacenterList{} | ||
dcList.ExcInfo = info | ||
dcList.Input = &datacenter.ListReq{} | ||
return &dcList | ||
} | ||
|
||
func (dcList *DatacenterList) Execute(cn base.Connection) error { | ||
var err error | ||
|
||
input := dcList.Input.(*datacenter.ListReq) | ||
dcList.Output, err = datacenter.All(cn, input.WithComputeLimits.Set, | ||
input.WithNetworkLimits.Set, input.WithAvailableOvfs.Set, input.WithLoadBalancers.Set) | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,54 @@ | ||
package datacenter | ||
|
||
import ( | ||
"fmt" | ||
"github.com/centurylinkcloud/clc-go-cli/base" | ||
"github.com/centurylinkcloud/clc-go-cli/models" | ||
) | ||
|
||
type GetReq struct { | ||
DataCenter string `valid:"required" URIParam:"yes"` | ||
GroupLinks string `valid:"required" URIParam:"yes"` | ||
DataCenter string `valid:"required"` | ||
WithComputeLimits base.NilField | ||
WithNetworkLimits base.NilField | ||
WithAvailableOvfs base.NilField | ||
WithLoadBalancers base.NilField | ||
} | ||
|
||
type GetRes struct { | ||
Id string | ||
Name string | ||
Links []models.LinkEntity | ||
Id string | ||
Name string | ||
ComputeLimits *DcComputeLimits `json:",omitempty"` | ||
NetworkLimits *DcNetworkLimits `json:",omitempty"` | ||
AvailableOVFs *[]DcAvailableOVF `json:",omitempty"` | ||
LoadBalancers *[]DcLoadBalancer `json:",omitempty"` | ||
Links models.Links | ||
} | ||
|
||
func (r *GetReq) Validate() error { | ||
if r.GroupLinks != "false" && r.GroupLinks != "true" { | ||
return fmt.Errorf("group-links value must be either true or false.") | ||
} | ||
return nil | ||
type DcComputeLimits struct { | ||
Cpu DcResourceLimit | ||
MemoryGB DcResourceLimit | ||
StorageGB DcResourceLimit | ||
} | ||
|
||
type DcNetworkLimits struct { | ||
Networks DcResourceLimit | ||
} | ||
|
||
type DcResourceLimit struct { | ||
Value int | ||
Inherited bool | ||
} | ||
|
||
type DcAvailableOVF struct { | ||
Id string | ||
Name string | ||
StorageSizeGB int | ||
CpuCount int | ||
MemorySizeMB int | ||
} | ||
|
||
type DcLoadBalancer struct { | ||
Name string | ||
Description string | ||
IpAddress string | ||
Status string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
package datacenter | ||
|
||
import ( | ||
"github.com/centurylinkcloud/clc-go-cli/models" | ||
"github.com/centurylinkcloud/clc-go-cli/base" | ||
) | ||
|
||
type ListReq struct{} | ||
|
||
type ListRes struct { | ||
Id string | ||
Name string | ||
Links []models.LinkEntity | ||
type ListReq struct { | ||
WithComputeLimits base.NilField | ||
WithNetworkLimits base.NilField | ||
WithAvailableOvfs base.NilField | ||
WithLoadBalancers base.NilField | ||
} | ||
|
||
type ListRes GetRes |
Oops, something went wrong.