udn 0.3.23.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/LICENSE +24 -0
  2. data/README.md +113 -0
  3. data/Rakefile +101 -0
  4. data/bin/udn +6 -0
  5. data/caldecott_helper/Gemfile +10 -0
  6. data/caldecott_helper/Gemfile.lock +48 -0
  7. data/caldecott_helper/server.rb +43 -0
  8. data/config/clients.yml +17 -0
  9. data/config/micro/offline.conf +2 -0
  10. data/config/micro/paths.yml +22 -0
  11. data/config/micro/refresh_ip.rb +20 -0
  12. data/lib/cli.rb +47 -0
  13. data/lib/cli/commands/admin.rb +80 -0
  14. data/lib/cli/commands/apps.rb +1129 -0
  15. data/lib/cli/commands/base.rb +228 -0
  16. data/lib/cli/commands/manifest.rb +56 -0
  17. data/lib/cli/commands/micro.rb +115 -0
  18. data/lib/cli/commands/misc.rb +129 -0
  19. data/lib/cli/commands/services.rb +259 -0
  20. data/lib/cli/commands/user.rb +65 -0
  21. data/lib/cli/config.rb +173 -0
  22. data/lib/cli/console_helper.rb +170 -0
  23. data/lib/cli/core_ext.rb +122 -0
  24. data/lib/cli/errors.rb +19 -0
  25. data/lib/cli/frameworks.rb +266 -0
  26. data/lib/cli/manifest_helper.rb +323 -0
  27. data/lib/cli/runner.rb +556 -0
  28. data/lib/cli/services_helper.rb +109 -0
  29. data/lib/cli/tunnel_helper.rb +332 -0
  30. data/lib/cli/usage.rb +124 -0
  31. data/lib/cli/version.rb +7 -0
  32. data/lib/cli/zip_util.rb +77 -0
  33. data/lib/vmc.rb +3 -0
  34. data/lib/vmc/client.rb +562 -0
  35. data/lib/vmc/const.rb +23 -0
  36. data/lib/vmc/micro.rb +56 -0
  37. data/lib/vmc/micro/switcher/base.rb +97 -0
  38. data/lib/vmc/micro/switcher/darwin.rb +19 -0
  39. data/lib/vmc/micro/switcher/dummy.rb +15 -0
  40. data/lib/vmc/micro/switcher/linux.rb +16 -0
  41. data/lib/vmc/micro/switcher/windows.rb +31 -0
  42. data/lib/vmc/micro/vmrun.rb +168 -0
  43. metadata +310 -0
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2010-2011 VMware Inc, All Rights Reserved
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
21
+ This software downloads additional open source software components upon install
22
+ that are distributed under separate terms and conditions. Please see the license
23
+ information provided in the individual software components for more information.
24
+
data/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # VMC
2
+
3
+ The VMware Cloud CLI. This is the command line interface to VMware's Application Platform
4
+
5
+ _Copyright 2010-2012, VMware, Inc. Licensed under the
6
+ MIT license, please see the LICENSE file. All rights reserved._
7
+
8
+ Usage: vmc [options] command [<args>] [command_options]
9
+ Try 'vmc help [command]' or 'vmc help options' for more information.
10
+
11
+ Currently available vmc commands are:
12
+
13
+ Getting Started
14
+ target [url] Reports current target or sets a new target
15
+ login [email] [--email, --passwd] Login
16
+ info System and account information
17
+
18
+ Applications
19
+ apps List deployed applications
20
+
21
+ Application Creation
22
+ push [appname] Create, push, map, and start a new application
23
+ push [appname] --path Push application from specified path
24
+ push [appname] --url Set the url for the application
25
+ push [appname] --instances <N> Set the expected number <N> of instances
26
+ push [appname] --mem M Set the memory reservation for the application
27
+ push [appname] --runtime RUNTIME Set the runtime to use for the application
28
+ push [appname] --framework Framework Set the framework to use for the application
29
+ push [appname] --debug [MODE] Push application and start in a debug mode
30
+ push [appname] --no-start Do not auto-start the application
31
+
32
+ Application Operations
33
+ start <appname> [--debug [MODE]] Start the application
34
+ stop <appname> Stop the application
35
+ restart <appname> [--debug [MODE]] Restart the application
36
+ delete <appname> Delete the application
37
+
38
+ Application Updates
39
+ update <appname> [--path,--debug [MODE]] Update the application bits
40
+ mem <appname> [memsize] Update the memory reservation for an application
41
+ map <appname> <url> Register the application to the url
42
+ unmap <appname> <url> Unregister the application from the url
43
+ instances <appname> <num|delta> Scale the application instances up or down
44
+
45
+ Application Information
46
+ crashes <appname> List recent application crashes
47
+ crashlogs <appname> Display log information for crashed applications
48
+ logs <appname> [--all] Display log information for the application
49
+ files <appname> [path] [--all] Display directory listing or file download for [path]
50
+ stats <appname> Display resource usage for the application
51
+ instances <appname> List application instances
52
+
53
+ Application Environment
54
+ env <appname> List application environment variables
55
+ env-add <appname> <variable[=]value> Add an environment variable to an application
56
+ env-del <appname> <variable> Delete an environment variable to an application
57
+
58
+ Services
59
+ services Lists of services available and provisioned
60
+ create-service <service> [--name,--bind] Create a provisioned service
61
+ create-service <service> <name> Create a provisioned service and assign it <name>
62
+ create-service <service> <name> <app> Create a provisioned service and assign it <name>, and bind to <app>
63
+ create-service <service> <name> <app> <plan> Create a provisioned service on specified plan and assign it <name>, and bind to <app>
64
+ delete-service [servicename] Delete a provisioned service
65
+ bind-service <servicename> <appname> Bind a service to an application
66
+ unbind-service <servicename> <appname> Unbind service from the application
67
+ clone-services <src-app> <dest-app> Clone service bindings from <src-app> application to <dest-app>
68
+ tunnel <servicename> [--port] Create a local tunnel to a service
69
+ tunnel <servicename> <clientcmd> Create a local tunnel to a service and start a local client
70
+
71
+ Administration
72
+ user Display user account information
73
+ passwd Change the password for the current user
74
+ logout Logs current user out of the target system
75
+ add-user [--email, --passwd] Register a new user (requires admin privileges)
76
+ delete-user <user> Delete a user and all apps and services (requires admin privileges)
77
+
78
+ System
79
+ runtimes Display the supported runtimes of the target system
80
+ frameworks Display the recognized frameworks of the target system
81
+
82
+ Micro Cloud Foundry
83
+ micro status Display Micro Cloud Foundry VM status
84
+ micro offline Configure Micro Cloud Foundry VM for offline mode
85
+ micro online Configure Micro Cloud Foundry VM for online mode
86
+ [--vmx file] Path to micro.vmx
87
+ [--vmrun executable] Path to vmrun executable
88
+ [--password cleartext] Cleartext password for guest VM vcap user
89
+ [--save] Save cleartext password in ~/.udn_micro
90
+
91
+ Misc
92
+ aliases List aliases
93
+ alias <alias[=]command> Create an alias for a command
94
+ unalias <alias> Remove an alias
95
+ targets List known targets and associated authorization tokens
96
+
97
+ Help
98
+ help [command] Get general help or help on a specific command
99
+ help options Get help on available options
100
+
101
+ Timeout
102
+ * --timeout timeout Set the timeout seconds for any requests
103
+
104
+ ## Simple Story (for Ruby apps)
105
+
106
+ vmc target api.cloudfoundry.com
107
+ vmc login
108
+ bundle package
109
+ vmc push
110
+
111
+ ## File a Bug
112
+
113
+ To file a bug against Cloud Foundry Open Source and its components, sign up and use our bug tracking system: [http://cloudfoundry.atlassian.net](http://cloudfoundry.atlassian.net)
data/Rakefile ADDED
@@ -0,0 +1,101 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run specs"
5
+ task :spec => :build do
6
+ Spec::Rake::SpecTask.new('spec') do |t|
7
+ t.spec_opts = %w(-fs -c)
8
+ t.spec_files = FileList['spec/**/*_spec.rb']
9
+ end
10
+ end
11
+
12
+ desc "Synonym for spec"
13
+ task :test => :spec
14
+ desc "Synonym for spec"
15
+ task :tests => :spec
16
+ task :default => :spec
17
+
18
+ def tests_path
19
+ if @tests_path == nil
20
+ @tests_path = File.join(Dir.pwd, "spec/assets/tests")
21
+ end
22
+ @tests_path
23
+ end
24
+ TESTS_PATH = tests_path
25
+
26
+ BUILD_ARTIFACT = File.join(Dir.pwd, "spec/assets/.build")
27
+
28
+ TESTS_TO_BUILD = ["#{TESTS_PATH}/java_web/java_tiny_app",
29
+ # "#{TESTS_PATH}/grails/guestbook",
30
+ "#{TESTS_PATH}/lift/hello_lift",
31
+ "#{TESTS_PATH}/spring/roo-guestbook",
32
+ "#{TESTS_PATH}/spring/spring-osgi-hello",
33
+ "#{TESTS_PATH}/standalone/java_app",
34
+ "#{TESTS_PATH}/standalone/python_app"
35
+ ]
36
+
37
+ 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]'"
38
+ task :build, [:force] do |t, args|
39
+ sh('bundle install')
40
+ sh('git submodule update --init')
41
+ puts "\nBuilding tests"
42
+ if build_required? args.force
43
+ ENV['MAVEN_OPTS']="-XX:MaxPermSize=256M"
44
+ TESTS_TO_BUILD.each do |test|
45
+ puts "\tBuilding '#{test}'"
46
+ Dir.chdir test do
47
+ sh('mvn package -DskipTests') do |success, exit_code|
48
+ unless success
49
+ clear_build_artifact
50
+ do_mvn_clean('-q')
51
+ fail "\tFailed to build #{test} - aborting build"
52
+ end
53
+ end
54
+ end
55
+ puts "\tCompleted building '#{test}'"
56
+ end
57
+ save_git_hash
58
+ else
59
+ puts "Built artifacts in sync with test assets - no build required"
60
+ end
61
+ end
62
+
63
+ desc "Clean the build artifacts"
64
+ task :clean do
65
+ puts "\nCleaning tests"
66
+ clear_build_artifact
67
+ TESTS_TO_BUILD.each do |test|
68
+ puts "\tCleaning '#{test}'"
69
+ Dir.chdir test do
70
+ do_mvn_clean
71
+ end
72
+ puts "\tCompleted cleaning '#{test}'"
73
+ end
74
+ end
75
+
76
+ def build_required? (force_build=nil)
77
+ if File.exists?(BUILD_ARTIFACT) == false or (force_build and force_build == "--force")
78
+ return true
79
+ end
80
+ Dir.chdir(tests_path) do
81
+ saved_git_hash = IO.readlines(BUILD_ARTIFACT)[0].split[0]
82
+ git_hash = `git rev-parse --short=8 --verify HEAD`
83
+ saved_git_hash.to_s.strip != git_hash.to_s.strip
84
+ end
85
+ end
86
+
87
+ def save_git_hash
88
+ Dir.chdir(tests_path) do
89
+ git_hash = `git rev-parse --short=8 --verify HEAD`
90
+ File.open(BUILD_ARTIFACT, 'w') {|f| f.puts("#{git_hash}")}
91
+ end
92
+ end
93
+
94
+ def clear_build_artifact
95
+ puts "\tClearing build artifact #{BUILD_ARTIFACT}"
96
+ File.unlink BUILD_ARTIFACT if File.exists? BUILD_ARTIFACT
97
+ end
98
+
99
+ def do_mvn_clean options=nil
100
+ sh("mvn clean #{options}")
101
+ end
data/bin/udn ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path('../../lib/cli', __FILE__)
4
+
5
+ VMC::Cli::Runner.run(ARGV.dup)
6
+
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rack', '~> 1.2.0'
4
+ gem 'caldecott', '= 0.0.3'
5
+ gem 'bundler'
6
+ gem 'em-websocket'
7
+ gem 'async_sinatra'
8
+ gem 'thin'
9
+ gem 'json'
10
+ gem 'uuidtools'
@@ -0,0 +1,48 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.6)
5
+ async_sinatra (0.5.0)
6
+ rack (>= 1.2.1)
7
+ sinatra (>= 1.0)
8
+ caldecott (0.0.3)
9
+ addressable (= 2.2.6)
10
+ async_sinatra (= 0.5.0)
11
+ em-http-request (= 0.3.0)
12
+ em-websocket (= 0.3.1)
13
+ json (= 1.6.1)
14
+ uuidtools (= 2.1.2)
15
+ daemons (1.1.4)
16
+ em-http-request (0.3.0)
17
+ addressable (>= 2.0.0)
18
+ escape_utils
19
+ eventmachine (>= 0.12.9)
20
+ em-websocket (0.3.1)
21
+ addressable (>= 2.1.1)
22
+ eventmachine (>= 0.12.9)
23
+ escape_utils (0.2.4)
24
+ eventmachine (0.12.10)
25
+ json (1.6.1)
26
+ rack (1.2.4)
27
+ sinatra (1.2.7)
28
+ rack (~> 1.1)
29
+ tilt (>= 1.2.2, < 2.0)
30
+ thin (1.2.11)
31
+ daemons (>= 1.0.9)
32
+ eventmachine (>= 0.12.6)
33
+ rack (>= 1.0.0)
34
+ tilt (1.3.3)
35
+ uuidtools (2.1.2)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ async_sinatra
42
+ bundler
43
+ caldecott (= 0.0.3)
44
+ em-websocket
45
+ json
46
+ rack (~> 1.2.0)
47
+ thin
48
+ uuidtools
@@ -0,0 +1,43 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) 2009-2011 VMware, Inc.
3
+ $:.unshift(File.dirname(__FILE__) + '/lib')
4
+
5
+ require 'rubygems'
6
+ require 'bundler/setup'
7
+
8
+ require 'caldecott'
9
+ require 'sinatra'
10
+ require 'json'
11
+ require 'eventmachine'
12
+
13
+ port = ENV['VMC_APP_PORT']
14
+ port ||= 8081
15
+
16
+ # add vcap specific stuff to Caldecott
17
+ class VcapHttpTunnel < Caldecott::Server::HttpTunnel
18
+ get '/info' do
19
+ { "version" => '0.0.4' }.to_json
20
+ end
21
+
22
+ def self.get_tunnels
23
+ super
24
+ end
25
+
26
+ get '/services' do
27
+ services_env = ENV['VMC_SERVICES']
28
+ return "no services env" if services_env.nil? or services_env.empty?
29
+ services_env
30
+ end
31
+
32
+ get '/services/:service' do |service_name|
33
+ services_env = ENV['VMC_SERVICES']
34
+ not_found if services_env.nil?
35
+
36
+ services = JSON.parse(services_env)
37
+ service = services.find { |s| s["name"] == service_name }
38
+ not_found if service.nil?
39
+ service["options"].to_json
40
+ end
41
+ end
42
+
43
+ VcapHttpTunnel.run!(:port => port, :auth_token => ENV["CALDECOTT_AUTH"])
@@ -0,0 +1,17 @@
1
+ redis:
2
+ redis-cli: -h ${host} -p ${port} -a ${password}
3
+
4
+ mysql:
5
+ mysql: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name}
6
+ mysqldump: --protocol=TCP --host=${host} --port=${port} --user=${user} --password=${password} ${name} > ${Output file}
7
+
8
+ mongodb:
9
+ mongo: --host ${host} --port ${port} -u ${user} -p ${password} ${name}
10
+ mongodump: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name}
11
+ mongorestore: --host ${host} --port ${port} -u ${user} -p ${password} --db ${name} ${Directory or filename to restore from}
12
+
13
+ postgresql:
14
+ psql:
15
+ command: -h ${host} -p ${port} -d ${name} -U ${user} -w
16
+ environment:
17
+ - PGPASSWORD='${password}'
@@ -0,0 +1,2 @@
1
+ no-resolv
2
+ log-queries
@@ -0,0 +1,22 @@
1
+ darwin:
2
+ vmrun:
3
+ - "/Applications/VMware Fusion.app/Contents/Library/"
4
+ - "/Applications/Fusion.app/Contents/Library/"
5
+ vmx:
6
+ - "~/Documents/Virtual Machines.localized/"
7
+ - "~/Documents/Virtual Machines/"
8
+ - "~/Desktop/"
9
+
10
+ linux:
11
+ vmrun:
12
+ - "/usr/bin/"
13
+ vmx:
14
+ - "~/"
15
+
16
+ windows:
17
+ vmrun:
18
+ - "c:\\Program Files (x86)\\"
19
+ - "c:\\Program Files\\"
20
+ vmx:
21
+ - "~\\Documents\\"
22
+ - "~\\Desktop\\"
@@ -0,0 +1,20 @@
1
+ #!/var/vcap/bosh/bin/ruby
2
+ require 'socket'
3
+
4
+ A_ROOT_SERVER = '198.41.0.4'
5
+
6
+ begin
7
+ retries ||= 0
8
+ route ||= A_ROOT_SERVER
9
+ orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
10
+ ip_address = UDPSocket.open {|s| s.connect(route, 1); s.addr.last }
11
+ rescue Errno::ENETUNREACH
12
+ # happens on boot when dhcp hasn't completed when we get here
13
+ sleep 3
14
+ retries += 1
15
+ retry if retries < 10
16
+ ensure
17
+ Socket.do_not_reverse_lookup = orig
18
+ end
19
+
20
+ File.open("/tmp/ip.txt", 'w') { |file| file.write(ip_address) }
data/lib/cli.rb ADDED
@@ -0,0 +1,47 @@
1
+ require "rbconfig"
2
+
3
+ ROOT = File.expand_path(File.dirname(__FILE__))
4
+ WINDOWS = !!(RbConfig::CONFIG['host_os'] =~ /mingw|mswin32|cygwin/)
5
+
6
+ module VMC
7
+ autoload :Client, "#{ROOT}/vmc/client"
8
+ autoload :Micro, "#{ROOT}/vmc/micro"
9
+
10
+ module Micro
11
+ module Switcher
12
+ autoload :Base, "#{ROOT}/vmc/micro/switcher/base"
13
+ autoload :Darwin, "#{ROOT}/vmc/micro/switcher/darwin"
14
+ autoload :Dummy, "#{ROOT}/vmc/micro/switcher/dummy"
15
+ autoload :Linux, "#{ROOT}/vmc/micro/switcher/linux"
16
+ autoload :Windows, "#{ROOT}/vmc/micro/switcher/windows"
17
+ end
18
+ autoload :VMrun, "#{ROOT}/vmc/micro/vmrun"
19
+ end
20
+
21
+ module Cli
22
+ autoload :Config, "#{ROOT}/cli/config"
23
+ autoload :Framework, "#{ROOT}/cli/frameworks"
24
+ autoload :Runner, "#{ROOT}/cli/runner"
25
+ autoload :ZipUtil, "#{ROOT}/cli/zip_util"
26
+ autoload :ServicesHelper, "#{ROOT}/cli/services_helper"
27
+ autoload :TunnelHelper, "#{ROOT}/cli/tunnel_helper"
28
+ autoload :ManifestHelper, "#{ROOT}/cli/manifest_helper"
29
+ autoload :ConsoleHelper, "#{ROOT}/cli/console_helper"
30
+
31
+ module Command
32
+ autoload :Base, "#{ROOT}/cli/commands/base"
33
+ autoload :Admin, "#{ROOT}/cli/commands/admin"
34
+ autoload :Apps, "#{ROOT}/cli/commands/apps"
35
+ autoload :Micro, "#{ROOT}/cli/commands/micro"
36
+ autoload :Misc, "#{ROOT}/cli/commands/misc"
37
+ autoload :Services, "#{ROOT}/cli/commands/services"
38
+ autoload :User, "#{ROOT}/cli/commands/user"
39
+ autoload :Manifest, "#{ROOT}/cli/commands/manifest"
40
+ end
41
+
42
+ end
43
+ end
44
+
45
+ require "#{ROOT}/cli/version"
46
+ require "#{ROOT}/cli/core_ext"
47
+ require "#{ROOT}/cli/errors"