You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ri...@apache.org on 2016/03/08 14:20:12 UTC
[39/50] [abbrv] brooklyn-client git commit: Add new Godeps
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_metadata/command_metadata.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_metadata/command_metadata.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_metadata/command_metadata.go
new file mode 100644
index 0000000..7f5c1b9
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_metadata/command_metadata.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package command_metadata
+
+import "github.com/codegangsta/cli"
+
+type CommandMetadata struct {
+ Name string
+ Aliases []string
+ ShortName string
+ Usage string
+ Description string
+ Flags []cli.Flag
+ SkipFlagParsing bool
+ TotalArgs int //Optional: number of required arguments to skip for flag verification
+ Operands []CommandMetadata
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_runner/runner.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_runner/runner.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_runner/runner.go
new file mode 100644
index 0000000..5fc86e5
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/command_runner/runner.go
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package command_runner
+
+import (
+ "github.com/apache/brooklyn-client/command_factory"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type Runner interface {
+ RunCmdByName(cmdName string, c *cli.Context) (err error)
+ RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) (err error)
+}
+
+type ConcreteRunner struct {
+ cmdFactory command_factory.Factory
+ scope scope.Scope
+}
+
+func NewRunner(scope scope.Scope, cmdFactory command_factory.Factory) (runner ConcreteRunner) {
+ runner.cmdFactory = cmdFactory
+ runner.scope = scope
+ return
+}
+
+func (runner ConcreteRunner) RunCmdByName(cmdName string, c *cli.Context) error {
+ cmd, err := runner.cmdFactory.GetByCmdName(cmdName)
+ if nil != err {
+ return err
+ }
+
+ cmd.Run(runner.scope, c)
+ return nil
+}
+
+func (runner ConcreteRunner) RunSubCmdByName(cmdName string, subCommand string, c *cli.Context) error {
+ cmd, err := runner.cmdFactory.GetBySubCmdName(cmdName, subCommand)
+ if nil != err {
+ return err
+ }
+
+ cmd.Run(runner.scope, c)
+ return nil
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/access.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/access.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/access.go
new file mode 100644
index 0000000..1ddef76
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/access.go
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/access_control"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type Access struct {
+ network *net.Network
+}
+
+func NewAccess(network *net.Network) (cmd *Access) {
+ cmd = new(Access)
+ cmd.network = network
+ return
+}
+
+func (cmd *Access) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "access",
+ Description: "Show access control",
+ Usage: "BROOKLYN_NAME access",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Access) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ access, err := access_control.Access(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println("Location Provisioning Allowed:", access.LocationProvisioningAllowed)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity-stream.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity-stream.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity-stream.go
new file mode 100644
index 0000000..38cec20
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity-stream.go
@@ -0,0 +1,149 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/activities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type ActivityStreamEnv struct {
+ network *net.Network
+}
+
+type ActivityStreamStderr struct {
+ network *net.Network
+}
+
+type ActivityStreamStdin struct {
+ network *net.Network
+}
+
+type ActivityStreamStdout struct {
+ network *net.Network
+}
+
+func NewActivityStreamEnv(network *net.Network) (cmd *ActivityStreamEnv) {
+ cmd = new(ActivityStreamEnv)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStderr(network *net.Network) (cmd *ActivityStreamStderr) {
+ cmd = new(ActivityStreamStderr)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStdin(network *net.Network) (cmd *ActivityStreamStdin) {
+ cmd = new(ActivityStreamStdin)
+ cmd.network = network
+ return
+}
+
+func NewActivityStreamStdout(network *net.Network) (cmd *ActivityStreamStdout) {
+ cmd = new(ActivityStreamStdout)
+ cmd.network = network
+ return
+}
+
+func (cmd *ActivityStreamEnv) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "env",
+ Description: "Show the ENV stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE env",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStderr) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stderr",
+ Description: "Show the STDERR stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stderr",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStdin) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stdin",
+ Description: "Show the STDIN stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE ] stdin",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamStdout) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stdout",
+ Description: "Show the STDOUT stream for a given activity",
+ Usage: "BROOKLYN_NAME ACTIVITY-SCOPE stdout",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *ActivityStreamEnv) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "env")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStderr) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stderr")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStdin) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdin")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
+
+func (cmd *ActivityStreamStdout) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activityStream, err := activities.ActivityStream(cmd.network, scope.Activity, "stdout")
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(activityStream)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity.go
new file mode 100644
index 0000000..cee097b
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/activity.go
@@ -0,0 +1,162 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/activities"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "sort"
+ "strconv"
+ "strings"
+ "time"
+)
+
+type Activity struct {
+ network *net.Network
+}
+
+func NewActivity(network *net.Network) (cmd *Activity) {
+ cmd = new(Activity)
+ cmd.network = network
+ return
+}
+
+func (cmd *Activity) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "activity",
+ Aliases: []string{"activities", "act", "acts"},
+ Description: "Show the activity for an application / entity",
+ Usage: "BROOKLYN_NAME SCOPE activity [ ACTIVITYID]",
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "children, c",
+ Usage: "List children of the activity",
+ },
+ },
+ }
+}
+
+func (cmd *Activity) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
+ cmd.listchildren(c.StringSlice("children")[0])
+ } else {
+ if c.Args().Present() {
+ cmd.show(c.Args().First())
+ } else {
+ if scope.Activity == "" {
+ cmd.list(scope.Application, scope.Entity)
+ } else {
+ cmd.listchildren(scope.Activity)
+ }
+ }
+ }
+}
+
+func (cmd *Activity) show(activityId string) {
+ activity, err := activities.Activity(cmd.network, activityId)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+
+ table := terminal.NewTable([]string{"Id:", activity.Id})
+ table.Add("DisplayName:", activity.DisplayName)
+ table.Add("Description:", activity.Description)
+ table.Add("EntityId:", activity.EntityId)
+ table.Add("EntityDisplayName:", activity.EntityDisplayName)
+ table.Add("Submitted:", time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("Started:", time.Unix(activity.StartTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("Ended:", time.Unix(activity.EndTimeUtc/1000, 0).Format(time.UnixDate))
+ table.Add("CurrentStatus:", activity.CurrentStatus)
+ table.Add("IsError:", strconv.FormatBool(activity.IsError))
+ table.Add("IsCancelled:", strconv.FormatBool(activity.IsCancelled))
+ table.Add("SubmittedByTask:", activity.SubmittedByTask.Metadata.Id)
+ if activity.Streams["stdin"].Metadata.Size > 0 ||
+ activity.Streams["stdout"].Metadata.Size > 0 ||
+ activity.Streams["stderr"].Metadata.Size > 0 ||
+ activity.Streams["env"].Metadata.Size > 0 {
+ table.Add("Streams:", fmt.Sprintf("stdin: %d, stdout: %d, stderr: %d, env %d",
+ activity.Streams["stdin"].Metadata.Size,
+ activity.Streams["stdout"].Metadata.Size,
+ activity.Streams["stderr"].Metadata.Size,
+ activity.Streams["env"].Metadata.Size))
+ } else {
+ table.Add("Streams:", "")
+ }
+ table.Add("DetailedStatus:", fmt.Sprintf("\"%s\"", activity.DetailedStatus))
+ table.Print()
+}
+
+func (cmd *Activity) list(application, entity string) {
+ activityList, err := entities.GetActivities(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
+ for _, activity := range activityList {
+ table.Add(activity.Id,
+ truncate(activity.DisplayName),
+ time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
+ streams(activity))
+ }
+ table.Print()
+}
+
+func (cmd *Activity) listchildren(activity string) {
+ activityList, err := activities.ActivityChildren(cmd.network, activity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status", "Streams"})
+ for _, activity := range activityList {
+ table.Add(activity.Id,
+ truncate(activity.DisplayName),
+ time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), truncate(activity.CurrentStatus),
+ streams(activity))
+ }
+ table.Print()
+}
+
+func streams(act models.TaskSummary) string {
+ names := make([]string, 0)
+ for name, _ := range act.Streams {
+ names = append(names, name)
+ }
+ sort.Strings(names)
+ return strings.Join(names, ",")
+}
+
+const truncLimit = 40
+
+func truncate(text string) string {
+ if len(text) < truncLimit {
+ return text
+ }
+ return text[0:(truncLimit-3)] + "..."
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-catalog.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-catalog.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-catalog.go
new file mode 100644
index 0000000..bf79f23
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-catalog.go
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/catalog"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type AddCatalog struct {
+ network *net.Network
+}
+
+func NewAddCatalog(network *net.Network) (cmd *AddCatalog) {
+ cmd = new(AddCatalog)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddCatalog) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-catalog",
+ Description: "* Add a new catalog item from the supplied YAML",
+ Usage: "BROOKLYN_NAME add-catalog FILEPATH",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddCatalog) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ create, err := catalog.AddCatalog(cmd.network, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(create)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-children.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-children.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-children.go
new file mode 100644
index 0000000..6492044
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-children.go
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "time"
+)
+
+type AddChildren struct {
+ network *net.Network
+}
+
+func NewAddChildren(network *net.Network) (cmd *AddChildren) {
+ cmd = new(AddChildren)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddChildren) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-children",
+ Description: "* Add a child or children to this entity from the supplied YAML",
+ Usage: "BROOKLYN_NAME SCOPE add-children FILEPATH",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddChildren) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ activity, err := entities.AddChildren(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Task", "Submitted", "Status"})
+ table.Add(activity.Id, activity.DisplayName, time.Unix(activity.SubmitTimeUtc/1000, 0).Format(time.UnixDate), activity.CurrentStatus)
+
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-location.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-location.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-location.go
new file mode 100644
index 0000000..32c2db0
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-location.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type AddLocation struct {
+ network *net.Network
+}
+
+func NewAddLocation(network *net.Network) (cmd *AddLocation) {
+ cmd = new(AddLocation)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-policy.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-policy.go
new file mode 100644
index 0000000..a17e6c5
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-policy.go
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/codegangsta/cli"
+ //"github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+)
+
+type AddPolicy struct {
+ network *net.Network
+}
+
+func NewAddPolicy(network *net.Network) (cmd *AddPolicy) {
+ cmd = new(AddPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *AddPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "add-policy",
+ Description: "Add a new policy",
+ Usage: "BROOKLYN_NAME [ SCOPE ] add-policy APPLICATION ENTITY POLICY_TYPE",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *AddPolicy) Run(scope scope.Scope, c *cli.Context) {
+ // Todo
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/application.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/application.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/application.go
new file mode 100644
index 0000000..3538689
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/application.go
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/api/entity_sensors"
+ "github.com/apache/brooklyn-client/api/locations"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "strings"
+)
+
+type Application struct {
+ network *net.Network
+}
+
+func NewApplication(network *net.Network) (cmd *Application) {
+ cmd = new(Application)
+ cmd.network = network
+ return
+}
+
+func (cmd *Application) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "application",
+ Aliases: []string{"applications", "app", "apps"},
+ Description: "Show the status and location of running applications",
+ Usage: "BROOKLYN_NAME application [APP]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Application) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ cmd.show(c.Args().First())
+ } else {
+ cmd.list()
+ }
+}
+
+const serviceIsUpStr = "service.isUp"
+
+func (cmd *Application) show(appName string) {
+ application, err := application.Application(cmd.network, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ entity, err := entities.GetEntity(cmd.network, appName, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ state, err := entity_sensors.CurrentState(cmd.network, appName, appName)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ location, err := locations.GetLocation(cmd.network, application.Spec.Locations[0])
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id:", application.Id})
+ table.Add("Name:", application.Spec.Name)
+ table.Add("Status:", string(application.Status))
+ if serviceUp, ok := state[serviceIsUpStr]; ok {
+ table.Add("ServiceUp:", fmt.Sprintf("%v", serviceUp))
+ }
+ table.Add("Type:", application.Spec.Type)
+ table.Add("CatalogItemId:", entity.CatalogItemId)
+ table.Add("LocationId:", strings.Join(application.Spec.Locations, ", "))
+ table.Add("LocationName:", location.Name)
+ table.Add("LocationSpec:", location.Spec)
+ table.Add("LocationType:", location.Type)
+ table.Print()
+}
+
+func (cmd *Application) list() {
+ applications, err := application.Applications(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Status", "Location"})
+ for _, app := range applications {
+ table.Add(app.Id, app.Spec.Name, string(app.Status), strings.Join(app.Spec.Locations, ", "))
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-applications.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-applications.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-applications.go
new file mode 100644
index 0000000..19a4373
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-applications.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogApplication struct {
+ network *net.Network
+}
+
+func NewCatalogApplication(network *net.Network) (cmd *CatalogApplication) {
+ cmd = new(CatalogApplication)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entities.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entities.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entities.go
new file mode 100644
index 0000000..dbec760
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entities.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogEntities struct {
+ network *net.Network
+}
+
+func NewCatalogEntities(network *net.Network) (cmd *CatalogEntities) {
+ cmd = new(CatalogEntities)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entity.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entity.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entity.go
new file mode 100644
index 0000000..23cc295
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entity.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogEntity struct {
+ network *net.Network
+}
+
+func NewCatalogEntity(network *net.Network) (cmd *CatalogEntity) {
+ cmd = new(CatalogEntity)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-location.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-location.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-location.go
new file mode 100644
index 0000000..40babdd
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-location.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogLocation struct {
+ network *net.Network
+}
+
+func NewCatalogLocation(network *net.Network) (cmd *CatalogLocation) {
+ cmd = new(CatalogLocation)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-locations.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-locations.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-locations.go
new file mode 100644
index 0000000..e1791e8
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-locations.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogLocations struct {
+ network *net.Network
+}
+
+func NewCatalogLocations(network *net.Network) (cmd *CatalogLocations) {
+ cmd = new(CatalogLocations)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policies.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policies.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policies.go
new file mode 100644
index 0000000..3e245db
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policies.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogPolicies struct {
+ network *net.Network
+}
+
+func NewCatalogPolicies(network *net.Network) (cmd *CatalogPolicies) {
+ cmd = new(CatalogPolicies)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policy.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policy.go
new file mode 100644
index 0000000..82e8a95
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policy.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type CatalogPolicy struct {
+ network *net.Network
+}
+
+func NewCatalogPolicy(network *net.Network) (cmd *CatalogPolicy) {
+ cmd = new(CatalogPolicy)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog.go
new file mode 100644
index 0000000..2cb884d
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog.go
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/api/catalog"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+)
+
+type Catalog struct {
+ network *net.Network
+}
+
+func NewCatalog(network *net.Network) (cmd *Catalog) {
+ cmd = new(Catalog)
+ cmd.network = network
+ return
+}
+
+func (cmd *Catalog) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "catalog",
+ Description: "* List the available catalog applications",
+ Usage: "BROOKLYN_NAME catalog",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Catalog) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ catalog, err := catalog.Catalog(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Description"})
+ for _, app := range catalog {
+ table.Add(app.Id, app.Name, app.Description)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/config.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/config.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/config.go
new file mode 100644
index 0000000..8af3046
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/config.go
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_config"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+)
+
+type Config struct {
+ network *net.Network
+}
+
+func NewConfig(network *net.Network) (cmd *Config) {
+ cmd = new(Config)
+ cmd.network = network
+ return
+}
+
+func (cmd *Config) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "config",
+ Description: "Show the config for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE config",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Config) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.Args().Present() {
+ configValue, err := entity_config.ConfigValue(cmd.network, scope.Application, scope.Entity, c.Args().First())
+
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ displayValue, err := stringRepresentation(configValue)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(displayValue)
+
+ } else {
+ config, err := entity_config.ConfigCurrentState(cmd.network, scope.Application, scope.Entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Key", "Value"})
+ for key, value := range config {
+ table.Add(key, fmt.Sprintf("%v", value))
+ }
+ table.Print()
+ }
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-application.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-application.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-application.go
new file mode 100644
index 0000000..f289bbd
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-application.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogApplication struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogApplication(network *net.Network) (cmd *DeleteCatalogApplication) {
+ cmd = new(DeleteCatalogApplication)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-entity.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-entity.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-entity.go
new file mode 100644
index 0000000..5953fff
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-entity.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogEntity struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogEntity(network *net.Network) (cmd *DeleteCatalogEntity) {
+ cmd = new(DeleteCatalogEntity)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-policy.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-policy.go
new file mode 100644
index 0000000..c6b29a6
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-policy.go
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/net"
+)
+
+type DeleteCatalogPolicy struct {
+ network *net.Network
+}
+
+func NewDeleteCatalogPolicy(network *net.Network) (cmd *DeleteCatalogPolicy) {
+ cmd = new(DeleteCatalogPolicy)
+ cmd.network = network
+ return
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete.go
new file mode 100644
index 0000000..e4bfdae
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete.go
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type Delete struct {
+ network *net.Network
+}
+
+func NewDelete(network *net.Network) (cmd *Delete) {
+ cmd = new(Delete)
+ cmd.network = network
+ return
+}
+
+func (cmd *Delete) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "delete",
+ Description: "* Delete (expunge) a brooklyn application",
+ Usage: "BROOKLYN_NAME SCOPE delete",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Delete) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ del, err := application.Delete(cmd.network, scope.Application)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(del)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/deploy.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/deploy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/deploy.go
new file mode 100644
index 0000000..3b0607c
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/deploy.go
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/api/application"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/models"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "io/ioutil"
+ "os"
+ "strings"
+)
+
+type Deploy struct {
+ network *net.Network
+}
+
+func NewDeploy(network *net.Network) (cmd *Deploy) {
+ cmd = new(Deploy)
+ cmd.network = network
+ return
+}
+
+func (cmd *Deploy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "deploy",
+ Description: "Deploy a new application from the given YAML (read from file or stdin)",
+ Usage: "BROOKLYN_NAME deploy ( <FILE> | - )",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Deploy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+
+ var create models.TaskSummary
+ var err error
+ var blueprint []byte
+ if c.Args().First() == "" {
+ error_handler.ErrorExit("A filename or '-' must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
+ }
+ if c.Args().First() == "-" {
+ blueprint, err = ioutil.ReadAll(os.Stdin)
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ create, err = application.CreateFromBytes(cmd.network, blueprint)
+ } else {
+ create, err = application.Create(cmd.network, c.Args().First())
+ }
+ if nil != err {
+ if httpErr, ok := err.(net.HttpError); ok {
+ error_handler.ErrorExit(strings.Join([]string{httpErr.Status, httpErr.Body}, "\n"), httpErr.Code)
+ } else {
+ error_handler.ErrorExit(err)
+ }
+ }
+ table := terminal.NewTable([]string{"Id:", create.EntityId})
+ table.Add("Name:", create.EntityDisplayName)
+ table.Add("Status:", create.CurrentStatus)
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/destroy-policy.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/destroy-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/destroy-policy.go
new file mode 100644
index 0000000..c358d70
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/destroy-policy.go
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_policies"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+)
+
+type DestroyPolicy struct {
+ network *net.Network
+}
+
+func NewDestroyPolicy(network *net.Network) (cmd *DestroyPolicy) {
+ cmd = new(DestroyPolicy)
+ cmd.network = network
+ return
+}
+
+func (cmd *DestroyPolicy) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "destroy-policy",
+ Description: "Destroy a policy",
+ Usage: "BROOKLYN_NAME SCOPE destroy-policy POLICY",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *DestroyPolicy) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ spec, err := entity_policies.DestroyPolicy(cmd.network, scope.Application, scope.Entity, c.Args().First())
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Println(spec)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/effector.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/effector.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/effector.go
new file mode 100644
index 0000000..7105cf9
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/effector.go
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/api/entity_effectors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "strings"
+)
+
+type Effector struct {
+ network *net.Network
+}
+
+func NewEffector(network *net.Network) (cmd *Effector) {
+ cmd = new(Effector)
+ cmd.network = network
+ return
+}
+
+func (cmd *Effector) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "effector",
+ Description: "Show the effectors for an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE effector [ NAME ]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Effector) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ effectors, err := entity_effectors.EffectorList(cmd.network, scope.Application, scope.Entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Name", "Description", "Parameters"})
+ for _, effector := range effectors {
+ var parameters []string
+ for _, parameter := range effector.Parameters {
+ parameters = append(parameters, parameter.Name)
+ }
+ if !c.Args().Present() || c.Args().First() == effector.Name {
+ table.Add(effector.Name, effector.Description, strings.Join(parameters, ","))
+ }
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/entity.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/entity.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/entity.go
new file mode 100644
index 0000000..b6688a3
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/entity.go
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entities"
+ "github.com/apache/brooklyn-client/api/entity_sensors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+ "os"
+)
+
+type Entity struct {
+ network *net.Network
+}
+
+func NewEntity(network *net.Network) (cmd *Entity) {
+ cmd = new(Entity)
+ cmd.network = network
+ return
+}
+
+func (cmd *Entity) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "entity",
+ Aliases: []string{"entities", "ent", "ents"},
+ Description: "Show the entities of an application or entity",
+ Usage: "BROOKLYN_NAME SCOPE entity [ENTITYID]",
+ Flags: []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "children, c",
+ Usage: "List children of the entity",
+ },
+ },
+ }
+}
+
+func (cmd *Entity) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ if c.NumFlags() > 0 && c.FlagNames()[0] == "children" {
+ cmd.listentity(scope.Application, c.StringSlice("children")[0])
+ } else {
+ if c.Args().Present() {
+ cmd.show(scope.Application, c.Args().First())
+ } else {
+ if scope.Entity == scope.Application {
+ cmd.listapp(scope.Application)
+ } else {
+ cmd.listentity(scope.Application, scope.Entity)
+ }
+ }
+ }
+}
+
+const serviceStateSensor = "service.state"
+const serviceIsUp = "service.isUp"
+
+func (cmd *Entity) show(application, entity string) {
+ summary, err := entities.GetEntity(cmd.network, application, entity)
+ if nil != err {
+ fmt.Fprintf(os.Stderr, "Error: %s\n", err)
+ os.Exit(1)
+ }
+ table := terminal.NewTable([]string{"Id:", summary.Id})
+ table.Add("Name:", summary.Name)
+ configState, err := entity_sensors.CurrentState(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ if serviceState, ok := configState[serviceStateSensor]; ok {
+ table.Add("Status:", fmt.Sprintf("%v", serviceState))
+ }
+ if serviceIsUp, ok := configState[serviceIsUp]; ok {
+ table.Add("ServiceUp:", fmt.Sprintf("%v", serviceIsUp))
+ }
+ table.Add("Type:", summary.Type)
+ table.Add("CatalogItemId:", summary.CatalogItemId)
+ table.Print()
+}
+
+func (cmd *Entity) listapp(application string) {
+ entitiesList, err := entities.EntityList(cmd.network, application)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Type"})
+ for _, entityitem := range entitiesList {
+ table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
+ }
+ table.Print()
+}
+
+func (cmd *Entity) listentity(application string, entity string) {
+ entitiesList, err := entities.Children(cmd.network, application, entity)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+
+ table := terminal.NewTable([]string{"Id", "Name", "Type"})
+ for _, entityitem := range entitiesList {
+ table.Add(entityitem.Id, entityitem.Name, entityitem.Type)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/invoke.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/invoke.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/invoke.go
new file mode 100644
index 0000000..1ca6dd8
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/invoke.go
@@ -0,0 +1,202 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "errors"
+ "fmt"
+ "github.com/apache/brooklyn-client/api/entity_effectors"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+ "io/ioutil"
+ "strings"
+)
+
+type Invoke struct {
+ network *net.Network
+}
+
+type Stop struct {
+ Invoke
+}
+
+type Start struct {
+ Invoke
+}
+
+type Restart struct {
+ Invoke
+}
+
+func NewInvoke(network *net.Network) (cmd *Invoke) {
+ cmd = new(Invoke)
+ cmd.network = network
+ return
+}
+
+func NewInvokeStop(network *net.Network) (cmd *Stop) {
+ cmd = new(Stop)
+ cmd.network = network
+ return
+}
+
+func NewInvokeStart(network *net.Network) (cmd *Start) {
+ cmd = new(Start)
+ cmd.network = network
+ return
+}
+
+func NewInvokeRestart(network *net.Network) (cmd *Restart) {
+ cmd = new(Restart)
+ cmd.network = network
+ return
+}
+
+var paramFlags = []cli.Flag{
+ cli.StringSliceFlag{
+ Name: "param, P",
+ Usage: "Parameter and value separated by '=', e.g. -P x=y",
+ },
+}
+
+func (cmd *Invoke) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "invoke",
+ Description: "Invoke an effector of an application and entity",
+ Usage: "BROOKLYN_NAME EFF-SCOPE invoke [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Stop) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "stop",
+ Description: "Invoke stop effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE stop [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Start) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "start",
+ Description: "Invoke start effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE start [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Restart) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "restart",
+ Description: "Invoke restart effector on an application and entity",
+ Usage: "BROOKLYN_NAME ENT-SCOPE restart [ parameter-options ]",
+ Flags: paramFlags,
+ }
+}
+
+func (cmd *Invoke) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, scope.Effector, parms)
+}
+
+const stopEffector = "stop"
+
+func (cmd *Stop) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, stopEffector, parms)
+}
+
+const startEffector = "start"
+
+func (cmd *Start) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, startEffector, parms)
+}
+
+const restartEffector = "restart"
+
+func (cmd *Restart) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ parms := c.StringSlice("param")
+ invoke(cmd.network, scope.Application, scope.Entity, restartEffector, parms)
+}
+
+func invoke(network *net.Network, application, entity, effector string, parms []string) {
+ names, vals, err := extractParams(parms)
+ result, err := entity_effectors.TriggerEffector(network, application, entity, effector, names, vals)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ } else {
+ if "" != result {
+ fmt.Println(result)
+ }
+ }
+}
+
+func extractParams(parms []string) ([]string, []string, error) {
+ names := make([]string, len(parms))
+ vals := make([]string, len(parms))
+ var err error
+ for i, parm := range parms {
+ index := strings.Index(parm, "=")
+ if index < 0 {
+ return names, vals, errors.New("Parameter value not provided: " + parm)
+ }
+ names[i] = parm[0:index]
+ vals[i], err = extractParamValue(parm[index+1:])
+ }
+ return names, vals, err
+}
+
+const paramDataPrefix string = "@"
+
+func extractParamValue(rawParam string) (string, error) {
+ var err error
+ var val string
+ if strings.HasPrefix(rawParam, paramDataPrefix) {
+ // strip the data prefix from the filename before reading
+ val, err = readParamFromFile(rawParam[len(paramDataPrefix):])
+ } else {
+ val = rawParam
+ err = nil
+ }
+ return val, err
+}
+
+// returning a string rather than byte array, assuming non-binary
+// TODO - if necessary support binary data sending to effector
+func readParamFromFile(filename string) (string, error) {
+ dat, err := ioutil.ReadFile(filename)
+ return string(dat), err
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/list.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/list.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/list.go
new file mode 100644
index 0000000..d675f77
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/list.go
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/command"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+ "strings"
+)
+
+type List struct {
+ network *net.Network
+ listCommands map[string]command.Command
+}
+
+func NewList(network *net.Network) (cmd *List) {
+ cmd = new(List)
+ cmd.network = network
+ cmd.listCommands = map[string]command.Command{
+ // ListApplicationCommand: NewApplications(cmd.network),
+ // ListEntityCommand: NewEntities(cmd.network),
+ // ListSensorCommand: NewSensors(cmd.network),
+ // ListEffectorCommand: NewEffector(cmd.network),
+ }
+ return
+}
+
+const ListApplicationCommand = "application"
+const ListEntityCommand = "entities"
+const ListSensorCommand = "sensors"
+const ListEffectorCommand = "effectors"
+
+var listCommands = []string{
+ ListApplicationCommand,
+ ListEntityCommand,
+ ListSensorCommand,
+ ListEffectorCommand,
+}
+var listCommandsUsage = strings.Join(listCommands, " | ")
+
+func (cmd *List) SubCommandNames() []string {
+ return listCommands
+}
+
+func (cmd *List) SubCommand(name string) command.Command {
+ return cmd.listCommands[name]
+}
+
+func (cmd *List) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "list",
+ Description: "List details for a variety of operands",
+ Usage: "BROOKLYN_NAME SCOPE list (" + listCommandsUsage + ")",
+ Flags: []cli.Flag{},
+ Operands: []command_metadata.CommandMetadata{
+ cmd.SubCommand(ListApplicationCommand).Metadata(),
+ cmd.SubCommand(ListEntityCommand).Metadata(),
+ cmd.SubCommand(ListSensorCommand).Metadata(),
+ cmd.SubCommand(ListEffectorCommand).Metadata(),
+ },
+ }
+}
+
+func (cmd *List) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("Unrecognised item for list, please use one of (%s)\n", listCommandsUsage)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/locations.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/locations.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/locations.go
new file mode 100644
index 0000000..79646d5
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/locations.go
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "github.com/apache/brooklyn-client/api/locations"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/apache/brooklyn-client/terminal"
+ "github.com/codegangsta/cli"
+)
+
+type Locations struct {
+ network *net.Network
+}
+
+func NewLocations(network *net.Network) (cmd *Locations) {
+ cmd = new(Locations)
+ cmd.network = network
+ return
+}
+
+func (cmd *Locations) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "locations",
+ Description: "* List the available locations",
+ Usage: "BROOKLYN_NAME locations",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Locations) Run(scope scope.Scope, c *cli.Context) {
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+ locationList, err := locations.LocationList(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ table := terminal.NewTable([]string{"Id", "Name", "Spec"})
+ for _, location := range locationList {
+ table.Add(location.Id, location.Name, location.Spec)
+ }
+ table.Print()
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/195403f1/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/login.go
----------------------------------------------------------------------
diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/login.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/login.go
new file mode 100644
index 0000000..fd47196
--- /dev/null
+++ b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/login.go
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package commands
+
+import (
+ "fmt"
+ "github.com/apache/brooklyn-client/api/version"
+ "github.com/apache/brooklyn-client/command_metadata"
+ "github.com/apache/brooklyn-client/error_handler"
+ "github.com/apache/brooklyn-client/io"
+ "github.com/apache/brooklyn-client/net"
+ "github.com/apache/brooklyn-client/scope"
+ "github.com/codegangsta/cli"
+ "golang.org/x/crypto/ssh/terminal"
+ "syscall"
+)
+
+type Login struct {
+ network *net.Network
+ config *io.Config
+}
+
+func NewLogin(network *net.Network, config *io.Config) (cmd *Login) {
+ cmd = new(Login)
+ cmd.network = network
+ cmd.config = config
+ return
+}
+
+func (cmd *Login) Metadata() command_metadata.CommandMetadata {
+ return command_metadata.CommandMetadata{
+ Name: "login",
+ Description: "Login to brooklyn",
+ Usage: "BROOKLYN_NAME login URL [USER [PASSWORD]]",
+ Flags: []cli.Flag{},
+ }
+}
+
+func (cmd *Login) Run(scope scope.Scope, c *cli.Context) {
+ if !c.Args().Present() {
+ error_handler.ErrorExit("A URL must be provided as the first argument", error_handler.CLIUsageErrorExitCode)
+ }
+
+ // If an argument was not supplied, it is set to empty string
+ cmd.network.BrooklynUrl = c.Args().Get(0)
+ cmd.network.BrooklynUser = c.Args().Get(1)
+ cmd.network.BrooklynPass = c.Args().Get(2)
+
+ if err := net.VerifyLoginURL(cmd.network); err != nil {
+ error_handler.ErrorExit(err)
+ }
+
+ // Strip off trailing '/' from URL if present.
+ if cmd.network.BrooklynUrl[len(cmd.network.BrooklynUrl)-1] == '/' {
+ if len(cmd.network.BrooklynUrl) == 1 {
+ error_handler.ErrorExit("URL must not be a single \"/\" character", error_handler.CLIUsageErrorExitCode)
+ }
+ cmd.network.BrooklynUrl = cmd.network.BrooklynUrl[0 : len(cmd.network.BrooklynUrl)-1]
+ }
+
+ // Prompt for password if not supplied (password is not echoed to screen
+ if cmd.network.BrooklynUser != "" && cmd.network.BrooklynPass == "" {
+ fmt.Print("Enter Password: ")
+ bytePassword, err := terminal.ReadPassword(int(syscall.Stdin))
+ if err != nil {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("\n")
+ cmd.network.BrooklynPass = string(bytePassword)
+ }
+
+ if cmd.config.Map == nil {
+ cmd.config.Map = make(map[string]interface{})
+ }
+ // now persist these credentials to the yaml file
+ auth, ok := cmd.config.Map["auth"].(map[string]interface{})
+ if !ok {
+ auth = make(map[string]interface{})
+ cmd.config.Map["auth"] = auth
+ }
+
+ auth[cmd.network.BrooklynUrl] = map[string]string{
+ "username": cmd.network.BrooklynUser,
+ "password": cmd.network.BrooklynPass,
+ }
+
+ cmd.config.Map["target"] = cmd.network.BrooklynUrl
+ cmd.config.Write()
+
+ loginVersion, err := version.Version(cmd.network)
+ if nil != err {
+ error_handler.ErrorExit(err)
+ }
+ fmt.Printf("Connected to Brooklyn version %s at %s\n", loginVersion.Version, cmd.network.BrooklynUrl)
+}