Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial new vmc client

Change-Id: Icb16e01b17adfcc6b0e1141ee7b10fa93a8eec8b
  • Loading branch information...
commit 53b0332ddcfece573668c0539629ac5dfd936b95 1 parent 1f3d1f3
@vito vito authored
Showing with 2,528 additions and 7,209 deletions.
  1. +4 −4 .gitignore
  2. +0 −3  .gitmodules
  3. +1 −1  Gemfile
  4. +736 −14 LICENSE
  5. +7 −0 NOTICE
  6. +0 −102 README.md
  7. +1 −101 Rakefile
  8. +0 −15 TODO
  9. +10 −2 bin/vmc
  10. +0 −10 caldecott_helper/Gemfile
  11. +0 −48 caldecott_helper/Gemfile.lock
  12. +0 −43 caldecott_helper/server.rb
  13. +0 −17 config/clients.yml
  14. +0 −2  config/micro/offline.conf
  15. +0 −22 config/micro/paths.yml
  16. +0 −20 config/micro/refresh_ip.rb
  17. +0 −47 lib/cli.rb
  18. +0 −80 lib/cli/commands/admin.rb
  19. +0 −1,126 lib/cli/commands/apps.rb
  20. +0 −227 lib/cli/commands/base.rb
  21. +0 −56 lib/cli/commands/manifest.rb
  22. +0 −115 lib/cli/commands/micro.rb
  23. +0 −129 lib/cli/commands/misc.rb
  24. +0 −180 lib/cli/commands/services.rb
  25. +0 −65 lib/cli/commands/user.rb
  26. +0 −173 lib/cli/config.rb
  27. +0 −160 lib/cli/console_helper.rb
  28. +0 −122 lib/cli/core_ext.rb
  29. +0 −19 lib/cli/errors.rb
  30. +0 −265 lib/cli/frameworks.rb
  31. +0 −302 lib/cli/manifest_helper.rb
  32. +0 −531 lib/cli/runner.rb
  33. +0 −84 lib/cli/services_helper.rb
  34. +0 −332 lib/cli/tunnel_helper.rb
  35. +0 −115 lib/cli/usage.rb
  36. +0 −7 lib/cli/version.rb
  37. +0 −77 lib/cli/zip_util.rb
  38. +2 −3 lib/vmc.rb
  39. +271 −0 lib/vmc/cli.rb
  40. +596 −0 lib/vmc/cli/app.rb
  41. +444 −0 lib/vmc/cli/command.rb
  42. +133 −0 lib/vmc/cli/dots.rb
  43. +113 −0 lib/vmc/cli/service.rb
  44. +71 −0 lib/vmc/cli/user.rb
  45. +0 −471 lib/vmc/client.rb
  46. +0 −22 lib/vmc/const.rb
  47. +10 −0 lib/vmc/constants.rb
  48. +64 −0 lib/vmc/detect.rb
  49. +0 −56 lib/vmc/micro.rb
  50. +0 −97 lib/vmc/micro/switcher/base.rb
  51. +0 −19 lib/vmc/micro/switcher/darwin.rb
  52. +0 −15 lib/vmc/micro/switcher/dummy.rb
  53. +0 −16 lib/vmc/micro/switcher/linux.rb
  54. +0 −31 lib/vmc/micro/switcher/windows.rb
  55. +0 −158 lib/vmc/micro/vmrun.rb
  56. +40 −0 lib/vmc/plugin.rb
  57. +3 −0  lib/vmc/version.rb
  58. +0 −9 spec/assets/app_info.txt
  59. +0 −9 spec/assets/app_listings.txt
  60. +0 −9 spec/assets/bad_create_app.txt
  61. +0 −2  spec/assets/console_access.txt
  62. +0 −9 spec/assets/delete_app.txt
  63. +0 −9 spec/assets/global_service_listings.txt
  64. +0 −9 spec/assets/good_create_app.txt
  65. +0 −9 spec/assets/good_create_service.txt
  66. +0 −27 spec/assets/info_authenticated.txt
  67. +0 −15 spec/assets/info_return.txt
  68. +0 −16 spec/assets/info_return_bad.txt
  69. +0 −1  spec/assets/invalid_console_access.txt
  70. +0 −13 spec/assets/list_users.txt
  71. +0 −9 spec/assets/login_fail.txt
  72. +0 −9 spec/assets/login_success.txt
  73. +0 −1  spec/assets/manifests/bad-manifest.yml
  74. +0 −2  spec/assets/manifests/my-manifest.yml
  75. +0 −2  spec/assets/manifests/someapp/manifest.yml
  76. 0  spec/assets/manifests/someapp/somedir/somesubdir/.gitignore
  77. 0  spec/assets/manifests/somenomanifestapp/.gitignore
  78. +0 −8 spec/assets/manifests/sub-manifest.yml
  79. +0 −47 spec/assets/manifests/sym-manifest.yml
  80. +0 −9 spec/assets/resources_return.txt
  81. +0 −1  spec/assets/sample_token.txt
  82. +0 −9 spec/assets/service_already_exists.txt
  83. +0 −9 spec/assets/service_gateway_fail.txt
  84. +0 −9 spec/assets/service_listings.txt
  85. +0 −9 spec/assets/service_not_found.txt
  86. +0 −9 spec/assets/standalone_app_info.txt
  87. +0 −9 spec/assets/user_info.txt
  88. +0 −13 spec/spec_helper.rb
  89. +0 −104 spec/unit/cli_opts_spec.rb
  90. +0 −345 spec/unit/client_spec.rb
  91. +0 −247 spec/unit/command_apps_spec.rb
  92. +0 −228 spec/unit/console_helper_spec.rb
  93. +0 −258 spec/unit/frameworks_spec.rb
  94. +0 −123 spec/unit/manifests_spec.rb
  95. +0 −34 spec/unit/micro_cmd_spec.rb
  96. +0 −22 spec/unit/switcher_spec.rb
  97. +0 −23 spec/unit/vmrun_spec.rb
  98. +22 −29 vmc.gemspec
View
8 .gitignore
@@ -1,5 +1,5 @@
-Gemfile.lock
-!caldecott_helper/Gemfile.lock
-.build
*.gem
-.DS_Store
+.rbenv-gemsets
+.bundle
+Gemfile.lock
+pkg/*
View
3  .gitmodules
@@ -1,3 +0,0 @@
-[submodule "spec/assets/tests"]
- path = spec/assets/tests
- url = https://github.com/cloudfoundry/vcap-test-assets.git
View
2  Gemfile
@@ -1,4 +1,4 @@
source "http://rubygems.org"
+# Specify your gem's dependencies in cf.gemspec
gemspec
-
View
750 LICENSE
@@ -1,24 +1,746 @@
-Copyright (c) 2010-2011 VMware Inc, All Rights Reserved
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
-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:
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+ 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.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
+=======================================================================
+
+VMC-Lib 1.0 GA:
+
+VMC-Lib 1.0 includes a number of subcomponents with
+separate copyright notices and license terms. The product that
+includes this file does not necessarily use all the open source
+subcomponents referred to below. Your use of the source
+code for the these subcomponents is subject to the terms and
+conditions of the following licenses.
+
+
+SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR
+
+ >>> cf-0.1.4
+ >>> cfoundry-0.1.1
+ >>> diff-lcs-1.1.3
+ >>> interact-0.4.2
+ >>> manifests-vmc-plugin-0.1.0
+ >>> rest-client-1.6.7
+ >>> rspec-2.10.0
+ >>> rspec-core-2.10.0
+ >>> rspec-expectations-2.10.0
+ >>> rspec-mocks-2.10.1
+ >>> thor-0.14.6
+
+
+
+SECTION 2: Ruby Clause-6
+
+ >>> json_pure-1.6.7
+ >>> mime-types-1.18
+ >>> rubyzip-0.9.8
+
+
+
+APPENDIX. Standard License Files
+
+ >>> Ruby Clause-6
+
+
+
+--------------- SECTION 1: BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES ----------
+
+BSD-STYLE, MIT-STYLE, OR SIMILAR STYLE LICENSES are applicable to the following component(s).
+
+
+>>> cf-0.1.4
+
+Copyright (c)2012, Alex Suraci
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * 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.
+
+ * Neither the name of Alex Suraci nor the names of other
+ 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
+OWNER 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.
+
+
+>>> cfoundry-0.1.1
+
+Copyright (c)2012, Alex Suraci
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * 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.
+
+ * Neither the name of Alex Suraci nor the names of other
+ 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
+OWNER 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.
+
+
+>>> diff-lcs-1.1.3
+
+[PLEASE NOTE: VMWARE, INC. ELECTS TO USE AND DISTRIBUTE THIS COMPONENT UNDER THE TERMS OF THE MIT LICENSE. PLEASE SEE BELOW FOR THE FULL TEXT OF THE MIT LICENSE. THE ORIGINAL LICENSE TERMS ARE REPRODUCED BELOW ONLY AS A REFERENCE.]
+
+
+== License
+
+This software is available under three licenses: the GNU GPL version 2 (or at
+your option, a later version), the Perl Artistic license, or the MIT license.
+Note that my preference for licensing is the MIT license, but Algorithm::Diff
+was dually originally licensed with the Perl Artistic and the GNU GPL ("the
+same terms as Perl itself") and that the Ruby implementation hews pretty
+closely to the Perl version, so I must maintain the additional licensing terms.
+
+* Copyright 20042011 Austin Ziegler.
+* Adapted from Algorithm::Diff (Perl) by Ned Konz and a Smalltalk versionby
+ Mario I. Wolczko <mario@wolczko.com>
+
+=== MIT License
+
+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.
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+=== Perl Artistic License (version 2)
+See the file docs/artistic.txt in the main distribution.
+
+=== GNU GPL version 2
+See the file docs/COPYING.txt in the main distribution.
+
+
+>>> interact-0.4.2
+
+Copyright (c)2011, Alex Suraci
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ * 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.
+
+ * Neither the name of Alex Suraci nor the names of other
+ 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
+OWNER 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.
+
+
+>>> manifests-vmc-plugin-0.1.0
+
+Copyright (c) 2012, Alex Suraci
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+
+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.
+
+Neither the name of Alex Suraci nor the names of other 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 OWNER 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.
+
+
+>>> rest-client-1.6.7
+
+Released under the MIT License: http://www.opensource.org/licenses/mit-license.php
+
+Copyright (c) 2003, 2004 Jim Weirich
+
+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.
+
+
+>>> rspec-2.10.0
+
+(The MIT License)
+
+Copyright (c) 2009 Chad Humphries, David Chelimsky
+Copyright (c) 2006 David Chelimsky, The RSpec Development Team
+Copyright (c) 2005 Steven Baker
+
+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.
+
+
+>>> rspec-core-2.10.0
+
+The MIT License
+
+Copyright (c) 2009 Chad Humphries, David Chelimsky
+
+Copyright (c) 2006 David Chelimsky, The RSpec Development Team
+
+Copyright (c) 2005 Steven Baker
+
+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.
+
+
+>>> rspec-expectations-2.10.0
+
+(The MIT License)
+
+Copyright (c) 2006 David Chelimsky, The RSpec Development Team
+Copyright (c) 2005 Steven Baker
+
+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.
+
+
+>>> rspec-mocks-2.10.1
+
+(The MIT License)
+
+Copyright (c) 2006 David Chelimsky, The RSpec Development Team
+Copyright (c) 2005 Steven Baker
+
+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.
+
+
+>>> thor-0.14.6
+
+Copyright (c) 2008 Yehuda Katz
+
+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.
+
+
+--------------- SECTION 2: Ruby Clause-6 ----------
+
+Ruby Clause-6 are applicable to the following component(s).
+
+
+>>> json_pure-1.6.7
+
+[PLEASE NOTE: VMWARE, INC. ELECTS TO USE AND DISTRIBUTE THIS COMPONENT UNDER THE TERMS OF THE RUBY LICENSE STATED BELOW. THE ORIGINAL LICENSE TERMS ARE REPRODUCED BELOW ONLY AS A REFERENCE.]
+
+
+JSON-JRuby is copyrighted free software by Daniel Luz <mernen at gmail dot com>,
+and is a derivative work of Florian Frank's json library <flori at ping dot de>.
+You can redistribute it and/or modify it under either the terms of the GPL
+version 2 (see the file GPL), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 3. You may distribute the software in object code or binary form,
+ provided that you do at least ONE of the following:
+
+ a) distribute the binaries and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard binaries non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under these terms.
+
+ For the list of those files and their copying conditions, see the
+ file LEGAL.
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+
+>>> mime-types-1.18
+
+[PLEASE NOTE: VMWARE, INC. ELECTS TO USE AND DISTRIBUTE THIS COMPONENT UNDER THE TERMS OF THE RUBY LICENSE. PLEASE SEE THE APPENDIX TO REVIEW THE FULL TEXT OF RUBY LICENSE. THE ORIGINAL LICENSE TERMS ARE REPRODUCED BELOW ONLY AS A REFERENCE.]
+
+== Licence
+
+This software is available under a triple disjunctive licence:
+{Ruby's licence}[http://www.ruby-lang.org/en/LICENSE.txt],
+the
+{Perl Artistic licence}[http://www.perl.com/pub/a/language/misc/Artistic.html],
+or the {GNU GPL version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html]
+(or at your option, any later verison).
+
+If you do not accept one of these licences, you may not use this software.
+
+* Copyright 20032012 Austin Ziegler.
+
+
+>>> rubyzip-0.9.8
+
+Copyright (C) 2002, 2003 Thomas Sondergaard
+ rubyzip is free software; you can redistribute it and/or
+ modify it under the terms of the ruby license.
+
+
+=============== APPENDIX. Standard License Files ==============
+
+
+
+--------------- SECTION 1: Ruby Clause-6 -----------
+
+Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
+You can redistribute it and/or modify it under either the terms of the GPL
+(see COPYING.txt file), or the conditions below:
+
+ 1. You may make and give away verbatim copies of the source form of the
+ software without restriction, provided that you duplicate all of the
+ original copyright notices and associated disclaimers.
+
+
+ 2. You may modify your copy of the software in any way, provided that
+ you do at least ONE of the following:
+
+ a) place your modifications in the Public Domain or otherwise
+ make them Freely Available, such as by posting said
+ modifications to Usenet or an equivalent medium, or by allowing
+ the author to include your modifications in the software.
+
+ b) use the modified software only within your corporation or
+ organization.
+
+ c) rename any non-standard executables so the names do not conflict
+ with standard executables, which must also be provided.
+
+ d) make other distribution arrangements with the author.
+
+
+ 3. You may distribute the software in object code or executable
+ form, provided that you do at least ONE of the following:
+
+ a) distribute the executables and library files of the software,
+ together with instructions (in the manual page or equivalent)
+ on where to get the original distribution.
+
+ b) accompany the distribution with the machine-readable source of
+ the software.
+
+ c) give non-standard executables non-standard names, with
+ instructions on where to get the original software distribution.
+
+ d) make other distribution arrangements with the author.
+
+
+ 4. You may modify and include the part of the software into any other
+ software (possibly commercial). But some files in the distribution
+ are not written by the author, so that they are not under this terms.
+
+ They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
+ files under the ./missing directory. See each file for the copying
+ condition.
+
+
+ 5. The scripts and library files supplied as input to or produced as
+ output from the software do not automatically fall under the
+ copyright of the software, but belong to whomever generated them,
+ and may be sold commercially, and may be aggregated with this
+ software.
+
+
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+
+===========================================================================
-This software downloads additional open source software components upon install
-that are distributed under separate terms and conditions. Please see the license
-information provided in the individual software components for more information.
+To the extent any open source components are licensed under the
+GPL and/or LGPL, or other similar licenses that require the
+source code and/or modifications to source code to be made
+available (as would be noted above), you may obtain a copy of
+the source code corresponding to the binaries for such open
+source components and modifications thereto, if any, (the
+"Source Files"), by downloading the Source Files from VMware's website at
+http://www.vmware.com/download/open_source.html, or by sending a request, with
+your name and address to: VMware, Inc., 3401 Hillview Avenue,
+Palo Alto, CA 94304,United States of America. All such
+requests should clearly specify: OPEN SOURCE FILES REQUEST,
+Attention General Counsel. VMware shall mail a copy of the
+Source Files to you on a CD or equivalent physical medium. This
+offer to obtain a copy of the Source Files is valid for three
+years from the date you acquired this Software product. Alternatively,
+the Source Files may accompany the VMware product.
+[MAPLE-VMC10GAKV051412]
View
7 NOTICE
@@ -0,0 +1,7 @@
+VMC-Lib
+Copyright (c) 2012 VMware, Inc. All Rights Reserved.
+
+VMware copyrighted code, is licensed to you under the Apache License, Version 2.0 (the "License").
+
+In addition to the VMware copyrighted code, VMC includes a number of components with separate copyright notices and license terms. Your use of these components is subject to the terms and conditions of the component's license, as noted in the LICENSE file.
+
View
102 README.md
@@ -1,102 +0,0 @@
-# VMC
-
-The VMware Cloud CLI. This is the command line interface to VMware's Application Platform
-
-_Copyright 2010-2011, VMware, Inc. Licensed under the
-MIT license, please see the LICENSE file. All rights reserved._
-
- Usage: vmc [options] command [<args>] [command_options]
- Try 'vmc help [command]' or 'vmc help options' for more information.
-
- Currently available vmc commands are:
-
- Getting Started
- target [url] Reports current target or sets a new target
- login [email] [--email, --passwd] Login
- info System and account information
-
- Applications
- apps List deployed applications
-
- Application Creation
- push [appname] Create, push, map, and start a new application
- push [appname] --path Push application from specified path
- push [appname] --url Set the url for the application
- push [appname] --instances <N> Set the expected number <N> of instances
- push [appname] --mem M Set the memory reservation for the application
- push [appname] --no-start Do not auto-start the application
-
- Application Operations
- start <appname> Start the application
- stop <appname> Stop the application
- restart <appname> Restart the application
- delete <appname> Delete the application
-
- Application Updates
- update <appname> [--path] Update the application bits
- mem <appname> [memsize] Update the memory reservation for an application
- map <appname> <url> Register the application to the url
- unmap <appname> <url> Unregister the application from the url
- instances <appname> <num|delta> Scale the application instances up or down
-
- Application Information
- crashes <appname> List recent application crashes
- crashlogs <appname> Display log information for crashed applications
- logs <appname> [--all] Display log information for the application
- files <appname> [path] [--all] Display directory listing or file download for path
- stats <appname> Display resource usage for the application
- instances <appname> List application instances
-
- Application Environment
- env <appname> List application environment variables
- env-add <appname> <variable[=]value> Add an environment variable to an application
- env-del <appname> <variable> Delete an environment variable to an application
-
- Services
- services Lists of services available and provisioned
- create-service <service> [--name,--bind] Create a provisioned service
- create-service <service> <name> Create a provisioned service and assign it <name>
- create-service <service> <name> <app> Create a provisioned service and assign it <name>, and bind to <app>
- delete-service [servicename] Delete a provisioned service
- bind-service <servicename> <appname> Bind a service to an application
- unbind-service <servicename> <appname> Unbind service from the application
- clone-services <src-app> <dest-app> Clone service bindings from <src-app> application to <dest-app>
- tunnel <servicename> [--port] Create a local tunnel to a service
- tunnel <servicename> <clientcmd> Create a local tunnel to a service and start a local client
-
- Administration
- user Display user account information
- passwd Change the password for the current user
- logout Logs current user out of the target system
- add-user [--email, --passwd] Register a new user (requires admin privileges)
- delete-user <user> Delete a user and all apps and services (requires admin privileges)
-
- System
- runtimes Display the supported runtimes of the target system
- frameworks Display the recognized frameworks of the target system
-
- Micro Cloud Foundry
- micro status Display Micro Cloud Foundry VM status
- mciro offline Configure Micro Cloud Foundry VM for offline mode
- micro online Configure Micro Cloud Foundry VM for online mode
- [--vmx file] Path to micro.vmx
- [--vmrun executable] Path to vmrun executable
- [--password cleartext] Cleartext password for guest VM vcap user
- [--save] Save cleartext password in ~/.vmc_micro
-
- Misc
- aliases List aliases
- alias <alias[=]command> Create an alias for a command
- unalias <alias> Remove an alias
- targets List known targets and associated authorization tokens
-
- Help
- help [command] Get general help or help on a specific command
- help options Get help on available options
-
-## Simple Story (for Ruby apps)
-
- vmc target api.cloudfoundry.com
- vmc login
- bundle package
- vmc push
View
102 Rakefile
@@ -1,101 +1 @@
-require 'rake'
-require 'spec/rake/spectask'
-
-desc "Run specs"
-task :spec => :build do
- Spec::Rake::SpecTask.new('spec') do |t|
- t.spec_opts = %w(-fs -c)
- t.spec_files = FileList['spec/**/*_spec.rb']
- end
-end
-
-desc "Synonym for spec"
-task :test => :spec
-desc "Synonym for spec"
-task :tests => :spec
-task :default => :spec
-
-def tests_path
- if @tests_path == nil
- @tests_path = File.join(Dir.pwd, "spec/assets/tests")
- end
- @tests_path
-end
-TESTS_PATH = tests_path
-
-BUILD_ARTIFACT = File.join(Dir.pwd, "spec/assets/.build")
-
-TESTS_TO_BUILD = ["#{TESTS_PATH}/java_web/java_tiny_app",
-# "#{TESTS_PATH}/grails/guestbook",
- "#{TESTS_PATH}/lift/hello_lift",
- "#{TESTS_PATH}/spring/roo-guestbook",
- "#{TESTS_PATH}/spring/spring-osgi-hello",
- "#{TESTS_PATH}/standalone/java_app",
- "#{TESTS_PATH}/standalone/python_app"
- ]
-
-desc "Build the tests. If the git hash associated with the test assets has not changed, nothing is built. To force a build, invoke 'rake build[--force]'"
-task :build, [:force] do |t, args|
- sh('bundle install')
- sh('git submodule update --init')
- puts "\nBuilding tests"
- if build_required? args.force
- ENV['MAVEN_OPTS']="-XX:MaxPermSize=256M"
- TESTS_TO_BUILD.each do |test|
- puts "\tBuilding '#{test}'"
- Dir.chdir test do
- sh('mvn package -DskipTests') do |success, exit_code|
- unless success
- clear_build_artifact
- do_mvn_clean('-q')
- fail "\tFailed to build #{test} - aborting build"
- end
- end
- end
- puts "\tCompleted building '#{test}'"
- end
- save_git_hash
- else
- puts "Built artifacts in sync with test assets - no build required"
- end
-end
-
-desc "Clean the build artifacts"
-task :clean do
- puts "\nCleaning tests"
- clear_build_artifact
- TESTS_TO_BUILD.each do |test|
- puts "\tCleaning '#{test}'"
- Dir.chdir test do
- do_mvn_clean
- end
- puts "\tCompleted cleaning '#{test}'"
- end
-end
-
-def build_required? (force_build=nil)
- if File.exists?(BUILD_ARTIFACT) == false or (force_build and force_build == "--force")
- return true
- end
- Dir.chdir(tests_path) do
- saved_git_hash = IO.readlines(BUILD_ARTIFACT)[0].split[0]
- git_hash = `git rev-parse --short=8 --verify HEAD`
- saved_git_hash.to_s.strip != git_hash.to_s.strip
- end
-end
-
-def save_git_hash
- Dir.chdir(tests_path) do
- git_hash = `git rev-parse --short=8 --verify HEAD`
- File.open(BUILD_ARTIFACT, 'w') {|f| f.puts("#{git_hash}")}
- end
-end
-
-def clear_build_artifact
- puts "\tClearing build artifact #{BUILD_ARTIFACT}"
- File.unlink BUILD_ARTIFACT if File.exists? BUILD_ARTIFACT
-end
-
-def do_mvn_clean options=nil
- sh("mvn clean #{options}")
-end
+require "bundler/gem_tasks"
View
15 TODO
@@ -1,15 +0,0 @@
-
-1. Use json load trick to load faster if available, fallback to json_pure. Change :symbols
-2. [DONE] Don't flush on :clear for percentage counter
-3. [DONE] Add --no-resource-check, should not do anything with war file but send it, e.g. no pack/unpack
-4. [DONE] Do auto-check on size of stuff to send? Don't bother with resources if small?
-5. [DONE] Do --log-prefix and also add --all to logs command[s]
-6. [DONE] fix aliases with no file
-7. [DONE] See if loading classes inside of requires save startup times.
-8. Add timeout for vmair?
-9. [DONE] register auto logs in if not logged in
-10. [DONE] Fix continous errors on push while checking start (start method)
-11. [DONE] zip filters [~ .idea, etc]
-12. [DONE] Make work with json on 1.9.2
-13. [DONE] Go back and match README
-14. Delete service remove from all apps? Causes 500 on actions to app afterwards.
View
12 bin/vmc
@@ -1,6 +1,14 @@
#!/usr/bin/env ruby
+# vim: ft=ruby
-require File.expand_path('../../lib/cli', __FILE__)
+require "rubygems"
+require "thor"
-VMC::Cli::Runner.run(ARGV.dup)
+require "vmc"
+require "vmc/plugin"
+VMC::Plugin.load_all
+
+$exit_status = 0
+VMC::CLI.start(ARGV)
+exit($exit_status)
View
10 caldecott_helper/Gemfile
@@ -1,10 +0,0 @@
-source "http://rubygems.org"
-
-gem 'rack', '~> 1.2.0'
-gem 'caldecott', '= 0.0.3'
-gem 'bundler'
-gem 'em-websocket'
-gem 'async_sinatra'
-gem 'thin'
-gem 'json'
-gem 'uuidtools'
View
48 caldecott_helper/Gemfile.lock
@@ -1,48 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- addressable (2.2.6)
- async_sinatra (0.5.0)
- rack (>= 1.2.1)
- sinatra (>= 1.0)
- caldecott (0.0.3)
- addressable (= 2.2.6)
- async_sinatra (= 0.5.0)
- em-http-request (= 0.3.0)
- em-websocket (= 0.3.1)
- json (= 1.6.1)
- uuidtools (= 2.1.2)
- daemons (1.1.4)
- em-http-request (0.3.0)
- addressable (>= 2.0.0)
- escape_utils
- eventmachine (>= 0.12.9)
- em-websocket (0.3.1)
- addressable (>= 2.1.1)
- eventmachine (>= 0.12.9)
- escape_utils (0.2.4)
- eventmachine (0.12.10)
- json (1.6.1)
- rack (1.2.4)
- sinatra (1.2.7)
- rack (~> 1.1)
- tilt (>= 1.2.2, < 2.0)
- thin (1.2.11)
- daemons (>= 1.0.9)
- eventmachine (>= 0.12.6)
- rack (>= 1.0.0)
- tilt (1.3.3)
- uuidtools (2.1.2)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- async_sinatra
- bundler
- caldecott (= 0.0.3)
- em-websocket
- json
- rack (~> 1.2.0)
- thin
- uuidtools
View
43 caldecott_helper/server.rb
@@ -1,43 +0,0 @@
-#!/usr/bin/env ruby
-# Copyright (c) 2009-2011 VMware, Inc.
-$:.unshift(File.dirname(__FILE__) + '/lib')
-
-require 'rubygems'
-require 'bundler/setup'
-
-require 'caldecott'
-require 'sinatra'
-require 'json'
-require 'eventmachine'
-
-port = ENV['VMC_APP_PORT']
-port ||= 8081
-
-# add vcap specific stuff to Caldecott
-class VcapHttpTunnel < Caldecott::Server::HttpTunnel
- get '/info' do
- { "version" => '0.0.4' }.to_json
- end
-
- def self.get_tunnels
- super
- end
-
- get '/services' do
- services_env = ENV['VMC_SERVICES']
- return "no services env" if services_env.nil? or services_env.empty?
- services_env
- end
-
- get '/services/:service' do |service_name|
- services_env = ENV['VMC_SERVICES']
- not_found if services_env.nil?
-
- services = JSON.parse(services_env)
- service = services.find { |s| s["name"] == service_name }
- not_found if service.nil?
- service["options"].to_json
- end
-end
-
-VcapHttpTunnel.run!(:port => port, :auth_token => ENV["CALDECOTT_AUTH"])
View
17 config/clients.yml
@@ -1,17 +0,0 @@
-redis:
- redis-cli: -h ${host} -p ${port} -a ${password}
-
-mysql:
- mysql: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name}
- mysqldump: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name} > ${Output file}
-
-mongodb:
- mongo: --host ${host} --port ${port} -u ${user} -p ${password} ${name}
- mongodump: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name}
- mongorestore: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name} ${Directory or filename to restore from}
-
-postgresql:
- psql:
- command: -h ${host} -p ${port} -d ${name} -U ${user} -w
- environment:
- - PGPASSWORD='${password}'
View
2  config/micro/offline.conf
@@ -1,2 +0,0 @@
-no-resolv
-log-queries
View
22 config/micro/paths.yml
@@ -1,22 +0,0 @@
-darwin:
- vmrun:
- - "/Applications/VMware Fusion.app/Contents/Library/"
- - "/Applications/Fusion.app/Contents/Library/"
- vmx:
- - "~/Documents/Virtual Machines.localized/"
- - "~/Documents/Virtual Machines/"
- - "~/Desktop/"
-
-linux:
- vmrun:
- - "/usr/bin/"
- vmx:
- - "~/"
-
-windows:
- vmrun:
- - "c:\\Program Files (x86)\\"
- - "c:\\Program Files\\"
- vmx:
- - "~\\Documents\\"
- - "~\\Desktop\\"
View
20 config/micro/refresh_ip.rb
@@ -1,20 +0,0 @@
-#!/var/vcap/bosh/bin/ruby
-require 'socket'
-
-A_ROOT_SERVER = '198.41.0.4'
-
-begin
-retries ||= 0
-route ||= A_ROOT_SERVER
-orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
-ip_address = UDPSocket.open {|s| s.connect(route, 1); s.addr.last }
-rescue Errno::ENETUNREACH
- # happens on boot when dhcp hasn't completed when we get here
- sleep 3
- retries += 1
- retry if retries < 10
-ensure
- Socket.do_not_reverse_lookup = orig
-end
-
-File.open("/tmp/ip.txt", 'w') { |file| file.write(ip_address) }
View
47 lib/cli.rb
@@ -1,47 +0,0 @@
-require "rbconfig"
-
-ROOT = File.expand_path(File.dirname(__FILE__))
-WINDOWS = !!(RbConfig::CONFIG['host_os'] =~ /mingw|mswin32|cygwin/)
-
-module VMC
- autoload :Client, "#{ROOT}/vmc/client"
- autoload :Micro, "#{ROOT}/vmc/micro"
-
- module Micro
- module Switcher
- autoload :Base, "#{ROOT}/vmc/micro/switcher/base"
- autoload :Darwin, "#{ROOT}/vmc/micro/switcher/darwin"
- autoload :Dummy, "#{ROOT}/vmc/micro/switcher/dummy"
- autoload :Linux, "#{ROOT}/vmc/micro/switcher/linux"
- autoload :Windows, "#{ROOT}/vmc/micro/switcher/windows"
- end
- autoload :VMrun, "#{ROOT}/vmc/micro/vmrun"
- end
-
- module Cli
- autoload :Config, "#{ROOT}/cli/config"
- autoload :Framework, "#{ROOT}/cli/frameworks"
- autoload :Runner, "#{ROOT}/cli/runner"
- autoload :ZipUtil, "#{ROOT}/cli/zip_util"
- autoload :ServicesHelper, "#{ROOT}/cli/services_helper"
- autoload :TunnelHelper, "#{ROOT}/cli/tunnel_helper"
- autoload :ManifestHelper, "#{ROOT}/cli/manifest_helper"
- autoload :ConsoleHelper, "#{ROOT}/cli/console_helper"
-
- module Command
- autoload :Base, "#{ROOT}/cli/commands/base"
- autoload :Admin, "#{ROOT}/cli/commands/admin"
- autoload :Apps, "#{ROOT}/cli/commands/apps"
- autoload :Micro, "#{ROOT}/cli/commands/micro"
- autoload :Misc, "#{ROOT}/cli/commands/misc"
- autoload :Services, "#{ROOT}/cli/commands/services"
- autoload :User, "#{ROOT}/cli/commands/user"
- autoload :Manifest, "#{ROOT}/cli/commands/manifest"
- end
-
- end
-end
-
-require "#{ROOT}/cli/version"
-require "#{ROOT}/cli/core_ext"
-require "#{ROOT}/cli/errors"
View
80 lib/cli/commands/admin.rb
@@ -1,80 +0,0 @@
-module VMC::Cli::Command
-
- class Admin < Base
-
- def list_users
- users = client.users
- users.sort! {|a, b| a[:email] <=> b[:email] }
- return display JSON.pretty_generate(users || []) if @options[:json]
-
- display "\n"
- return display "No Users" if users.nil? || users.empty?
-
- users_table = table do |t|
- t.headings = 'Email', 'Admin', 'Apps'
- users.each do |user|
- t << [user[:email], user[:admin], user[:apps].map {|x| x[:name]}.join(', ')]
- end
- end
- display users_table
- end
-
- alias :users :list_users
-
- def add_user(email=nil)
- email ||= @options[:email]
- email ||= ask("Email") unless no_prompt
- password = @options[:password]
- unless no_prompt || password
- password = ask("Password", :echo => "*")
- password2 = ask("Verify Password", :echo => "*")
- err "Passwords did not match, try again" if password != password2
- end
- err "Need a valid email" unless email
- err "Need a password" unless password
- display 'Creating New User: ', false
- client.add_user(email, password)
- display 'OK'.green
-
- # if we are not logged in for the current target, log in as the new user
- return unless VMC::Cli::Config.auth_token.nil?
- @options[:password] = password
- cmd = User.new(@options)
- cmd.login(email)
- end
-
- def delete_user(user_email)
- # Check to make sure all apps and services are deleted before deleting the user
- # implicit proxying
-
- client.proxy_for(user_email)
- @options[:proxy] = user_email
- apps = client.apps
-
- if (apps && !apps.empty?)
- unless no_prompt
- proceed = ask(
- "\nDeployed applications and associated services will be DELETED, continue?",
- :default => false
- )
- err "Aborted" unless proceed
- end
- cmd = Apps.new(@options.merge({ :force => true }))
- apps.each { |app| cmd.delete(app[:name]) }
- end
-
- services = client.services
- if (services && !services.empty?)
- cmd = Services.new(@options)
- services.each { |s| cmd.delete_service(s[:name])}
- end
-
- display 'Deleting User: ', false
- client.proxy = nil
- client.delete_user(user_email)
- display 'OK'.green
- end
-
- end
-
-end
View
1,126 lib/cli/commands/apps.rb
@@ -1,1126 +0,0 @@
-require 'digest/sha1'
-require 'fileutils'
-require 'pathname'
-require 'tempfile'
-require 'tmpdir'
-require 'set'
-require "uuidtools"
-require 'socket'
-
-module VMC::Cli::Command
-
- class Apps < Base
- include VMC::Cli::ServicesHelper
- include VMC::Cli::ManifestHelper
- include VMC::Cli::TunnelHelper
- include VMC::Cli::ConsoleHelper
-
- def list
- apps = client.apps
- apps.sort! {|a, b| a[:name] <=> b[:name] }
- return display JSON.pretty_generate(apps || []) if @options[:json]
-
- display "\n"
- return display "No Applications" if apps.nil? || apps.empty?
-
- apps_table = table do |t|
- t.headings = 'Application', '# ', 'Health', 'URLS', 'Services'
- apps.each do |app|
- t << [app[:name], app[:instances], health(app), app[:uris].join(', '), app[:services].join(', ')]
- end
- end
- display apps_table
- end
-
- alias :apps :list
-
- SLEEP_TIME = 1
- LINE_LENGTH = 80
-
- # Numerators are in secs
- TICKER_TICKS = 25/SLEEP_TIME
- HEALTH_TICKS = 5/SLEEP_TIME
- TAIL_TICKS = 45/SLEEP_TIME
- GIVEUP_TICKS = 120/SLEEP_TIME
-
- def info(what, default=nil)
- @options[what] || (@app_info && @app_info[what.to_s]) || default
- end
-
- def console(appname, interactive=true)
- unless defined? Caldecott
- display "To use `vmc rails-console', you must first install Caldecott:"
- display ""
- display "\tgem install caldecott"
- display ""
- display "Note that you'll need a C compiler. If you're on OS X, Xcode"
- display "will provide one. If you're on Windows, try DevKit."
- display ""
- display "This manual step will be removed in the future."
- display ""
- err "Caldecott is not installed."
- end
-
- #Make sure there is a console we can connect to first
- conn_info = console_connection_info appname
-
- port = pick_tunnel_port(@options[:port] || 20000)
-
- raise VMC::Client::AuthError unless client.logged_in?
-
- if not tunnel_pushed?
- display "Deploying tunnel application '#{tunnel_appname}'."
- auth = UUIDTools::UUID.random_create.to_s
- push_caldecott(auth)
- start_caldecott
- else
- auth = tunnel_auth
- end
-
- if not tunnel_healthy?(auth)
- display "Redeploying tunnel application '#{tunnel_appname}'."
- # We don't expect caldecott not to be running, so take the
- # most aggressive restart method.. delete/re-push
- client.delete_app(tunnel_appname)
- invalidate_tunnel_app_info
- push_caldecott(auth)
- start_caldecott
- end
-
- start_tunnel(port, conn_info, auth)
- wait_for_tunnel_start(port)
- start_local_console(port, appname) if interactive
- port
- end
-
- def start(appname=nil, push=false)
- if appname
- do_start(appname, push)
- else
- each_app do |name|
- do_start(name, push)
- end
- end
- end
-
- def stop(appname=nil)
- if appname
- do_stop(appname)
- else
- reversed = []
- each_app do |name|
- reversed.unshift name
- end
-
- reversed.each do |name|
- do_stop(name)
- end
- end
- end
-
- def restart(appname=nil)
- stop(appname)
- start(appname)
- end
-
- def mem(appname, memsize=nil)
- app = client.app_info(appname)
- mem = current_mem = mem_quota_to_choice(app[:resources][:memory])
- memsize = normalize_mem(memsize) if memsize
-
- memsize ||= ask(
- "Update Memory Reservation?",
- :default => current_mem,
- :choices => mem_choices
- )
-
- mem = mem_choice_to_quota(mem)
- memsize = mem_choice_to_quota(memsize)
- current_mem = mem_choice_to_quota(current_mem)
-
- display "Updating Memory Reservation to #{mem_quota_to_choice(memsize)}: ", false
-
- # check memsize here for capacity
- check_has_capacity_for((memsize - mem) * app[:instances])
-
- mem = memsize
-
- if (mem != current_mem)
- app[:resources][:memory] = mem
- client.update_app(appname, app)
- display 'OK'.green
- restart appname if app[:state] == 'STARTED'
- else
- display 'OK'.green
- end
- end
-
- def map(appname, url)
- app = client.app_info(appname)
- uris = app[:uris] || []
- uris << url
- app[:uris] = uris
- client.update_app(appname, app)
- display "Successfully mapped url".green
- end
-
- def unmap(appname, url)
- app = client.app_info(appname)
- uris = app[:uris] || []
- url = url.gsub(/^http(s*):\/\//i, '')
- deleted = uris.delete(url)
- err "Invalid url" unless deleted
- app[:uris] = uris
- client.update_app(appname, app)
- display "Successfully unmapped url".green
- end
-
- def delete(appname=nil)
- force = @options[:force]
- if @options[:all]
- if no_prompt || force || ask("Delete ALL applications?", :default => false)
- apps = client.apps
- apps.each { |app| delete_app(app[:name], force) }
- end
- else
- err 'No valid appname given' unless appname
- delete_app(appname, force)
- end
- end
-
- def files(appname, path='/')
- return all_files(appname, path) if @options[:all] && !@options[:instance]
- instance = @options[:instance] || '0'
- content = client.app_files(appname, path, instance)
- display content
- rescue VMC::Client::NotFound, VMC::Client::TargetError
- err 'No such file or directory'
- end
-
- def logs(appname)
- # Check if we have an app before progressing further
- client.app_info(appname)
- return grab_all_logs(appname) if @options[:all] && !@options[:instance]
- instance = @options[:instance] || '0'
- grab_logs(appname, instance)
- end
-
- def crashes(appname, print_results=true, since=0)
- crashed = client.app_crashes(appname)[:crashes]
- crashed.delete_if { |c| c[:since] < since }
- instance_map = {}
-
-# return display JSON.pretty_generate(apps) if @options[:json]
-
-
- counter = 0
- crashed = crashed.to_a.sort { |a,b| a[:since] - b[:since] }
- crashed_table = table do |t|
- t.headings = 'Name', 'Instance ID', 'Crashed Time'
- crashed.each do |crash|
- name = "#{appname}-#{counter += 1}"
- instance_map[name] = crash[:instance]
- t << [name, crash[:instance], Time.at(crash[:since]).strftime("%m/%d/%Y %I:%M%p")]
- end
- end
-
- VMC::Cli::Config.store_instances(instance_map)
-
- if @options[:json]
- return display JSON.pretty_generate(crashed)
- elsif print_results
- display "\n"
- if crashed.empty?
- display "No crashed instances for [#{appname}]" if print_results
- else
- display crashed_table if print_results
- end
- end
-
- crashed
- end
-
- def crashlogs(appname)
- instance = @options[:instance] || '0'
- grab_crash_logs(appname, instance)
- end
-
- def instances(appname, num=nil)
- if num
- change_instances(appname, num)
- else
- get_instances(appname)
- end
- end
-
- def stats(appname=nil)
- if appname
- display "\n", false
- do_stats(appname)
- else
- each_app do |n|
- display "\n#{n}:"
- do_stats(n)
- end
- end
- end
-
- def update(appname=nil)
- if appname
- app = client.app_info(appname)
- if @options[:canary]
- display "[--canary] is deprecated and will be removed in a future version".yellow
- end
- upload_app_bits(appname, @path)
- restart appname if app[:state] == 'STARTED'
- else
- each_app do |name|
- display "Updating application '#{name}'..."
-
- app = client.app_info(name)
- upload_app_bits(name, @application)
- restart name if app[:state] == 'STARTED'
- end
- end
- end
-
- def push(appname=nil)
- unless no_prompt || @options[:path]
- proceed = ask(
- 'Would you like to deploy from the current directory?',
- :default => true
- )
-
- unless proceed
- @path = ask('Deployment path')
- end
- end
-
- pushed = false
- each_app(false) do |name|
- display "Pushing application '#{name}'..." if name
- do_push(name)
- pushed = true
- end
-
- unless pushed
- @application = @path
- do_push(appname)
- end
- end
-
- def environment(appname)
- app = client.app_info(appname)
- env = app[:env] || []
- return display JSON.pretty_generate(env) if @options[:json]
- return display "No Environment Variables" if env.empty?
- etable = table do |t|
- t.headings = 'Variable', 'Value'
- env.each do |e|
- k,v = e.split('=', 2)
- t << [k, v]
- end
- end
- display "\n"
- display etable
- end
-
- def environment_add(appname, k, v=nil)
- app = client.app_info(appname)
- env = app[:env] || []
- k,v = k.split('=', 2) unless v
- env << "#{k}=#{v}"
- display "Adding Environment Variable [#{k}=#{v}]: ", false
- app[:env] = env
- client.update_app(appname, app)
- display 'OK'.green
- restart appname if app[:state] == 'STARTED'
- end
-
- def environment_del(appname, variable)
- app = client.app_info(appname)
- env = app[:env] || []
- deleted_env = nil
- env.each do |e|
- k,v = e.split('=')
- if (k == variable)
- deleted_env = e
- break;
- end
- end
- display "Deleting Environment Variable [#{variable}]: ", false
- if deleted_env
- env.delete(deleted_env)
- app[:env] = env
- client.update_app(appname, app)
- display 'OK'.green
- restart appname if app[:state] == 'STARTED'
- else
- display 'OK'.green
- end
- end
-
- private
-
- def app_exists?(appname)
- app_info = client.app_info(appname)
- app_info != nil
- rescue VMC::Client::NotFound
- false
- end
-
- def check_deploy_directory(path)
- err 'Deployment path does not exist' unless File.exists? path
- return if File.expand_path(Dir.tmpdir) != File.expand_path(path)
- err "Can't deploy applications from staging directory: [#{Dir.tmpdir}]"
- end
-
- def check_unreachable_links(path)
- files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
-
- pwd = Pathname.pwd
-
- abspath = File.expand_path(path)
- unreachable = []
- files.each do |f|
- file = Pathname.new(f)
- if file.symlink? && !file.realpath.to_s.start_with?(abspath)
- unreachable << file.relative_path_from(pwd)
- end
- end
-
- unless unreachable.empty?
- root = Pathname.new(path).relative_path_from(pwd)
- err "Can't deploy application containing links '#{unreachable}' that reach outside its root '#{root}'"
- end
- end
-
- def find_sockets(path)
- files = Dir.glob("#{path}/**/*", File::FNM_DOTMATCH)
- files && files.select { |f| File.socket? f }
- end
-
- def upload_app_bits(appname, path)
- display 'Uploading Application:'
-
- upload_file, file = "#{Dir.tmpdir}/#{appname}.zip", nil
- FileUtils.rm_f(upload_file)
-
- explode_dir = "#{Dir.tmpdir}/.vmc_#{appname}_files"
- FileUtils.rm_rf(explode_dir) # Make sure we didn't have anything left over..
-
- if path =~ /\.(war|zip)$/
- #single file that needs unpacking
- VMC::Cli::ZipUtil.unpack(path, explode_dir)
- elsif !File.directory? path
- #single file that doesn't need unpacking
- FileUtils.mkdir(explode_dir)
- FileUtils.cp(path,explode_dir)
- else
- Dir.chdir(path) do
- # Stage the app appropriately and do the appropriate fingerprinting, etc.
- if war_file = Dir.glob('*.war').first
- VMC::Cli::ZipUtil.unpack(war_file, explode_dir)
- elsif zip_file = Dir.glob('*.zip').first
- VMC::Cli::ZipUtil.unpack(zip_file, explode_dir)
- else
- check_unreachable_links(path)
- FileUtils.mkdir(explode_dir)
-
- files = Dir.glob('{*,.[^\.]*}')
-
- # Do not process .git files
- files.delete('.git') if files
-
- FileUtils.cp_r(files, explode_dir)
-
- find_sockets(explode_dir).each do |s|
- File.delete s
- end
- end
- end
- end
-
- # Send the resource list to the cloudcontroller, the response will tell us what it already has..
- unless @options[:noresources]
- display ' Checking for available resources: ', false
- fingerprints = []
- total_size = 0
- resource_files = Dir.glob("#{explode_dir}/**/*", File::FNM_DOTMATCH)
- resource_files.each do |filename|
- next if (File.directory?(filename) || !File.exists?(filename))
- fingerprints << {
- :size => File.size(filename),
- :sha1 => Digest::SHA1.file(filename).hexdigest,
- :fn => filename
- }
- total_size += File.size(filename)
- end
-
- # Check to see if the resource check is worth the round trip
- if (total_size > (64*1024)) # 64k for now
- # Send resource fingerprints to the cloud controller
- appcloud_resources = client.check_resources(fingerprints)
- end
- display 'OK'.green
-
- if appcloud_resources
- display ' Processing resources: ', false
- # We can then delete what we do not need to send.
- appcloud_resources.each do |resource|
- FileUtils.rm_f resource[:fn]
- # adjust filenames sans the explode_dir prefix
- resource[:fn].sub!("#{explode_dir}/", '')
- end
- display 'OK'.green
- end
-
- end
-
- # If no resource needs to be sent, add an empty file to ensure we have
- # a multi-part request that is expected by nginx fronting the CC.
- if VMC::Cli::ZipUtil.get_files_to_pack(explode_dir).empty?
- Dir.chdir(explode_dir) do
- File.new(".__empty__", "w")
- end
- end
- # Perform Packing of the upload bits here.
- display ' Packing application: ', false
- VMC::Cli::ZipUtil.pack(explode_dir, upload_file)
- display 'OK'.green
-
- upload_size = File.size(upload_file);
- if upload_size > 1024*1024
- upload_size = (upload_size/(1024.0*1024.0)).round.to_s + 'M'
- elsif upload_size > 0
- upload_size = (upload_size/1024.0).round.to_s + 'K'
- else
- upload_size = '0K'
- end
-
- upload_str = " Uploading (#{upload_size}): "
- display upload_str, false
-
- FileWithPercentOutput.display_str = upload_str
- FileWithPercentOutput.upload_size = File.size(upload_file);
- file = FileWithPercentOutput.open(upload_file, 'rb')
-
- client.upload_app(appname, file, appcloud_resources)
- display 'OK'.green if VMC::Cli::ZipUtil.get_files_to_pack(explode_dir).empty?
-
- display 'Push Status: ', false
- display 'OK'.green
-
- ensure
- # Cleanup if we created an exploded directory.
- FileUtils.rm_f(upload_file) if upload_file
- FileUtils.rm_rf(explode_dir) if explode_dir
- end
-
- def check_app_limit
- usage = client_info[:usage]
- limits = client_info[:limits]
- return unless usage and limits and limits[:apps]
- if limits[:apps] == usage[:apps]
- display "Not enough capacity for operation.".red
- tapps = limits[:apps] || 0
- apps = usage[:apps] || 0
- err "Current Usage: (#{apps} of #{tapps} total apps already in use)"
- end
- end
-
- def check_has_capacity_for(mem_wanted)
- usage = client_info[:usage]
- limits = client_info[:limits]
- return unless usage and limits
- available_for_use = limits[:memory].to_i - usage[:memory].to_i
- if mem_wanted > available_for_use
- tmem = pretty_size(limits[:memory]*1024*1024)
- mem = pretty_size(usage[:memory]*1024*1024)
- display "Not enough capacity for operation.".yellow
- available = pretty_size(available_for_use * 1024 * 1024)
- err "Current Usage: (#{mem} of #{tmem} total, #{available} available for use)"
- end
- end
-
- def mem_choices
- default = ['64M', '128M', '256M', '512M', '1G', '2G']
-
- return default unless client_info
- return default unless (usage = client_info[:usage] and limits = client_info[:limits])
-
- available_for_use = limits[:memory].to_i - usage[:memory].to_i
- check_has_capacity_for(64) if available_for_use < 64
- return ['64M'] if available_for_use < 128
- return ['64M', '128M'] if available_for_use < 256
- return ['64M', '128M', '256M'] if available_for_use < 512
- return ['64M', '128M', '256M', '512M'] if available_for_use < 1024
- return ['64M', '128M', '256M', '512M', '1G'] if available_for_use < 2048
- return ['64M', '128M', '256M', '512M', '1G', '2G']
- end
-
- def normalize_mem(mem)
- return mem if /K|G|M/i =~ mem
- "#{mem}M"
- end
-
- def mem_choice_to_quota(mem_choice)
- (mem_choice =~ /(\d+)M/i) ? mem_quota = $1.to_i : mem_quota = mem_choice.to_i * 1024
- mem_quota
- end
-
- def mem_quota_to_choice(mem)
- if mem < 1024
- mem_choice = "#{mem}M"
- else
- mem_choice = "#{(mem/1024).to_i}G"
- end
- mem_choice
- end
-
- def get_instances(appname)
- instances_info_envelope = client.app_instances(appname)
- # Empty array is returned if there are no instances running.
- instances_info_envelope = {} if instances_info_envelope.is_a?(Array)
-
- instances_info = instances_info_envelope[:instances] || []
- instances_info = instances_info.sort {|a,b| a[:index] - b[:index]}
-
- return display JSON.pretty_generate(instances_info) if @options[:json]
-
- return display "No running instances for [#{appname}]".yellow if instances_info.empty?
-
- instances_table = table do |t|
- show_debug = instances_info.any? { |e| e[:debug_port] }
-
- headings = ['Index', 'State', 'Start Time']
- headings << 'Debug IP' if show_debug
- headings << 'Debug Port' if show_debug
-
- t.headings = headings
-
- instances_info.each do |entry|
- row = [entry[:index], entry[:state], Time.at(entry[:since]).strftime("%m/%d/%Y %I:%M%p")]
- row << entry[:debug_ip] if show_debug
- row << entry[:debug_port] if show_debug
- t << row
- end
- end
- display "\n"
- display instances_table
- end
-
- def change_instances(appname, instances)
- app = client.app_info(appname)
-
- match = instances.match(/([+-])?\d+/)
- err "Invalid number of instances '#{instances}'" unless match
-
- instances = instances.to_i
- current_instances = app[:instances]
- new_instances = match.captures[0] ? current_instances + instances : instances
- err "There must be at least 1 instance." if new_instances < 1
-
- if current_instances == new_instances
- display "Application [#{appname}] is already running #{new_instances} instance#{'s' if new_instances > 1}.".yellow
- return
- end
-
- up_or_down = new_instances > current_instances ? 'up' : 'down'
- display "Scaling Application instances #{up_or_down} to #{new_instances}: ", false
- app[:instances] = new_instances
- client.update_app(appname, app)
- display 'OK'.green
- end
-
- def health(d)
- return 'N/A' unless (d and d[:state])
- return 'STOPPED' if d[:state] == 'STOPPED'
-
- healthy_instances = d[:runningInstances]
- expected_instance = d[:instances]
- health = nil
-
- if d[:state] == "STARTED" && expected_instance > 0 && healthy_instances
- health = format("%.3f", healthy_instances.to_f / expected_instance).to_f
- end
-
- return 'RUNNING' if health && health == 1.0
- return "#{(health * 100).round}%" if health
- return 'N/A'
- end
-
- def app_started_properly(appname, error_on_health)
- app = client.app_info(appname)
- case health(app)
- when 'N/A'
- # Health manager not running.
- err "\nApplication '#{appname}'s state is undetermined, not enough information available." if error_on_health
- return false
- when 'RUNNING'
- return true
- else
- if app[:meta][:debug] == "suspend"
- display "\nApplication [#{appname}] has started in a mode that is waiting for you to trigger startup."
- return true
- else
- return false
- end
- end
- end
-
- def display_logfile(path, content, instance='0', banner=nil)
- banner ||= "====> #{path} <====\n\n"
-
- unless content.empty?
- display banner
- prefix = "[#{instance}: #{path}] -".bold if @options[:prefixlogs]
- unless prefix
- display content
- else
- lines = content.split("\n")
- lines.each { |line| display "#{prefix} #{line}"}
- end
- display ''
- end
- end
-
- def grab_all_logs(appname)
- instances_info_envelope = client.app_instances(appname)
- return if instances_info_envelope.is_a?(Array)
- instances_info = instances_info_envelope[:instances] || []
- instances_info.each do |entry|
- grab_logs(appname, entry[:index])
- end
- end
-
- def grab_logs(appname, instance)
- files_under(appname, instance, "/logs").each do |path|
- begin
- content = client.app_files(appname, path, instance)
- display_logfile(path, content, instance)
- rescue VMC::Client::NotFound, VMC::Client::TargetError
- end
- end
- end
-
- def files_under(appname, instance, path)
- client.app_files(appname, path, instance).split("\n").collect do |l|
- "#{path}/#{l.split[0]}"
- end
- rescue VMC::Client::NotFound, VMC::Client::TargetError
- []
- end
-
- def grab_crash_logs(appname, instance, was_staged=false)
- # stage crash info
- crashes(appname, false) unless was_staged
-
- instance ||= '0'
- map = VMC::Cli::Config.instances
- instance = map[instance] if map[instance]
-
- (files_under(appname, instance, "/logs") +
- files_under(appname, instance, "/app/logs") +
- files_under(appname, instance, "/app/log")).each do |path|
- content = client.app_files(appname, path, instance)
- display_logfile(path, content, instance)
- end
- end
-
- def grab_startup_tail(appname, since = 0)
- new_lines = 0
- path = "logs/startup.log"
- content = client.app_files(appname, path)
- if content && !content.empty?
- display "\n==== displaying startup log ====\n\n" if since == 0
- response_lines = content.split("\n")
- lines = response_lines.size
- tail = response_lines[since, lines] || []
- new_lines = tail.size
- display tail.join("\n") if new_lines > 0
- end
- since + new_lines
- rescue VMC::Client::NotFound, VMC::Client::TargetError
- 0
- end
-
- def provisioned_services_apps_hash
- apps = client.apps
- services_apps_hash = {}
- apps.each {|app|
- app[:services].each { |svc|
- svc_apps = services_apps_hash[svc]
- unless svc_apps
- svc_apps = Set.new
- services_apps_hash[svc] = svc_apps
- end
- svc_apps.add(app[:name])
- } unless app[:services] == nil
- }
- services_apps_hash
- end
-
- def delete_app(appname, force)
- app = client.app_info(appname)
- services_to_delete = []
- app_services = app[:services]
- services_apps_hash = provisioned_services_apps_hash
- app_services.each { |service|
- del_service = force && no_prompt
- unless no_prompt || force
- del_service = ask(
- "Provisioned service [#{service}] detected, would you like to delete it?",
- :default => false
- )
-
- if del_service
- apps_using_service = services_apps_hash[service].reject!{ |app| app == appname}
- if apps_using_service.size > 0
- del_service = ask(
- "Provisioned service [#{service}] is also used by #{apps_using_service.size == 1 ? "app" : "apps"} #{apps_using_service.entries}, are you sure you want to delete it?",
- :default => false
- )
- end
- end
- end
- services_to_delete << service if del_service
- }
-
- display "Deleting application [#{appname}]: ", false
- client.delete_app(appname)
- display 'OK'.green
-
- services_to_delete.each do |s|
- delete_service_banner(s)
- end
- end
-
- def do_start(appname, push=false)
- app = client.app_info(appname)
- return display "Application '#{appname}' could not be found".red if app.nil?
- return display "Application '#{appname}' already started".yellow if app[:state] == 'STARTED'
-
-
-
- if @options[:debug]
- runtimes = client.runtimes_info
- return display "Cannot get runtime information." unless runtimes
-
- runtime = runtimes[app[:staging][:stack].to_sym]
- return display "Unknown runtime." unless runtime
-
- unless runtime[:debug_modes] and runtime[:debug_modes].include? @options[:debug]
- modes = runtime[:debug_modes] || []
-
- display "\nApplication '#{appname}' cannot start in '#{@options[:debug]}' mode"
-
- if push
- display "Try 'vmc start' with one of the following modes: #{modes.inspect}"
- else
- display "Available modes: #{modes.inspect}"
- end
-
- return
- end
- end
-
- banner = "Staging Application '#{appname}': "
- display banner, false
-
- t = Thread.new do
- count = 0
- while count < TAIL_TICKS do
- display '.', false
- sleep SLEEP_TIME
- count += 1
- end
- end
-
- app[:state] = 'STARTED'
- app[:debug] = @options[:debug]
- app[:console] = VMC::Cli::Framework.lookup_by_framework(app[:staging][:model]).console
- client.update_app(appname, app)
-
- Thread.kill(t)
- clear(LINE_LENGTH)
- display "#{banner}#{'OK'.green}"
-
- banner = "Starting Application '#{appname}': "
- display banner, false
-
- count = log_lines_displayed = 0
- failed = false
- start_time = Time.now.to_i
-
- loop do
- display '.', false unless count > TICKER_TICKS
- sleep SLEEP_TIME
-
- break if app_started_properly(appname, count > HEALTH_TICKS)
-
- if !crashes(appname, false, start_time).empty?
- # Check for the existance of crashes
- display "\nError: Application [#{appname}] failed to start, logs information below.\n".red
- grab_crash_logs(appname, '0', true)
- if push and !no_prompt
- display "\n"
- delete_app(appname, false) if ask "Delete the application?", :default => true
- end
- failed = true
- break
- elsif count > TAIL_TICKS
- log_lines_displayed = grab_startup_tail(appname, log_lines_displayed)
- end
-
- count += 1
- if count > GIVEUP_TICKS # 2 minutes
- display "\nApplication is taking too long to start, check your logs".yellow
- break
- end
- end
- exit(false) if failed
- clear(LINE_LENGTH)
- display "#{banner}#{'OK'.green}"
- end
-
- def do_stop(appname)
- app = client.app_info(appname)
- return display "Application '#{appname}' already stopped".yellow if app[:state] == 'STOPPED'
- display "Stopping Application '#{appname}': ", false
- app[:state] = 'STOPPED'
- client.update_app(appname, app)
- display 'OK'.green
- end
-
- def do_push(appname=nil)
- unless @app_info || no_prompt
- @manifest = { "applications" => { @path => { "name" => appname } } }
-
- interact
-
- if ask("Would you like to save this configuration?", :default => false)
- save_manifest
- end
-