Skip to content

Commit

Permalink
Update cluster post and get with enableTrusted
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveengostu authored and sakshiag committed Jun 18, 2018
1 parent e048da0 commit 2c17f72
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
2 changes: 2 additions & 0 deletions api/container/containerv1/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type ClusterInfo struct {
SpaceID string `json:"logSpace"`
SpaceName string `json:"logSpaceName"`
IsPaid bool `json:"isPaid"`
IsTrusted bool `json:"isTrusted"`
WorkerCount int `json:"workerCount"`
Vlans []Vlan `json:"vlans"`
Addons []Addon `json:"addons"`
Expand Down Expand Up @@ -120,6 +121,7 @@ type ClusterCreateRequest struct {
MasterVersion string `json:"masterVersion,omitempty" description:"Desired version of the requested master"`
Prefix string `json:"prefix,omitempty" description:"hostname prefix for new workers"`
DiskEncryption bool `json:"diskEncryption" description:"disable encryption on a worker"`
EnableTrusted bool `json:"enableTrusted" description:"Set to true if trusted hardware should be requested"`
}

// ServiceBindRequest ...
Expand Down
8 changes: 5 additions & 3 deletions api/container/containerv1/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var _ = Describe("Clusters", func() {
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/clusters"),
ghttp.VerifyJSON(`{"dataCenter":"dal10","isolation":"","machineType":"b2c.4x16","name":"testservice","privateVlan":"vlan","publicVlan":"vlan","workerNum":1,"noSubnet":false,"masterVersion":"1.8.1","prefix":"worker","diskEncryption": true}
ghttp.VerifyJSON(`{"dataCenter":"dal10","isolation":"","machineType":"b2c.4x16","name":"testservice","privateVlan":"vlan","publicVlan":"vlan","workerNum":1,"noSubnet":false,"masterVersion":"1.8.1","prefix":"worker","diskEncryption": true,"enableTrusted":true}
`),
ghttp.RespondWith(http.StatusCreated, `{
"id": "f91adfe2-76c9-4649-939e-b01c37a3704c"
Expand All @@ -38,7 +38,7 @@ var _ = Describe("Clusters", func() {

It("should return cluster created", func() {
params := ClusterCreateRequest{
Name: "testservice", Datacenter: "dal10", MachineType: "b2c.4x16", PublicVlan: "vlan", PrivateVlan: "vlan", MasterVersion: "1.8.1", Prefix: "worker", WorkerNum: 1, DiskEncryption: true,
Name: "testservice", Datacenter: "dal10", MachineType: "b2c.4x16", PublicVlan: "vlan", PrivateVlan: "vlan", MasterVersion: "1.8.1", Prefix: "worker", WorkerNum: 1, DiskEncryption: true, EnableTrusted: true,
}
target := ClusterTargetHeader{
OrgID: "abc",
Expand All @@ -57,7 +57,7 @@ var _ = Describe("Clusters", func() {
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPost, "/v1/clusters"),
ghttp.VerifyJSON(`{"dataCenter":"dal10","isolation":"","machineType":"free","name":"testservice","privateVlan":"vlan","publicVlan":"vlan","workerNum":1,"noSubnet":false,"masterVersion":"1.8.1","prefix":"worker","diskEncryption": false}
ghttp.VerifyJSON(`{"dataCenter":"dal10","isolation":"","machineType":"free","name":"testservice","privateVlan":"vlan","publicVlan":"vlan","workerNum":1,"noSubnet":false,"masterVersion":"1.8.1","prefix":"worker","diskEncryption": false,"enableTrusted":false}
`),
ghttp.RespondWith(http.StatusInternalServerError, `Failed to create cluster`),
),
Expand Down Expand Up @@ -102,6 +102,7 @@ var _ = Describe("Clusters", func() {
"ServerURL": "",
"State": "normal",
"IsPaid": false,
"IsTrusted": true,
"WorkerCount": 1
}]`),
),
Expand Down Expand Up @@ -215,6 +216,7 @@ var _ = Describe("Clusters", func() {
"ServerURL": "",
"State": "normal",
"IsPaid": false,
"IsTrusted": true,
"WorkerCount": 1,
"Vlans": [{
"ID": "177453",
Expand Down
41 changes: 17 additions & 24 deletions examples/container/create/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"log"
"os"

bluemix "github.com/IBM-Cloud/bluemix-go"
"github.com/IBM-Cloud/bluemix-go/session"

"github.com/IBM-Cloud/bluemix-go/api/account/accountv2"
Expand All @@ -16,6 +17,8 @@ import (

func main() {

c := new(bluemix.Config)

var org string
flag.StringVar(&org, "org", "", "Bluemix Organization")

Expand All @@ -26,39 +29,45 @@ func main() {
flag.StringVar(&zone, "zone", "", "Zone")

var privateVlan string
flag.StringVar(&privateVlan, "privateVlan", "", "Private Vlan")
flag.StringVar(&privateVlan, "privateVlan", "", "Zone Private Vlan")

var publicVlan string
flag.StringVar(&publicVlan, "publicVlan", "", "Public vlan")
flag.StringVar(&publicVlan, "publicVlan", "", "Zone Public vlan")

var updatePrivateVlan string
flag.StringVar(&updatePrivateVlan, "updatePrivateVlan", "", "Private vlan")
flag.StringVar(&updatePrivateVlan, "updatePrivateVlan", "", "Zone Private vlan to be updated")

var updatePublicVlan string
flag.StringVar(&updatePublicVlan, "updatePublicVlan", "", "Public vlan")
flag.StringVar(&updatePublicVlan, "updatePublicVlan", "", "Zone Public vlan to be updated")

var location string
flag.StringVar(&location, "location", "", "location")

var region string
flag.StringVar(&c.Region, "region", "us-south", "The Bluemix region. You can source it from env BM_REGION or BLUEMIX_REGION")

var skipDeletion bool
flag.BoolVar(&skipDeletion, "no-delete", false, "If provided will delete the resources created")

flag.Parse()

trace.Logger = trace.NewLogger("true")
if org == "" || space == "" || privateVlan == "" || publicVlan == "" || updatePrivateVlan == "" || updatePublicVlan == "" || zone == "" {
if org == "" || space == "" || privateVlan == "" || publicVlan == "" || updatePrivateVlan == "" || updatePublicVlan == "" || zone == "" || location == "" {
flag.Usage()
os.Exit(1)
}

var clusterInfo = v1.ClusterCreateRequest{
Name: "my_cluster",
Datacenter: "dal10",
Datacenter: location,
MachineType: "u2c.2x4",
WorkerNum: 1,
PrivateVlan: privateVlan,
PublicVlan: publicVlan,
Isolation: "public",
}

sess, err := session.New()
sess, err := session.New(c)
if err != nil {
log.Fatal(err)
}
Expand All @@ -69,7 +78,7 @@ func main() {
log.Fatal(err)
}

region := sess.Config.Region
region = sess.Config.Region
orgAPI := client.Organizations()
myorg, err := orgAPI.FindByName(org, region)

Expand Down Expand Up @@ -141,25 +150,9 @@ func main() {
log.Fatal(err)
}

err = workerPoolAPI.ResizeWorkerPool(out.ID, resp.ID, 3)
if err != nil {
log.Fatal(err)
}

pool, err := workerPoolAPI.GetWorkerPool(out.ID, resp.ID)
if err != nil {
log.Fatal(err)
}
fmt.Println("Pool id is ", pool.ID)

err = workerPoolAPI.RemoveZone(out.ID, zone, resp.ID)
if err != nil {
log.Fatal(err)
}

err = workerPoolAPI.DeleteWorkerPool(out.ID, resp.ID)
if err != nil {
log.Fatal(err)
}

}

0 comments on commit 2c17f72

Please sign in to comment.