You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by an...@apache.org on 2016/09/10 17:14:42 UTC
[05/10] brooklyn-client git commit: move rest-client to
brooklyn-client
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/build.sh
----------------------------------------------------------------------
diff --git a/cli/release/build.sh b/cli/release/build.sh
new file mode 100755
index 0000000..dfee050
--- /dev/null
+++ b/cli/release/build.sh
@@ -0,0 +1,283 @@
+#!/usr/bin/env bash
+# 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.
+
+
+#
+# Constants
+#
+OSVALUES="darwin freebsd linux netbsd openbsd windows"
+ARCHVALUES="386 amd64"
+BRNAME="br"
+GOPACKAGE="github.com/apache/brooklyn-client/${BRNAME}"
+PROJECT="github.com/apache/brooklyn-client"
+CLI_PACKAGE="${PROJECT}/${BRNAME}"
+GOBIN=go
+GLIDE=glide
+
+START_TIME=$(date +%s)
+
+#
+# Globals
+#
+os=""
+arch=""
+all=""
+outdir="."
+sourcedir="."
+label=""
+timestamp=""
+
+builds=(
+ darwin/amd64
+ linux/386
+ windows/386
+)
+
+show_help() {
+ echo "Usage: $0 [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -o <OS> -a <ARCH> [-d <DIRECTORY>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -A [-d <OUTPUTDIR>] [-l <LABEL>] [-t] -s <SOURCEDIR>"
+ echo " $0 -h"
+ echo
+ cat <<-EOH
+ -A Build for default OS/ARCH combinations
+ -a Set ARCH to build for
+ -d Set output directory
+ -h Show help
+ -l Set label text for including in filename
+ -o Set OS to build for
+ -t Set timestamp for including in filename
+ -s Source directory
+
+EOH
+
+ echo $OSVALUES | awk 'BEGIN{printf("Supported OS:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
+ echo $ARCHVALUES | awk 'BEGIN{printf("Supported ARCH:\n")};{for(i=1;i<=NF;i++){printf("\t%s\n",$i)}}'
+ echo Default build:
+ for build in ${builds[@]} ; do
+ printf "\t%s\n" $build
+ done
+}
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -h|help)
+ show_help
+ exit 0
+ ;;
+ -d)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for OUTPUTDIR must be provided"
+ exit 1
+ fi
+ outdir="$2"
+ shift 2
+ ;;
+ -s)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for SOURCEDIR must be provided"
+ exit 1
+ fi
+ sourcedir="$2"
+ shift 2
+ ;;
+ -o)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for OS must be provided"
+ exit 1
+ fi
+ os="$2"
+ shift 2
+ ;;
+ -a)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for ARCH must be provided"
+ exit 1
+ fi
+ arch="$2"
+ shift 2
+ ;;
+ -A)
+ all="all"
+ shift 1
+ ;;
+ -l)
+ if [ $# -lt 2 ]; then
+ show_help
+ echo "Value for LABEL must be provided"
+ exit 1
+ fi
+ label=".$2"
+ shift 2
+ ;;
+ -t)
+ timestamp=`date +.%Y%m%d-%H%M%S`
+ shift
+ ;;
+ *)
+ show_help
+ echo "Unrecognised parameter: $1"
+ exit 1
+ ;;
+ esac
+done
+
+echo "Starting build.sh (brooklyn-client go build script)"
+
+#
+# Test if go is available
+#
+if ! command -v $GOBIN >/dev/null 2>&1 ; then
+ cat 1>&2 << \
+--MARKER--
+
+ERROR: Go language binaries not found (running "$GOBIN")
+
+The binaries for go v1.6 must be installed to build the brooklyn-client CLI.
+See golang.org for more information, or run maven with '-Dno-go-client' to skip.
+
+--MARKER--
+ exit 1
+fi
+
+GO_VERSION=`go version | awk '{print $3}'`
+GO_V=`echo $GO_VERSION | sed 's/^go1\.\([0-9][0-9]*\).*/\1/'`
+# test if not okay so error shows if regex above not matched
+if ! (( "$GO_V" >= 6 )) ; then
+ cat 1>&2 << \
+--MARKER--
+
+ERROR: Incompatible Go language version: $GO_VERSION
+
+Go version 1.6 or higher is required to build the brooklyn-client CLI.
+See golang.org for more information, or run maven with '-Dno-go-client' to skip.
+
+--MARKER--
+ exit 1
+fi
+
+
+if [ -n "$outdir" -a ! -d "$outdir" ]; then
+ show_help
+ echo "No such directory: $outdir"
+ exit 1
+fi
+
+# Set GOPATH to $outdir and link to source code.
+export GOPATH=${outdir}
+mkdir -p ${GOPATH}/src/${PROJECT%/*}
+[ -e ${GOPATH}/src/${PROJECT} ] || ln -s ${sourcedir} ${GOPATH}/src/${PROJECT}
+PATH=${GOPATH}/bin:${PATH}
+
+command -v $GLIDE >/dev/null 2>&1 || {
+ echo Installing $GLIDE
+ go get github.com/Masterminds/glide || { echo failed installing $GLIDE ; exit 1; }
+}
+
+command -v $GLIDE >/dev/null 2>&1 || {
+ echo "Command for resolving dependencies ($GLIDE) not found and could not be installed in $GOPATH"
+ exit 1
+}
+
+echo "Installing dependencies"
+$GLIDE install
+
+if [ -n "$all" -a \( -n "$os" -o -n "$arch" \) ]; then
+ show_help
+ echo "OS and ARCH must not be combined with ALL"
+ exit 1
+fi
+
+if [ \( -n "$os" -a -z "$arch" \) -o \( -z "$os" -a -n "$arch" \) ]; then
+ show_help
+ echo "OS and ARCH must be specified"
+ exit 1
+fi
+
+EXECUTABLE_DIR="$GOPATH/src/$CLI_PACKAGE"
+if [ -d ${EXECUTABLE_DIR} ]; then
+ cd ${EXECUTABLE_DIR}
+else
+ echo "Directory not found: ${EXECUTABLE_DIR}"
+ exit 2
+fi
+
+mkdir -p ${GOPATH}/bin
+
+# Disable use of C code modules (causes problems with cross-compiling)
+export CGO_ENABLED=0
+
+# build requested file
+function build_cli () {
+ local filepath=$1
+ mkdir -p ${filepath%/*}
+ $GOBIN build -ldflags "-s" -o $filepath $CLI_PACKAGE || return $?
+}
+
+# Do a build for one platorm, usage like: build_for_platform darwin/amd64
+function build_for_platform () {
+ local os=${1%/*}
+ local arch=${1#*/}
+ local BINARY=${BRNAME}
+ if [ "windows" = $os ] ; then
+ BINARY=${BINARY}.exe
+ fi
+ GOOS="$os" GOARCH="$arch" build_cli "${GOPATH}/bin/$os.$arch/${BINARY}${label}" || return $?
+}
+
+# Build as instructed
+if [ -z "$os" -a -z "$all" ]; then
+ echo "Building $BRNAME for native OS/ARCH"
+ build_cli "${GOPATH}/bin/${BRNAME}${label}${timestamp}" || exit $?
+elif [ -z "$all" ]; then
+ validos=`expr " $OSVALUES " : ".* $os "`
+ if [ "$validos" -eq 0 ]; then
+ show_help
+ echo "Unrecognised OS: $os"
+ exit 1
+ fi
+ validarch=`expr " $ARCHVALUES " : ".* $arch "`
+ if [ "$validarch" -eq 0 ]; then
+ show_help
+ echo "Unrecognised ARCH: $arch"
+ exit 1
+ fi
+ echo "Building $BRNAME for $os/$arch:"
+ build_for_platform $os/$arch || exit $?
+else
+ echo "Building $BRNAME for default OS/ARCH:"
+ for build in ${builds[@]}; do
+ echo " $build"
+ build_for_platform $build || exit $?
+ done
+fi
+
+echo
+echo Successfully built the following binaries:
+echo
+ls -lR ${GOPATH}/bin
+echo
+
+END_TIME=$(date +%s)
+echo "Completed build.sh (brooklyn-client go build script) in $(( $END_TIME - START_TIME ))s"
+
+exit 0
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/files/README
----------------------------------------------------------------------
diff --git a/cli/release/files/README b/cli/release/files/README
new file mode 100644
index 0000000..da1f0a0
--- /dev/null
+++ b/cli/release/files/README
@@ -0,0 +1,42 @@
+
+Apache Brooklyn Command Line Client
+===================================
+
+What is it?
+-----------
+
+A command line client, "br", for **[Apache Brooklyn](https://brooklyn.apache.org)**.
+
+With this tool you can deploy and manage applications on a running Brooklyn server.
+
+This file gives a brief summary of how to use the Brooklyn CLI client tool.
+More complete documentation is available **[on the Apache Brooklyn website](https://brooklyn.apache.org/v/latest/ops/cli/cli-ref-guide.html).
+
+
+License
+-------
+
+Please see the file [LICENSE](LICENSE).
+
+
+Getting Started
+---------------
+
+Find the binary which is right for your platform.
+You'll typically find it in a sub-directory here.
+(Note that "Darwin" is a technical name for "Mac OS X".)
+
+Add it to your path or alias it with `br`.
+
+Then log in to your Brooklyn instance with:
+
+ $ br login URL [USER PASSWORD]
+
+See the help command for info on all commands:
+
+ $ br help
+
+For help on individual commands:
+
+ $ br help COMMAND
+
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/license/files/LICENSE
----------------------------------------------------------------------
diff --git a/cli/release/license/files/LICENSE b/cli/release/license/files/LICENSE
new file mode 100644
index 0000000..9764158
--- /dev/null
+++ b/cli/release/license/files/LICENSE
@@ -0,0 +1,445 @@
+
+This software is distributed under the Apache License, version 2.0. See (1) below.
+This software is copyright (c) The Apache Software Foundation and contributors.
+
+Contents:
+
+ (1) This software license: Apache License, version 2.0
+ (2) Notices for bundled software
+ (3) Licenses for bundled software
+
+
+---------------------------------------------------
+
+(1) This software license: Apache License, version 2.0
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+
+---------------------------------------------------
+
+(2) Notices for bundled software
+
+This project includes the software: github.com/urfave/cli
+ Available at: https://github.com/urfave/cli
+ Used under the following license: The MIT License (http://opensource.org/licenses/MIT)
+ Copyright (C) 2013 Jeremy Saenz
+
+This project includes the software: golang.org/x/crypto/ssh
+ Available at: https://godoc.org/golang.org/x/crypto/ssh
+ Used under the following license: The BSD 3-Clause (New BSD) License (http://opensource.org/licenses/BSD-3-Clause)
+ Copyright (c) 2009 The Go Authors. All rights reserved.
+
+
+---------------------------------------------------
+
+(3) Licenses for bundled software
+
+Contents:
+
+ Apache License, Version 2.0
+ The BSD 3-Clause License ("New BSD")
+ The MIT License ("MIT")
+
+
+Apache License, Version 2.0
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+
+The BSD 3-Clause License ("New BSD")
+
+ Redistribution and use in source and binary forms, with or without modification,
+ are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the copyright holder nor the names of its contributors
+ may be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+
+
+The MIT License ("MIT")
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+
+
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/release/license/source-inclusions.yaml
----------------------------------------------------------------------
diff --git a/cli/release/license/source-inclusions.yaml b/cli/release/license/source-inclusions.yaml
new file mode 100644
index 0000000..dddc9dc
--- /dev/null
+++ b/cli/release/license/source-inclusions.yaml
@@ -0,0 +1,24 @@
+#
+# 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.
+#
+
+# extras file for org.heneveld.license-audit-maven-plugin
+# listing projects from which *source* files are included
+
+- id: github.com/urfave/cli
+- id: golang.org/x/crypto/ssh
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/scope/scope.go
----------------------------------------------------------------------
diff --git a/cli/scope/scope.go b/cli/scope/scope.go
new file mode 100644
index 0000000..9332c4a
--- /dev/null
+++ b/cli/scope/scope.go
@@ -0,0 +1,137 @@
+/*
+ * 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 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
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/terminal/table.go
----------------------------------------------------------------------
diff --git a/cli/terminal/table.go b/cli/terminal/table.go
new file mode 100644
index 0000000..c163318
--- /dev/null
+++ b/cli/terminal/table.go
@@ -0,0 +1,102 @@
+/*
+ * 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 terminal
+
+import (
+ "fmt"
+ "strings"
+ "unicode/utf8"
+)
+
+type Table interface {
+ Add(row ...string)
+ Print()
+}
+
+type PrintableTable struct {
+ headers []string
+ headerPrinted bool
+ maxSizes []int
+ rows [][]string
+}
+
+func NewTable(headers []string) Table {
+ return &PrintableTable{
+ headers: headers,
+ maxSizes: make([]int, len(headers)),
+ }
+}
+
+func (t *PrintableTable) Add(row ...string) {
+ t.rows = append(t.rows, row)
+}
+
+func (t *PrintableTable) Print() {
+ for _, row := range append(t.rows, t.headers) {
+ t.calculateMaxSize(row)
+ }
+
+ if t.headerPrinted == false {
+ t.printHeader()
+ t.headerPrinted = true
+ }
+
+ for _, line := range t.rows {
+ t.printRow(line)
+ }
+
+ t.rows = [][]string{}
+}
+
+func (t *PrintableTable) calculateMaxSize(row []string) {
+ for index, value := range row {
+ cellLength := utf8.RuneCountInString(value)
+ if t.maxSizes[index] < cellLength {
+ t.maxSizes[index] = cellLength
+ }
+ }
+}
+
+func (t *PrintableTable) printHeader() {
+ output := ""
+ for col, value := range t.headers {
+ output = output + t.cellValue(col, value)
+ }
+ fmt.Println(output)
+}
+
+func (t *PrintableTable) printRow(row []string) {
+ output := ""
+ for columnIndex, value := range row {
+ if columnIndex == 0 {
+ value = value
+ }
+
+ output = output + t.cellValue(columnIndex, value)
+ }
+ fmt.Printf("%s\n", output)
+}
+
+func (t *PrintableTable) cellValue(col int, value string) string {
+ padding := ""
+ if col < len(t.headers)-1 {
+ padding = strings.Repeat(" ", t.maxSizes[col]-utf8.RuneCountInString(value))
+ }
+ return fmt.Sprintf("%s%s ", value, padding)
+}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/test/test.sh
----------------------------------------------------------------------
diff --git a/cli/test/test.sh b/cli/test/test.sh
new file mode 100644
index 0000000..7f86538
--- /dev/null
+++ b/cli/test/test.sh
@@ -0,0 +1,226 @@
+#!/usr/bin/env bash
+# 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.
+
+declare -a FAILS
+
+export BRCLI_HOME=/tmp
+trap cleanup EXIT
+
+
+function usage() {
+ echo "Usage: $0 <brooklyn_url> [ <user> <password> ]"
+ exit 0
+}
+
+
+function cleanup() {
+ rm -f $BRCLI_HOME/.brooklyn_cli
+}
+
+function title() {
+ echo "*************************************************************************"
+ echo " ${FUNCNAME[1]}"
+ echo "*************************************************************************"
+}
+
+function fail() {
+ local code=$?
+ local message="$*"
+ FAILS[${#FAILS[*]}]="${FUNCNAME[1]}: (${code}) ${message}"
+}
+
+function report() {
+ if [ 0 -ne ${#FAILS[*]} ] ; then
+ echo " ${#FAILS[*]} Test failures" 1>&2
+ else
+ echo All tests succeeded
+ fi
+ local n=0
+ while [ $n -lt ${#FAILS[*]} ] ; do
+ echo ${FAILS[$N]} 1>&2
+ n=$(( $n + 1 ))
+ done
+}
+
+
+function isAppStatus() {
+ local appname=$1
+ local status=$2
+ br apps | grep "${appname}" | grep ${status} > /dev/null
+}
+
+function isEntityStatus() {
+ local appname=$1
+ local entity=$2
+ local status=$3
+
+ br app "${appname}" ent "${entity}" | grep ${status} > /dev/null
+}
+
+function waitForCommand() {
+ local N=300 # 5 minutes
+ while [ $N -gt 0 ] && ! "$@" ; do
+ sleep 1
+ N=$(($N - 1))
+ done
+ if [ $N -eq 0 ] ; then
+ return 1
+ fi
+ return 0
+}
+
+
+
+function brIsDefined() {
+ type br > /dev/null 2>&1
+}
+
+
+#
+# TESTS
+#
+
+function shouldLogin() {
+ title
+ br login $1 $2 $3 || fail
+}
+
+
+
+function shouldDeployTomcat() {
+ title
+
+ br deploy test_app.yaml
+
+ waitForCommand isAppStatus "Test Tomcat" RUNNING || fail
+}
+
+function shouldRenameApp() {
+ title
+ local appname=$1
+ local rename=$2
+
+ br app "${appname}" rename "${rename}"
+
+ br apps | grep "${rename}" | grep RUNNING || fail
+}
+
+function shouldGetAppConfig() {
+ title
+ local appname=$1
+ br app "${appname}" config | grep brooklyn.wrapper_app | grep true || fail
+}
+
+function shouldGetTomcatServerEntity() {
+ title
+ local appname=$1
+
+ br app "${appname}" entity | grep TomcatServer || fail
+}
+
+
+function shouldRenameTomcatServerEntity() {
+ title
+ local appname=$1
+ local rename=$2
+
+ br app "${appname}" entity "Tomcat Server" rename "${rename}"
+ br app "${appname}" entity "${rename}" | grep TomcatServer || fail
+}
+
+function shouldStopEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" ent "${entityname}" stop
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" STOPPED || fail; return
+}
+
+function shouldRestartEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" restart "${entityname}"
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
+}
+
+function shouldStartEntity() {
+ title
+ local appname=$1
+ local entityname=$2
+
+ br app "${appname}" start "${entityname}"
+
+ waitForCommand isEntityStatus "${appname}" "${entityname}" RUNNING || fail; return
+}
+
+
+function runAllTests() {
+
+ local brooklyn_url=${1}
+ local user=${2}
+ local password=${3}
+
+ shouldLogin ${brooklyn_url} ${user} ${password}
+ shouldDeployTomcat
+ shouldRenameApp "Test Tomcat" mytest
+ shouldGetAppConfig mytest
+ shouldGetTomcatServerEntity mytest
+ shouldRenameTomcatServerEntity mytest myserver
+ shouldStopEntity mytest myserver
+ shouldStartEntity mytest myserver
+ shouldRestartEntity mytest myserver
+
+
+ #... TODO add more tests here
+}
+
+#
+# main function
+#
+function main() {
+
+ [ $1 ] || usage
+
+ local brooklyn_url=${1}
+ local user=${2}
+ local password=${3}
+
+ brIsDefined || {
+ >&2 echo br is not defined
+ exit 1
+ }
+
+ runAllTests ${brooklyn_url} ${user} ${password}
+
+ # If there are test failures we leave the application running, in case it helps determine what failed.
+ if [ 0 -eq ${#FAILS[*]} ] ; then
+ echo Stopping test application
+ br app mytest stop
+ fi
+
+ report
+
+}
+
+main $@
+exit ${#FAILS[*]}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/cli/test/test_app.yaml
----------------------------------------------------------------------
diff --git a/cli/test/test_app.yaml b/cli/test/test_app.yaml
new file mode 100644
index 0000000..f5e9abe
--- /dev/null
+++ b/cli/test/test_app.yaml
@@ -0,0 +1,22 @@
+# 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.
+
+name: Test Tomcat
+location:
+ replaceMeWithYourLocation
+services:
+ - type: org.apache.brooklyn.entity.webapp.tomcat.TomcatServer
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command/command.go
----------------------------------------------------------------------
diff --git a/command/command.go b/command/command.go
deleted file mode 100644
index 1a16282..0000000
--- a/command/command.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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
-
-import (
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/scope"
- "github.com/urfave/cli"
-)
-
-type Command interface {
- Metadata() command_metadata.CommandMetadata
- Run(scope scope.Scope, context *cli.Context)
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command/supercommand.go
----------------------------------------------------------------------
diff --git a/command/supercommand.go b/command/supercommand.go
deleted file mode 100644
index 82a5856..0000000
--- a/command/supercommand.go
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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
-
-// A command with further (sub) commands, like 'git remote', with its 'git remote add' etc.
-type SuperCommand interface {
- Command
-
- // Get the sub command wih the given name
- SubCommand(name string) Command
-
- // Get the names of all subcommands
- SubCommandNames() []string
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command_factory/factory.go
----------------------------------------------------------------------
diff --git a/command_factory/factory.go b/command_factory/factory.go
deleted file mode 100644
index 7a46eb9..0000000
--- a/command_factory/factory.go
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * 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_factory
-
-import (
- "errors"
- "github.com/apache/brooklyn-client/command"
- "github.com/apache/brooklyn-client/command_metadata"
- "github.com/apache/brooklyn-client/commands"
- "github.com/apache/brooklyn-client/io"
- "github.com/apache/brooklyn-client/net"
- "sort"
- "strings"
-)
-
-type Factory interface {
- GetByCmdName(cmdName string) (cmd command.Command, err error)
- GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error)
- CommandMetadatas() []command_metadata.CommandMetadata
-}
-
-type concreteFactory struct {
- cmdsByName map[string]command.Command
- subCommands map[string]map[string]command.Command
-}
-
-func NewFactory(network *net.Network, config *io.Config) (factory concreteFactory) {
- factory.cmdsByName = make(map[string]command.Command)
- factory.subCommands = make(map[string]map[string]command.Command)
-
- factory.simpleCommand(commands.NewAccess(network))
- //factory.command(commands.NewActivities(network))
- factory.simpleCommand(commands.NewActivity(network))
- factory.simpleCommand(commands.NewActivityStreamEnv(network))
- factory.simpleCommand(commands.NewActivityStreamStderr(network))
- factory.simpleCommand(commands.NewActivityStreamStdin(network))
- factory.simpleCommand(commands.NewActivityStreamStdout(network))
- factory.simpleCommand(commands.NewAddCatalog(network))
- factory.simpleCommand(commands.NewAddChildren(network))
- factory.simpleCommand(commands.NewApplication(network))
- //factory.simpleCommand(commands.NewApplications(network))
- factory.simpleCommand(commands.NewCatalog(network))
- factory.simpleCommand(commands.NewConfig(network))
- factory.simpleCommand(commands.NewDeploy(network))
- factory.simpleCommand(commands.NewDelete(network))
- factory.simpleCommand(commands.NewDestroyPolicy(network))
- factory.simpleCommand(commands.NewEffector(network))
- factory.simpleCommand(commands.NewEntity(network))
- factory.simpleCommand(commands.NewInvoke(network))
- factory.simpleCommand(commands.NewInvokeRestart(network))
- factory.simpleCommand(commands.NewInvokeStart(network))
- factory.simpleCommand(commands.NewInvokeStop(network))
- // NewList below is not used but we retain the code as an example of how to do a super command.
- // factory.superCommand(commands.NewList(network))
- factory.simpleCommand(commands.NewLocations(network))
- factory.simpleCommand(commands.NewLogin(network, config))
- factory.simpleCommand(commands.NewPolicy(network))
- factory.simpleCommand(commands.NewRename(network))
- factory.simpleCommand(commands.NewSensor(network))
- factory.simpleCommand(commands.NewSetConfig(network))
- factory.simpleCommand(commands.NewSpec(network))
- factory.simpleCommand(commands.NewStartPolicy(network))
- factory.simpleCommand(commands.NewStopPolicy(network))
- factory.simpleCommand(commands.NewTree(network))
- factory.simpleCommand(commands.NewVersion(network))
-
- return factory
-}
-
-func (factory *concreteFactory) simpleCommand(cmd command.Command) {
- factory.cmdsByName[cmd.Metadata().Name] = cmd
-}
-
-func (factory *concreteFactory) superCommand(cmd command.SuperCommand) {
-
- factory.simpleCommand(cmd)
-
- if nil == factory.subCommands[cmd.Metadata().Name] {
- factory.subCommands[cmd.Metadata().Name] = make(map[string]command.Command)
- }
-
- for _, sub := range cmd.SubCommandNames() {
- factory.subCommands[cmd.Metadata().Name][sub] = cmd.SubCommand(sub)
- }
-}
-
-func (f concreteFactory) GetByCmdName(cmdName string) (cmd command.Command, err error) {
- cmd, found := f.cmdsByName[cmdName]
- if !found {
- for _, c := range f.cmdsByName {
- if c.Metadata().ShortName == cmdName {
- return c, nil
- }
- }
-
- err = errors.New(strings.Join([]string{"Command not found:", cmdName}, " "))
- }
- return
-}
-
-func (f concreteFactory) GetBySubCmdName(cmdName string, subCmdName string) (cmd command.Command, err error) {
-
- _, hasPrimary := f.subCommands[cmdName]
- if hasPrimary {
- cmd, found := f.subCommands[cmdName][subCmdName]
- if found {
- return cmd, nil
- }
- }
- return cmd, errors.New(strings.Join([]string{"Command not found:", cmdName, subCmdName}, " "))
-}
-
-func (factory concreteFactory) CommandMetadatas() (commands []command_metadata.CommandMetadata) {
- keys := make([]string, 0, len(factory.cmdsByName))
- for key := range factory.cmdsByName {
- keys = append(keys, key)
- }
- sort.Strings(keys)
-
- for _, key := range keys {
- command := factory.cmdsByName[key]
- commands = append(commands, command.Metadata())
- }
- return
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-client/blob/4122cfe1/command_metadata/command_metadata.go
----------------------------------------------------------------------
diff --git a/command_metadata/command_metadata.go b/command_metadata/command_metadata.go
deleted file mode 100644
index eac321f..0000000
--- a/command_metadata/command_metadata.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/command_runner/runner.go
----------------------------------------------------------------------
diff --git a/command_runner/runner.go b/command_runner/runner.go
deleted file mode 100644
index c123b5f..0000000
--- a/command_runner/runner.go
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/access.go
----------------------------------------------------------------------
diff --git a/commands/access.go b/commands/access.go
deleted file mode 100644
index 87e26cd..0000000
--- a/commands/access.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/activity-stream.go
----------------------------------------------------------------------
diff --git a/commands/activity-stream.go b/commands/activity-stream.go
deleted file mode 100644
index eceadc4..0000000
--- a/commands/activity-stream.go
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/activity.go
----------------------------------------------------------------------
diff --git a/commands/activity.go b/commands/activity.go
deleted file mode 100644
index d748c1a..0000000
--- a/commands/activity.go
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/add-catalog.go
----------------------------------------------------------------------
diff --git a/commands/add-catalog.go b/commands/add-catalog.go
deleted file mode 100644
index b161f8b..0000000
--- a/commands/add-catalog.go
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * 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/urfave/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 (a file or http URL)",
- Usage: "BROOKLYN_NAME add-catalog ( FILEPATH | URL )",
- 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/4122cfe1/commands/add-children.go
----------------------------------------------------------------------
diff --git a/commands/add-children.go b/commands/add-children.go
deleted file mode 100644
index d05a114..0000000
--- a/commands/add-children.go
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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/urfave/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 | URL )",
- 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/4122cfe1/commands/add-location.go
----------------------------------------------------------------------
diff --git a/commands/add-location.go b/commands/add-location.go
deleted file mode 100644
index 32c2db0..0000000
--- a/commands/add-location.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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/4122cfe1/commands/add-policy.go
----------------------------------------------------------------------
diff --git a/commands/add-policy.go b/commands/add-policy.go
deleted file mode 100644
index 35de8c4..0000000
--- a/commands/add-policy.go
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/application.go
----------------------------------------------------------------------
diff --git a/commands/application.go b/commands/application.go
deleted file mode 100644
index c321227..0000000
--- a/commands/application.go
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- * 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/urfave/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/4122cfe1/commands/catalog-applications.go
----------------------------------------------------------------------
diff --git a/commands/catalog-applications.go b/commands/catalog-applications.go
deleted file mode 100644
index 19a4373..0000000
--- a/commands/catalog-applications.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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/4122cfe1/commands/catalog-entities.go
----------------------------------------------------------------------
diff --git a/commands/catalog-entities.go b/commands/catalog-entities.go
deleted file mode 100644
index dbec760..0000000
--- a/commands/catalog-entities.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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/4122cfe1/commands/catalog-entity.go
----------------------------------------------------------------------
diff --git a/commands/catalog-entity.go b/commands/catalog-entity.go
deleted file mode 100644
index 23cc295..0000000
--- a/commands/catalog-entity.go
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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
-}