paasio 0.3.16.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +24 -0
- data/README.md +96 -0
- data/Rakefile +99 -0
- data/bin/paasio +6 -0
- data/caldecott_helper/Gemfile +10 -0
- data/caldecott_helper/Gemfile.lock +48 -0
- data/caldecott_helper/server.rb +43 -0
- data/config/clients.yml +17 -0
- data/lib/cli/commands/admin.rb +80 -0
- data/lib/cli/commands/apps.rb +1284 -0
- data/lib/cli/commands/base.rb +230 -0
- data/lib/cli/commands/manifest.rb +56 -0
- data/lib/cli/commands/misc.rb +129 -0
- data/lib/cli/commands/services.rb +179 -0
- data/lib/cli/commands/user.rb +65 -0
- data/lib/cli/config.rb +165 -0
- data/lib/cli/core_ext.rb +122 -0
- data/lib/cli/errors.rb +19 -0
- data/lib/cli/frameworks.rb +131 -0
- data/lib/cli/manifest_helper.rb +238 -0
- data/lib/cli/runner.rb +535 -0
- data/lib/cli/services_helper.rb +84 -0
- data/lib/cli/tunnel_helper.rb +324 -0
- data/lib/cli/usage.rb +104 -0
- data/lib/cli/version.rb +7 -0
- data/lib/cli/zip_util.rb +77 -0
- data/lib/cli.rb +32 -0
- data/lib/vmc/client.rb +481 -0
- data/lib/vmc/const.rb +22 -0
- data/lib/vmc.rb +3 -0
- metadata +246 -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,96 @@
|
|
1
|
+
# paasio
|
2
|
+
|
3
|
+
The PaaS.io CLI. This is the command line interface to PaaS.io's Application Platform
|
4
|
+
|
5
|
+
paasio is based on VMware's default vmc implementation, but contains
|
6
|
+
several extensions to work with PaaS.io's core platform.
|
7
|
+
|
8
|
+
_Copyright 2012, PaaS.io, Inc.
|
9
|
+
Copyright 2010-2011, VMware, Inc. Licensed under the
|
10
|
+
MIT license, please see the LICENSE file. All rights reserved._
|
11
|
+
|
12
|
+
Usage: paasio [options] command [<args>] [command_options]
|
13
|
+
Try 'paasio help [command]' or 'paasio help options' for more information.
|
14
|
+
|
15
|
+
Currently available paasio commands are:
|
16
|
+
|
17
|
+
Getting Started
|
18
|
+
login [email] [--email, --passwd] Login
|
19
|
+
info System and account information
|
20
|
+
|
21
|
+
Applications
|
22
|
+
apps List deployed applications
|
23
|
+
|
24
|
+
Application Creation
|
25
|
+
create [appname] Create a new application
|
26
|
+
create [appname] --url Set the url for the application
|
27
|
+
create [appname] --instances <N> Set the expected number <N> of instances
|
28
|
+
create [appname] --mem M Set the memory reservation for the application
|
29
|
+
create [appname] --runtime RUNTIME Set the runtime to use for the application
|
30
|
+
create [appname] --debug [MODE] Push application and start in a debug mode
|
31
|
+
|
32
|
+
Application Operations
|
33
|
+
start <appname> Start the application
|
34
|
+
stop <appname> Stop the application
|
35
|
+
restart <appname> Restart the application
|
36
|
+
delete <appname> Delete the application
|
37
|
+
rename <appname> <newname> Rename the application
|
38
|
+
|
39
|
+
Application Updates
|
40
|
+
upload <appname> [--path] Upload the application bits
|
41
|
+
mem <appname> [memsize] Update the memory reservation for an application
|
42
|
+
map <appname> <url> Register the application to the url
|
43
|
+
unmap <appname> <url> Unregister the application from the url
|
44
|
+
instances <appname> <num|delta> Scale the application instances up or down
|
45
|
+
|
46
|
+
Application Information
|
47
|
+
crashes <appname> List recent application crashes
|
48
|
+
crashlogs <appname> Display log information for crashed applications
|
49
|
+
logs <appname> [--all] Display log information for the application
|
50
|
+
files <appname> [path] [--all] Display directory listing or file download for path
|
51
|
+
stats <appname> Display resource usage for the application
|
52
|
+
instances <appname> List application instances
|
53
|
+
|
54
|
+
Application Environment
|
55
|
+
env <appname> List application environment variables
|
56
|
+
env-add <appname> <variable[=]value> Add an environment variable to an application
|
57
|
+
env-del <appname> <variable> Delete an environment variable to an application
|
58
|
+
|
59
|
+
Services
|
60
|
+
services Lists of services available and provisioned
|
61
|
+
create-service <service> [--name,--bind] Create a provisioned service
|
62
|
+
create-service <service> <name> Create a provisioned service and assign it <name>
|
63
|
+
create-service <service> <name> <app> Create a provisioned service 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
|
+
Misc
|
83
|
+
aliases List aliases
|
84
|
+
alias <alias[=]command> Create an alias for a command
|
85
|
+
unalias <alias> Remove an alias
|
86
|
+
targets List known targets and associated authorization tokens
|
87
|
+
|
88
|
+
Help
|
89
|
+
help [command] Get general help or help on a specific command
|
90
|
+
help options Get help on available options
|
91
|
+
|
92
|
+
## Simple Story (for Ruby apps)
|
93
|
+
|
94
|
+
paasio login
|
95
|
+
bundle package
|
96
|
+
paasio push
|
data/Rakefile
ADDED
@@ -0,0 +1,99 @@
|
|
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
|
+
]
|
34
|
+
|
35
|
+
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]'"
|
36
|
+
task :build, [:force] do |t, args|
|
37
|
+
sh('bundle install')
|
38
|
+
sh('git submodule update --init')
|
39
|
+
puts "\nBuilding tests"
|
40
|
+
if build_required? args.force
|
41
|
+
ENV['MAVEN_OPTS']="-XX:MaxPermSize=256M"
|
42
|
+
TESTS_TO_BUILD.each do |test|
|
43
|
+
puts "\tBuilding '#{test}'"
|
44
|
+
Dir.chdir test do
|
45
|
+
sh('mvn package -DskipTests') do |success, exit_code|
|
46
|
+
unless success
|
47
|
+
clear_build_artifact
|
48
|
+
do_mvn_clean('-q')
|
49
|
+
fail "\tFailed to build #{test} - aborting build"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
puts "\tCompleted building '#{test}'"
|
54
|
+
end
|
55
|
+
save_git_hash
|
56
|
+
else
|
57
|
+
puts "Built artifacts in sync with test assets - no build required"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Clean the build artifacts"
|
62
|
+
task :clean do
|
63
|
+
puts "\nCleaning tests"
|
64
|
+
clear_build_artifact
|
65
|
+
TESTS_TO_BUILD.each do |test|
|
66
|
+
puts "\tCleaning '#{test}'"
|
67
|
+
Dir.chdir test do
|
68
|
+
do_mvn_clean
|
69
|
+
end
|
70
|
+
puts "\tCompleted cleaning '#{test}'"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def build_required? (force_build=nil)
|
75
|
+
if File.exists?(BUILD_ARTIFACT) == false or (force_build and force_build == "--force")
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
Dir.chdir(tests_path) do
|
79
|
+
saved_git_hash = IO.readlines(BUILD_ARTIFACT)[0].split[0]
|
80
|
+
git_hash = `git rev-parse --short=8 --verify HEAD`
|
81
|
+
saved_git_hash.to_s.strip != git_hash.to_s.strip
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def save_git_hash
|
86
|
+
Dir.chdir(tests_path) do
|
87
|
+
git_hash = `git rev-parse --short=8 --verify HEAD`
|
88
|
+
File.open(BUILD_ARTIFACT, 'w') {|f| f.puts("#{git_hash}")}
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def clear_build_artifact
|
93
|
+
puts "\tClearing build artifact #{BUILD_ARTIFACT}"
|
94
|
+
File.unlink BUILD_ARTIFACT if File.exists? BUILD_ARTIFACT
|
95
|
+
end
|
96
|
+
|
97
|
+
def do_mvn_clean options=nil
|
98
|
+
sh("mvn clean #{options}")
|
99
|
+
end
|
data/bin/paasio
ADDED
@@ -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"])
|
data/config/clients.yml
ADDED
@@ -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,80 @@
|
|
1
|
+
module VMC::Cli::Command
|
2
|
+
|
3
|
+
class Admin < Base
|
4
|
+
|
5
|
+
def list_users
|
6
|
+
users = client.users
|
7
|
+
users.sort! {|a, b| a[:email] <=> b[:email] }
|
8
|
+
return display JSON.pretty_generate(users || []) if @options[:json]
|
9
|
+
|
10
|
+
display "\n"
|
11
|
+
return display "No Users" if users.nil? || users.empty?
|
12
|
+
|
13
|
+
users_table = table do |t|
|
14
|
+
t.headings = 'Email', 'Admin', 'Apps'
|
15
|
+
users.each do |user|
|
16
|
+
t << [user[:email], user[:admin], user[:apps].map {|x| x[:name]}.join(', ')]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
display users_table
|
20
|
+
end
|
21
|
+
|
22
|
+
alias :users :list_users
|
23
|
+
|
24
|
+
def add_user(email=nil)
|
25
|
+
email ||= @options[:email]
|
26
|
+
email ||= ask("Email") unless no_prompt
|
27
|
+
password = @options[:password]
|
28
|
+
unless no_prompt || password
|
29
|
+
password = ask("Password", :echo => "*")
|
30
|
+
password2 = ask("Verify Password", :echo => "*")
|
31
|
+
err "Passwords did not match, try again" if password != password2
|
32
|
+
end
|
33
|
+
err "Need a valid email" unless email
|
34
|
+
err "Need a password" unless password
|
35
|
+
display 'Creating New User: ', false
|
36
|
+
client.add_user(email, password)
|
37
|
+
display 'OK'.green
|
38
|
+
|
39
|
+
# if we are not logged in for the current target, log in as the new user
|
40
|
+
return unless VMC::Cli::Config.auth_token.nil?
|
41
|
+
@options[:password] = password
|
42
|
+
cmd = User.new(@options)
|
43
|
+
cmd.login(email)
|
44
|
+
end
|
45
|
+
|
46
|
+
def delete_user(user_email)
|
47
|
+
# Check to make sure all apps and services are deleted before deleting the user
|
48
|
+
# implicit proxying
|
49
|
+
|
50
|
+
client.proxy_for(user_email)
|
51
|
+
@options[:proxy] = user_email
|
52
|
+
apps = client.apps
|
53
|
+
|
54
|
+
if (apps && !apps.empty?)
|
55
|
+
unless no_prompt
|
56
|
+
proceed = ask(
|
57
|
+
"\nDeployed applications and associated services will be DELETED, continue?",
|
58
|
+
:default => false
|
59
|
+
)
|
60
|
+
err "Aborted" unless proceed
|
61
|
+
end
|
62
|
+
cmd = Apps.new(@options.merge({ :force => true }))
|
63
|
+
apps.each { |app| cmd.delete(app[:name]) }
|
64
|
+
end
|
65
|
+
|
66
|
+
services = client.services
|
67
|
+
if (services && !services.empty?)
|
68
|
+
cmd = Services.new(@options)
|
69
|
+
services.each { |s| cmd.delete_service(s[:name])}
|
70
|
+
end
|
71
|
+
|
72
|
+
display 'Deleting User: ', false
|
73
|
+
client.proxy = nil
|
74
|
+
client.delete_user(user_email)
|
75
|
+
display 'OK'.green
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|