http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/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 deleted file mode 100644 index 7c3dfcf..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-location.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 3fe0813..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/add-policy.go +++ /dev/null @@ -1,32 +0,0 @@ -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/81853355/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 deleted file mode 100644 index c62ca1b..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/application.go +++ /dev/null @@ -1,93 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 217a048..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-applications.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index a9681f8..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entities.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 3a3b88c..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-entity.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 1dd542e..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-location.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 4699a9b..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-locations.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 871270a..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policies.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index d26a9e3..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog-policy.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 6d9e8e8..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/catalog.go +++ /dev/null @@ -1,45 +0,0 @@ -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/81853355/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 deleted file mode 100644 index d7af15a..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/config.go +++ /dev/null @@ -1,60 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 626e466..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-application.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index cfee68e..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-entity.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index ef4975d..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete-catalog-policy.go +++ /dev/null @@ -1,15 +0,0 @@ -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/81853355/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 deleted file mode 100644 index a77e134..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/delete.go +++ /dev/null @@ -1,41 +0,0 @@ -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/81853355/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 deleted file mode 100644 index fb86d10..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/deploy.go +++ /dev/null @@ -1,67 +0,0 @@ -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/81853355/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 deleted file mode 100644 index d9a007e..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/destroy-policy.go +++ /dev/null @@ -1,41 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 147e9c8..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/effector.go +++ /dev/null @@ -1,52 +0,0 @@ -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/81853355/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 deleted file mode 100644 index c5ff0ab..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/entity.go +++ /dev/null @@ -1,109 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 77cb794..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/invoke.go +++ /dev/null @@ -1,184 +0,0 @@ -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/81853355/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 deleted file mode 100644 index f18e955..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/list.go +++ /dev/null @@ -1,72 +0,0 @@ -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/81853355/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 deleted file mode 100644 index c1dfd88..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/locations.go +++ /dev/null @@ -1,45 +0,0 @@ -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/81853355/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 deleted file mode 100644 index 84c8ea9..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/login.go +++ /dev/null @@ -1,93 +0,0 @@ -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) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/policy.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/policy.go deleted file mode 100644 index 8617699..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/policy.go +++ /dev/null @@ -1,96 +0,0 @@ -package commands - -import ( - "github.com/apache/brooklyn-client/api/entity_policies" - "github.com/apache/brooklyn-client/api/entity_policy_config" - "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" -) - -type Policy struct { - network *net.Network -} - -type policyConfigList []models.PolicyConfigList - -// Len is the number of elements in the collection. -func (configs policyConfigList) Len() int { - return len(configs) -} - -// Less reports whether the element with -// index i should sort before the element with index j. -func (configs policyConfigList) Less(i, j int) bool { - return configs[i].Name < configs[j].Name -} - -// Swap swaps the elements with indexes i and j. -func (configs policyConfigList) Swap(i, j int) { - temp := configs[i] - configs[i] = configs[j] - configs[j] = temp -} - -func NewPolicy(network *net.Network) (cmd *Policy) { - cmd = new(Policy) - cmd.network = network - return -} - -func (cmd *Policy) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "policy", - Aliases: []string{"policies", "pol", "pols"}, - Description: "Show the policies for an application or entity", - Usage: "BROOKLYN_NAME SCOPE policy [NAME]", - Flags: []cli.Flag{}, - } -} - -func (cmd *Policy) 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(scope.Application, scope.Entity, c.Args().First()) - } else { - cmd.list(scope.Application, scope.Entity) - } -} - -func (cmd *Policy) show(application, entity, policy string) { - configs, err := entity_policy_config.GetAllConfigValues(cmd.network, application, entity, policy) - if nil != err { - error_handler.ErrorExit(err) - } - table := terminal.NewTable([]string{"Name", "Value", "Description"}) - var theConfigs policyConfigList = configs - sort.Sort(theConfigs) - - for _, config := range theConfigs { - value, err := entity_policy_config.GetConfigValue(cmd.network, application, entity, policy, config.Name) - if nil != err { - error_handler.ErrorExit(err) - } - table.Add(config.Name, value, config.Description) - } - table.Print() -} - -func (cmd *Policy) list(application, entity string) { - policies, err := entity_policies.PolicyList(cmd.network, application, entity) - if nil != err { - error_handler.ErrorExit(err) - } - table := terminal.NewTable([]string{"Id", "Name", "State"}) - for _, policy := range policies { - table.Add(policy.Id, policy.Name, string(policy.State)) - } - table.Print() -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/rename.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/rename.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/rename.go deleted file mode 100644 index d76fedc..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/rename.go +++ /dev/null @@ -1,41 +0,0 @@ -package commands - -import ( - "fmt" - "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/codegangsta/cli" -) - -type Rename struct { - network *net.Network -} - -func NewRename(network *net.Network) (cmd *Rename) { - cmd = new(Rename) - cmd.network = network - return -} - -func (cmd *Rename) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "rename", - Description: "Rename an application or entity", - Usage: "BROOKLYN_NAME SCOPE rename NEW_NAME", - Flags: []cli.Flag{}, - } -} - -func (cmd *Rename) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - rename, err := entities.Rename(cmd.network, scope.Application, scope.Entity, c.Args().First()) - if nil != err { - error_handler.ErrorExit(err) - } - fmt.Println(rename) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/reset-catalog.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/reset-catalog.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/reset-catalog.go deleted file mode 100644 index bb863f6..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/reset-catalog.go +++ /dev/null @@ -1,15 +0,0 @@ -package commands - -import ( - "github.com/apache/brooklyn-client/net" -) - -type ResetCatalog struct { - network *net.Network -} - -func NewResetCatalog(network *net.Network) (cmd *ResetCatalog) { - cmd = new(ResetCatalog) - cmd.network = network - return -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/sensor.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/sensor.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/sensor.go deleted file mode 100644 index 65c3115..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/sensor.go +++ /dev/null @@ -1,100 +0,0 @@ -package commands - -import ( - "fmt" - "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/models" - "github.com/apache/brooklyn-client/net" - "github.com/apache/brooklyn-client/scope" - "github.com/apache/brooklyn-client/terminal" - "github.com/codegangsta/cli" - "sort" -) - -type Sensor struct { - network *net.Network -} - -type sensorList []models.SensorSummary - -// Len is the number of elements in the collection. -func (sensors sensorList) Len() int { - return len(sensors) -} - -// Less reports whether the element with -// index i should sort before the element with index j. -func (sensors sensorList) Less(i, j int) bool { - return sensors[i].Name < sensors[j].Name -} - -// Swap swaps the elements with indexes i and j. -func (sensors sensorList) Swap(i, j int) { - temp := sensors[i] - sensors[i] = sensors[j] - sensors[j] = temp -} - -func NewSensor(network *net.Network) (cmd *Sensor) { - cmd = new(Sensor) - cmd.network = network - return -} - -func (cmd *Sensor) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "sensor", - Description: "Show values of all sensors or named sensor for an application or entity", - Usage: "BROOKLYN_NAME SCOPE sensor [ SENSOR_NAME ]", - Flags: []cli.Flag{}, - } -} - -func (cmd *Sensor) 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(scope.Application, scope.Entity, c.Args().First()) - } else { - cmd.list(scope.Application, scope.Entity) - } -} - -func (cmd *Sensor) show(application, entity, sensor string) { - sensorValue, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor) - if nil != err { - error_handler.ErrorExit(err) - } - displayValue, err := stringRepresentation(sensorValue) - if nil != err { - error_handler.ErrorExit(err) - } - fmt.Println(displayValue) -} - -func (cmd *Sensor) list(application, entity string) { - sensors, err := entity_sensors.SensorList(cmd.network, application, entity) - if nil != err { - error_handler.ErrorExit(err) - } - var theSensors sensorList = sensors - table := terminal.NewTable([]string{"Name", "Description", "Value"}) - - sort.Sort(theSensors) - - for _, sensor := range theSensors { - value, err := entity_sensors.SensorValue(cmd.network, application, entity, sensor.Name) - if nil != err { - error_handler.ErrorExit(err) - } - displayValue, err := stringRepresentation(value) - if nil != err { - error_handler.ErrorExit(err) - } - table.Add(sensor.Name, sensor.Description, displayValue) - } - table.Print() -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/set.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/set.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/set.go deleted file mode 100644 index c0f2b50..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/set.go +++ /dev/null @@ -1,41 +0,0 @@ -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/codegangsta/cli" -) - -type SetConfig struct { - network *net.Network -} - -func NewSetConfig(network *net.Network) (cmd *SetConfig) { - cmd = new(SetConfig) - cmd.network = network - return -} - -func (cmd *SetConfig) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "set", - Description: "Set config for an entity", - Usage: "BROOKLYN_NAME CONFIG-SCOPE set VALUE", - Flags: []cli.Flag{}, - } -} - -func (cmd *SetConfig) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - response, err := entity_config.SetConfig(cmd.network, scope.Application, scope.Entity, scope.Config, c.Args().First()) - if nil != err { - error_handler.ErrorExit(err) - } - fmt.Println(response) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/spec.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/spec.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/spec.go deleted file mode 100644 index ca980d3..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/spec.go +++ /dev/null @@ -1,41 +0,0 @@ -package commands - -import ( - "fmt" - "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/codegangsta/cli" -) - -type Spec struct { - network *net.Network -} - -func NewSpec(network *net.Network) (cmd *Spec) { - cmd = new(Spec) - cmd.network = network - return -} - -func (cmd *Spec) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "spec", - Description: "Get the YAML spec used to create the entity, if available", - Usage: "BROOKLYN_NAME SCOPE spec", - Flags: []cli.Flag{}, - } -} - -func (cmd *Spec) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - spec, err := entities.Spec(cmd.network, scope.Application, scope.Entity) - if nil != err { - error_handler.ErrorExit(err) - } - fmt.Println(spec) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/start-policy.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/start-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/start-policy.go deleted file mode 100644 index a5675ba..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/start-policy.go +++ /dev/null @@ -1,41 +0,0 @@ -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 StartPolicy struct { - network *net.Network -} - -func NewStartPolicy(network *net.Network) (cmd *StartPolicy) { - cmd = new(StartPolicy) - cmd.network = network - return -} - -func (cmd *StartPolicy) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "start-policy", - Description: "Start or resume a policy", - Usage: "BROOKLYN_NAME SCOPE start-policy POLICY", - Flags: []cli.Flag{}, - } -} - -func (cmd *StartPolicy) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - spec, err := entity_policies.StartPolicy(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/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/stop-policy.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/stop-policy.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/stop-policy.go deleted file mode 100644 index ce0b89b..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/stop-policy.go +++ /dev/null @@ -1,41 +0,0 @@ -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 StopPolicy struct { - network *net.Network -} - -func NewStopPolicy(network *net.Network) (cmd *StopPolicy) { - cmd = new(StopPolicy) - cmd.network = network - return -} - -func (cmd *StopPolicy) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "stop-policy", - Description: "Suspends a policy", - Usage: "BROOKLYN_NAME SCOPE stop-policy POLICY", - Flags: []cli.Flag{}, - } -} - -func (cmd *StopPolicy) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - spec, err := entity_policies.StopPolicy(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/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/tree.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/tree.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/tree.go deleted file mode 100644 index 3ee55f6..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/tree.go +++ /dev/null @@ -1,60 +0,0 @@ -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/models" - "github.com/apache/brooklyn-client/net" - "github.com/apache/brooklyn-client/scope" - "github.com/codegangsta/cli" -) - -type Tree struct { - network *net.Network -} - -func NewTree(network *net.Network) (cmd *Tree) { - cmd = new(Tree) - cmd.network = network - return -} - -func (cmd *Tree) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "tree", - Description: "* Show the tree of all applications", - Usage: "BROOKLYN_NAME tree", - Flags: []cli.Flag{}, - } -} - -func (cmd *Tree) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - trees, err := application.Tree(cmd.network) - if nil != err { - error_handler.ErrorExit(err) - } - cmd.printTrees(trees, "") -} - -func (cmd *Tree) printTrees(trees []models.Tree, indent string) { - for i, app := range trees { - cmd.printTree(app, indent, i == len(trees)-1) - } -} - -func (cmd *Tree) printTree(tree models.Tree, indent string, last bool) { - fmt.Println(indent+"|-", tree.Name) - fmt.Println(indent+"+-", tree.Type) - - if last { - indent = indent + " " - } else { - indent = indent + "| " - } - cmd.printTrees(tree.Children, indent) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/utils.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/utils.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/utils.go deleted file mode 100644 index ba553e0..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/utils.go +++ /dev/null @@ -1,20 +0,0 @@ -package commands - -import ( - "encoding/json" -) - -func stringRepresentation(value interface{}) (string, error) { - var result string - switch value.(type) { - case string: - result = value.(string) // use string value as-is - default: - json, err := json.Marshal(value) - if err != nil { - return "", err - } - result = string(json) // return JSON text representation of value object - } - return result, nil -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/version.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/version.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/version.go deleted file mode 100644 index 0e30a26..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/commands/version.go +++ /dev/null @@ -1,41 +0,0 @@ -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/net" - "github.com/apache/brooklyn-client/scope" - "github.com/codegangsta/cli" -) - -type Version struct { - network *net.Network -} - -func NewVersion(network *net.Network) (cmd *Version) { - cmd = new(Version) - cmd.network = network - return -} - -func (cmd *Version) Metadata() command_metadata.CommandMetadata { - return command_metadata.CommandMetadata{ - Name: "version", - Description: "Display the version of the connected Brooklyn", - Usage: "BROOKLYN_NAME version", - Flags: []cli.Flag{}, - } -} - -func (cmd *Version) Run(scope scope.Scope, c *cli.Context) { - if err := net.VerifyLoginURL(cmd.network); err != nil { - error_handler.ErrorExit(err) - } - version, err := version.Version(cmd.network) - if nil != err { - error_handler.ErrorExit(err) - } - fmt.Println(version.Version) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/error_handler/error.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/error_handler/error.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/error_handler/error.go deleted file mode 100644 index 73a525c..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/error_handler/error.go +++ /dev/null @@ -1,28 +0,0 @@ -package error_handler - -import ( - "fmt" - "os" -) - -const CLIUsageErrorExitCode int = 1 -const CliGenericErrorExitCode int = 2 -const CLITrapErrorCode int = 3 - -func ErrorExit(errorvalue interface{}, errorcode ...int) { - switch errorvalue.(type) { - case error: - fmt.Fprintln(os.Stderr, errorvalue) - case string: - fmt.Fprintln(os.Stderr, errorvalue) - case nil: - fmt.Fprintln(os.Stderr, "No error message provided") - default: - fmt.Fprintln(os.Stderr, "Unknown Error Type: ", errorvalue) - } - if len(errorcode) > 0 { - os.Exit(errorcode[0]) - } else { - os.Exit(CliGenericErrorExitCode) - } -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/io/config.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/io/config.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/io/config.go deleted file mode 100644 index 5ebc79b..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/io/config.go +++ /dev/null @@ -1,51 +0,0 @@ -package io - -import ( - "encoding/json" - "github.com/apache/brooklyn-client/error_handler" - "os" - "path/filepath" -) - -type Config struct { - FilePath string - Map map[string]interface{} -} - -func GetConfig() (config *Config) { - // check to see if $BRCLI_HOME/.brooklyn_cli or $HOME/.brooklyn_cli exists - // Then parse it to get user credentials - config = new(Config) - if os.Getenv("BRCLI_HOME") != "" { - config.FilePath = filepath.Join(os.Getenv("BRCLI_HOME"), ".brooklyn_cli") - } else { - config.FilePath = filepath.Join(os.Getenv("HOME"), ".brooklyn_cli") - } - if _, err := os.Stat(config.FilePath); os.IsNotExist(err) { - config.Map = make(map[string]interface{}) - config.Write() - } - config.Read() - return -} - -func (config *Config) Write() { - - // Create file as read/write by user (but does not change perms of existing file) - fileToWrite, err := os.OpenFile(config.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - error_handler.ErrorExit(err) - } - - enc := json.NewEncoder(fileToWrite) - enc.Encode(config.Map) -} - -func (config *Config) Read() { - fileToRead, err := os.Open(config.FilePath) - if err != nil { - error_handler.ErrorExit(err) - } - dec := json.NewDecoder(fileToRead) - dec.Decode(&config.Map) -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/access.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/access.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/access.go deleted file mode 100644 index 27a7dbb..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/access.go +++ /dev/null @@ -1,6 +0,0 @@ -package models - -type AccessSummary struct { - Links map[string]URI `json:"links"` - LocationProvisioningAllowed bool `json:"locationProvisioningAllowed"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/applications.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/applications.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/applications.go deleted file mode 100644 index cac09dd..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/applications.go +++ /dev/null @@ -1,77 +0,0 @@ -package models - -type Tree struct { - Name string `json:"name"` - Id string `json:"id"` - Type string `json:"type"` - ServiceUp bool `json:"serviceUp"` - ServiceState string `json:"serviceState"` - Children []Tree `json:"children"` -} - -type TaskSummary struct { - SubmitTimeUtc int64 `json:"submitTimeUtc"` - EndTimeUtc int64 `json:"endTimeUtc"` - IsCancelled bool `json:"isCancelled"` - CurrentStatus string `json:"currentStatus"` - BlockingTask LinkTaskWithMetadata `json:"blockingTask"` - DisplayName string `json:"displayName"` - Streams map[string]LinkStreamsWithMetadata `json:"streams"` - Description string `json:"description"` - EntityId string `json:"entityId"` - EntityDisplayName string `json:"entityDisplayName"` - Error bool `json:"error"` - SubmittedByTask LinkTaskWithMetadata `json:"submittedByTask"` - Result interface{} `json:"result"` - IsError bool `json:"isError"` - DetailedStatus string `json:"detailedStatus"` - Children []LinkTaskWithMetadata `json:"children"` - BlockingDetails string `json:"blockingDetails"` - Cancelled bool `json:"cancelled"` - Links map[string]URI `json:"links"` - Id string `json:"id"` - StartTimeUtc int64 `json:"startTimeUtc"` -} - -type ApplicationSummary struct { - Links map[string]URI `json:"links"` - Id string `json:"id"` - Spec ApplicationSpec `json:"spec"` - Status Status `json:"status"` -} - -type ApplicationSpec struct { - Name string `json:"name"` - Type string `json:"type"` - Locations []string `json:"locations"` -} - -type Status string - -type LinkWithMetadata struct { -} - -type LinkStreamsWithMetadata struct { - Link string `json:"link"` - Metadata LinkStreamMetadata `json:"metadata"` -} - -type LinkStreamMetadata struct { - Name string `json:"name"` - Size int64 `json:"size"` - SizeText string `json:"sizeText"` -} - -type LinkTaskWithMetadata struct { - Link string `json:"link"` - Metadata LinkTaskMetadata `json:"metadata"` -} - -type LinkTaskMetadata struct { - Id string `json:"id"` - TaskName string `json:"taskName"` - EntityId string `json:"entityId"` - EntityDisplayName string `json:"entityDisplayName"` -} - -type URI string http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/catalog.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/catalog.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/catalog.go deleted file mode 100644 index 92b745c..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/catalog.go +++ /dev/null @@ -1,45 +0,0 @@ -package models - -type CatalogItemSummary struct { - Name string `json:"name"` - JavaType string `json:"javaType"` - SymbolicName string `json:"symbolicName"` - Version string `json:"version"` - PlanYaml string `json:"planYaml"` - Description string `json:"description"` - Deprecated bool `json:"deprecated"` - Links map[string]interface{} `json:"links"` - Id string `json:"id"` - Type string `json:"type"` -} - -type CatalogPolicySummary struct { - symbolicName string `json:"symbolicName"` - version string `json:"version"` - displayName string `json:"name"` - javaType string `json:"javaType"` - planYaml string `json:"planYaml"` - description string `json:"description"` - iconUrl string `json:"iconUrl"` - deprecated bool `json:"deprecated"` - links map[string]URI `json:"links"` -} - -type CatalogLocationSummary struct { -} - -type CatalogEntitySummary struct { - symbolicName string `json:"symbolicName"` - version string `json:"version"` - displayName string `json:"name"` - javaType string `json:"javaType"` - planYaml string `json:"planYaml"` - description string `json:"description"` - Config []ConfigSummary `json:"config"` - Effectors []EffectorSummary `json:"effectors"` - Sensors []SensorSummary `json:"sensors"` - Deprecated bool `json:"deprecated"` - Links map[string]interface{} `json:"links"` - Id string `json:"id"` - Type string `json:"type"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/config.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/config.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/config.go deleted file mode 100644 index 599e362..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/config.go +++ /dev/null @@ -1,13 +0,0 @@ -package models - -type ConfigSummary struct { - Reconfigurable bool `json:"reconfigurable"` - PossibleValues []map[string]string `json:"possibleValues"` - DefaultValue interface{} `json:"defaultValue"` - Name string `json:"name"` - Description string `json:"description"` - Links map[string]URI `json:"links"` - Label string `json:"label"` - Priority float64 `json:"priority"` - Type string `json:"type"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/effectors.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/effectors.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/effectors.go deleted file mode 100644 index 25d5cb9..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/effectors.go +++ /dev/null @@ -1,16 +0,0 @@ -package models - -type EffectorSummary struct { - Name string `json:"name"` - Description string `json:"description"` - Links map[string]URI `json:"links"` - Parameters []ParameterSummary `json:"parameters"` - ReturnType string `json:"returnType"` -} - -type ParameterSummary struct { - Name string `json:"name"` - Type string `json:"type"` - Description string `json:"description"` - DefaultValue interface{} `json:"defaultValue"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/entities.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/entities.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/entities.go deleted file mode 100644 index 70a47ca..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/entities.go +++ /dev/null @@ -1,9 +0,0 @@ -package models - -type EntitySummary struct { - CatalogItemId string `json:"catalogItemId"` - Name string `json:"name"` - Links map[string]URI `json:"links"` - Id string `json:"id"` - Type string `json:"type"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/locations.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/locations.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/locations.go deleted file mode 100644 index b73c9bb..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/locations.go +++ /dev/null @@ -1,10 +0,0 @@ -package models - -type LocationSummary struct { - Id string `json:"id"` - Name string `json:"name"` - Spec string `json:"spec"` - Type string `json:"type"` - Config map[string]interface{} `json:"config"` - Links map[string]URI `json:"links"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/policies.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/policies.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/policies.go deleted file mode 100644 index 16c1b25..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/policies.go +++ /dev/null @@ -1,21 +0,0 @@ -package models - -type PolicySummary struct { - CatalogItemId string `json:"catalogItemId"` - Name string `json:"name"` - Links map[string]URI `json:"links"` - Id string `json:"id"` - State Status `json:"state"` -} - -type PolicyConfigList struct { - Name string `json:"name"` - Type string `json:"type"` - DefaultValue interface{} `json:"defaultValue` - Description string `json:"description"` - Reconfigurable bool `json:"reconfigurable"` - Label string `json:"label"` - Priority int64 `json:"priority"` - PossibleValues []interface{} `json:"possibleValues"` - Links map[string]URI `json:"links"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/sensors.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/sensors.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/sensors.go deleted file mode 100644 index c93b1cd..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/sensors.go +++ /dev/null @@ -1,8 +0,0 @@ -package models - -type SensorSummary struct { - Name string `json:"name"` - Description string `json:"description"` - Links map[string]URI `json:"links"` - Type string `json:"type"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/version.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/version.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/version.go deleted file mode 100644 index bc68bf5..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/models/version.go +++ /dev/null @@ -1,16 +0,0 @@ -package models - -type VersionSummary struct { - Version string `json:"version"` - BuildSha1 string `json:"buildSha1"` - BuildBranch string `json:"buildBranch"` - Features []BrooklynFeatureSummary `json:"features"` -} - -type BrooklynFeatureSummary struct { - Name string `json:"name"` - SymbolicName string `json:"symbolicName"` - Version string `json:"version"` - LastModified string `json:"lastModified"` - AdditionalData map[string]string `json:"additionalData"` -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/net/net.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/net/net.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/net/net.go deleted file mode 100644 index 7b49475..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/net/net.go +++ /dev/null @@ -1,156 +0,0 @@ -package net - -import ( - "bytes" - "encoding/json" - "errors" - "io" - "io/ioutil" - "net/http" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" -) - -type Network struct { - BrooklynUrl string - BrooklynUser string - BrooklynPass string -} - -func NewNetwork(brooklynUrl, brooklynUser, brooklynPass string) (net *Network) { - net = new(Network) - net.BrooklynUrl = brooklynUrl - net.BrooklynUser = brooklynUser - net.BrooklynPass = brooklynPass - return -} - -func (net *Network) NewRequest(method, path string, body io.Reader) *http.Request { - req, _ := http.NewRequest(method, net.BrooklynUrl+path, body) - req.SetBasicAuth(net.BrooklynUser, net.BrooklynPass) - return req -} - -func (net *Network) NewGetRequest(url string) *http.Request { - return net.NewRequest("GET", url, nil) -} - -func (net *Network) NewPostRequest(url string, body io.Reader) *http.Request { - return net.NewRequest("POST", url, body) -} - -func (net *Network) NewDeleteRequest(url string) *http.Request { - return net.NewRequest("DELETE", url, nil) -} - -type HttpError struct { - Code int - Status string - Headers http.Header - Body string -} - -func (err HttpError) Error() string { - return err.Status -} - -func makeError(resp *http.Response, code int, body []byte) error { - theError := HttpError{ - Code: code, - Status: resp.Status, - Headers: resp.Header, - } - details := make(map[string]string) - if err := json.Unmarshal(body, &details); nil == err { - if message, ok := details["message"]; ok { - theError.Body = message - return theError - } - } - theError.Body = string(body) - return theError -} - -func (net *Network) SendRequest(req *http.Request) ([]byte, error) { - client := &http.Client{} - resp, err := client.Do(req) - if err != nil { - return nil, err - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if code, failed := unsuccessful(resp.Status); failed { - return nil, makeError(resp, code, body) - } - return body, err -} - -const httpSuccessSeriesFrom = 200 -const httpSuccessSeriesTo = 300 - -func unsuccessful(status string) (int, bool) { - tokens := strings.Split(status, " ") - if 0 == len(tokens) { - return -1, false - } - code, err := strconv.Atoi(tokens[0]) - if nil != err { - return -1, false - } - return code, code < httpSuccessSeriesFrom || httpSuccessSeriesTo <= code -} - -func (net *Network) SendGetRequest(url string) ([]byte, error) { - req := net.NewGetRequest(url) - req.Header.Set("Accept", "application/json, text/plain") - body, err := net.SendRequest(req) - return body, err -} - -func (net *Network) SendDeleteRequest(url string) ([]byte, error) { - req := net.NewDeleteRequest(url) - body, err := net.SendRequest(req) - return body, err -} - -func (net *Network) SendEmptyPostRequest(url string) ([]byte, error) { - req := net.NewPostRequest(url, nil) - body, err := net.SendRequest(req) - return body, err -} - -func (net *Network) SendPostRequest(urlStr string, data []byte) ([]byte, error) { - req := net.NewPostRequest(urlStr, bytes.NewBuffer(data)) - req.Header.Set("Content-Type", "application/json") - body, err := net.SendRequest(req) - return body, err -} - -func (net *Network) SendPostFileRequest(url, filePath string, contentType string) ([]byte, error) { - file, err := os.Open(filepath.Clean(filePath)) - if err != nil { - return nil, err - } - defer file.Close() - req := net.NewPostRequest(url, file) - req.Header.Set("Content-Type", contentType) - body, err := net.SendRequest(req) - return body, err -} - -func VerifyLoginURL(network *Network) error { - url, err := url.Parse(network.BrooklynUrl) - if err != nil { - return err - } - if url.Scheme != "http" && url.Scheme != "https" { - return errors.New("Use login command to set Brooklyn URL with a scheme of \"http\" or \"https\"") - } - if url.Host == "" { - return errors.New("Use login command to set Brooklyn URL with a valid host[:port]") - } - return nil -} http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/81853355/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/scope/scope.go ---------------------------------------------------------------------- diff --git a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/scope/scope.go b/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/scope/scope.go deleted file mode 100644 index 6ecf406..0000000 --- a/br/Godeps/_workspace/src/github.com/apache/brooklyn-client/scope/scope.go +++ /dev/null @@ -1,119 +0,0 @@ -package scope - -import ( - "strings" -) - -type Scope struct { - Application string - Entity string - Effector string - Config string - Activity string -} - -func (scope Scope) String() string { - return strings.Join([]string{ - "{Application: ", scope.Application, - ", Entity: ", scope.Entity, - ", Effector: ", scope.Effector, - ", Config: ", scope.Config, - ", Activity: ", scope.Activity, - "}", - }, "") -} - -func application(scope *Scope, id string) { - scope.Application = id -} - -func entity(scope *Scope, id string) { - scope.Entity = id -} - -func effector(scope *Scope, id string) { - scope.Effector = id -} - -func config(scope *Scope, id string) { - scope.Config = id -} - -func activity(scope *Scope, id string) { - scope.Activity = id -} - -var scopeSpecifier = map[string]func(scope *Scope, id string){ - "application": application, - "app": application, - "a": application, - "entity": entity, - "ent": entity, - "e": entity, - "effector": effector, - "eff": effector, - "f": effector, - "config": config, - "conf": config, - "con": config, - "c": config, - "activity": activity, - "act": activity, - "v": activity, -} - -// Scopes the arguments. -// Assumes the arguments are a copy of the program args, including the first member that defines the program name. -// Removes the scope arguments from the array and applies them to a scope object. -// Returns the remaining arguments with the program name restored to first argument. -// For example with input -// br application 1 entity 2 doSomething -// the function will return ([]string{"br", "doSomething"}, Scope{Application:1, Entity:2}) -func ScopeArguments(args []string) ([]string, Scope) { - scope := Scope{} - - if len(args) < 2 { - return args, scope - } - - command := args[0] - args = args[1:] - - args = defineScope(args, &scope) - - args = prepend(command, args) - - return args, scope -} - -func defineScope(args []string, scope *Scope) []string { - - allScopesFound := false - for !allScopesFound && len(args) > 2 && args[1][0] != '-' { - if setAppropriateScope, nameOfAScope := scopeSpecifier[args[0]]; nameOfAScope { - setAppropriateScope(scope, args[1]) - args = args[2:] - } else { - allScopesFound = true - } - } - - setDefaultEntityIfRequired(scope) - - return args -} - -func setDefaultEntityIfRequired(scope *Scope) { - if "" == scope.Entity { - scope.Entity = scope.Application - } -} - -func prepend(v string, args []string) []string { - result := make([]string, len(args)+1) - result[0] = v - for i, a := range args { - result[i+1] = a - } - return result -}