Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit dbe336aab837dc000dd68523212d8e307c63b8e3 Cloud Foundry Engineer committed Apr 12, 2011
Showing with 3,662 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +4 −0 Gemfile
  3. +24 −0 LICENSE
  4. +92 −0 README.md
  5. +17 −0 Rakefile
  6. +15 −0 TODO
  7. +6 −0 bin/vmc
  8. +30 −0 lib/cli.rb
  9. +57 −0 lib/cli/commands/admin.rb
  10. +937 −0 lib/cli/commands/apps.rb
  11. +79 −0 lib/cli/commands/base.rb
  12. +128 −0 lib/cli/commands/misc.rb
  13. +84 −0 lib/cli/commands/services.rb
  14. +60 −0 lib/cli/commands/user.rb
  15. +110 −0 lib/cli/config.rb
  16. +119 −0 lib/cli/core_ext.rb
  17. +19 −0 lib/cli/errors.rb
  18. +97 −0 lib/cli/frameworks.rb
  19. +485 −0 lib/cli/runner.rb
  20. +74 −0 lib/cli/services_helper.rb
  21. +103 −0 lib/cli/usage.rb
  22. +7 −0 lib/cli/version.rb
  23. +77 −0 lib/cli/zip_util.rb
  24. +3 −0 lib/vmc.rb
  25. +435 −0 lib/vmc/client.rb
  26. +21 −0 lib/vmc/const.rb
  27. +9 −0 spec/assets/app_info.txt
  28. +9 −0 spec/assets/app_listings.txt
  29. +9 −0 spec/assets/bad_create_app.txt
  30. +9 −0 spec/assets/delete_app.txt
  31. +9 −0 spec/assets/global_service_listings.txt
  32. +9 −0 spec/assets/good_create_app.txt
  33. +9 −0 spec/assets/good_create_service.txt
  34. +27 −0 spec/assets/info_authenticated.txt
  35. +15 −0 spec/assets/info_return.txt
  36. +16 −0 spec/assets/info_return_bad.txt
  37. +9 −0 spec/assets/login_fail.txt
  38. +9 −0 spec/assets/login_success.txt
  39. +1 −0 spec/assets/sample_token.txt
  40. +9 −0 spec/assets/service_already_exists.txt
  41. +9 −0 spec/assets/service_listings.txt
  42. +9 −0 spec/assets/service_not_found.txt
  43. +9 −0 spec/assets/user_info.txt
  44. +11 −0 spec/spec_helper.rb
  45. +73 −0 spec/unit/cli_opts_spec.rb
  46. +284 −0 spec/unit/client_spec.rb
  47. +32 −0 vmc.gemspec
@@ -0,0 +1,3 @@
+Gemfile.lock
+*.gem
+.DS_Store
@@ -0,0 +1,4 @@
+source "http://rubygems.org"
+
+gemspec
+
@@ -0,0 +1,24 @@
+Copyright (c) 2010-2011 VMware Inc, All Rights Reserved
+
+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.
+
+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.
+
@@ -0,0 +1,92 @@
+# 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
+ rename <appname> <newname> Rename 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>
+
+ 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
+
+ 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.vcloudlabs.com
+ vmc login
+ bundle package
+ vmc push
@@ -0,0 +1,17 @@
+require 'rake'
+require 'spec/rake/spectask'
+
+desc "Run specs"
+task :spec do
+ sh('bundle install')
+ 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
@@ -0,0 +1,15 @@
+
+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.
@@ -0,0 +1,6 @@
+#!/usr/bin/env ruby
+
+require File.expand_path('../../lib/cli', __FILE__)
+
+VMC::Cli::Runner.run(ARGV.dup)
+
@@ -0,0 +1,30 @@
+
+ROOT = File.expand_path(File.dirname(__FILE__))
+
+module VMC
+
+ autoload :Client, "#{ROOT}/vmc/client"
+
+ 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"
+
+ module Command
+ autoload :Base, "#{ROOT}/cli/commands/base"
+ autoload :Admin, "#{ROOT}/cli/commands/admin"
+ autoload :Apps, "#{ROOT}/cli/commands/apps"
+ autoload :Misc, "#{ROOT}/cli/commands/misc"
+ autoload :Services, "#{ROOT}/cli/commands/services"
+ autoload :User, "#{ROOT}/cli/commands/user"
+ end
+
+ end
+end
+
+require "#{ROOT}/cli/version"
+require "#{ROOT}/cli/core_ext"
+require "#{ROOT}/cli/errors"
@@ -0,0 +1,57 @@
+module VMC::Cli::Command
+
+ class Admin < Base
+
+ def add_user(email=nil)
+ email = @options[:email] unless email
+ password = @options[:password]
+ email = ask("Email: ") unless no_prompt || email
+ unless no_prompt || password
+ password = ask("Password: ") {|q| q.echo = '*'}
+ password2 = ask("Verify Password: ") {|q| q.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? [yN]: ")
+ err "Aborted" if proceed.upcase != 'Y'
+ end
+ cmd = Apps.new(@options)
+ apps.each { |app| cmd.delete_app(app[:name], true) }
+ 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.delete_user(user_email)
+ display 'OK'.green
+ end
+
+ end
+
+end
Oops, something went wrong.

0 comments on commit dbe336a

Please sign in to comment.