Permalink
Browse files

initial new vmc client

Change-Id: Icb16e01b17adfcc6b0e1141ee7b10fa93a8eec8b
  • Loading branch information...
1 parent 1f3d1f3 commit 53b0332ddcfece573668c0539629ac5dfd936b95 @vito vito committed May 15, 2012
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
@@ -1,5 +1,5 @@
-Gemfile.lock
-!caldecott_helper/Gemfile.lock
-.build
*.gem
-.DS_Store
+.rbenv-gemsets
+.bundle
+Gemfile.lock
+pkg/*
View
@@ -1,3 +0,0 @@
-[submodule "spec/assets/tests"]
- path = spec/assets/tests
- url = https://github.com/cloudfoundry/vcap-test-assets.git
View
@@ -1,4 +1,4 @@
source "http://rubygems.org"
+# Specify your gem's dependencies in cf.gemspec
gemspec
-
View
750 LICENSE

Large diffs are not rendered by default.

Oops, something went wrong.
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
@@ -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'
@@ -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
@@ -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
@@ -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}'
@@ -1,2 +0,0 @@
-no-resolv
-log-queries
Oops, something went wrong.

0 comments on commit 53b0332

Please sign in to comment.