jdc 0.2.1 → 0.2.2.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1277 -24
- data/Rakefile +13 -0
- data/bin/jdc +12 -2
- data/lib/admin/README.md +15 -0
- data/lib/admin/curl.rb +60 -0
- data/lib/admin/guid.rb +89 -0
- data/lib/admin/plugin.rb +6 -0
- data/lib/admin/service_auth_token.rb +94 -0
- data/lib/admin/service_broker/add.rb +47 -0
- data/lib/admin/service_broker/service_brokers.rb +24 -0
- data/lib/admin/set_quota.rb +44 -0
- data/lib/console/README.md +8 -0
- data/lib/console/console.rb +187 -0
- data/lib/console/plugin.rb +33 -0
- data/lib/jdc.rb +15 -2
- data/lib/jdc/cli.rb +556 -0
- data/lib/jdc/cli/app/app.rb +43 -0
- data/lib/jdc/cli/app/apps.rb +87 -0
- data/lib/jdc/cli/app/base.rb +72 -0
- data/lib/jdc/cli/app/delete.rb +95 -0
- data/lib/jdc/cli/app/deprecated.rb +11 -0
- data/lib/jdc/cli/app/env.rb +78 -0
- data/lib/jdc/cli/app/events.rb +45 -0
- data/lib/jdc/cli/app/files.rb +137 -0
- data/lib/jdc/cli/app/health.rb +26 -0
- data/lib/jdc/cli/app/instances.rb +53 -0
- data/lib/jdc/cli/app/logs.rb +76 -0
- data/lib/jdc/cli/app/push.rb +103 -0
- data/lib/jdc/cli/app/push/create.rb +108 -0
- data/lib/jdc/cli/app/push/interactions.rb +86 -0
- data/lib/jdc/cli/app/push/sync.rb +57 -0
- data/lib/jdc/cli/app/rename.rb +35 -0
- data/lib/jdc/cli/app/restart.rb +31 -0
- data/lib/jdc/cli/app/scale.rb +63 -0
- data/lib/jdc/cli/app/start.rb +161 -0
- data/lib/jdc/cli/app/stats.rb +67 -0
- data/lib/jdc/cli/app/stop.rb +27 -0
- data/lib/jdc/cli/domain/base.rb +9 -0
- data/lib/jdc/cli/domain/domains.rb +40 -0
- data/lib/jdc/cli/domain/map.rb +55 -0
- data/lib/jdc/cli/domain/unmap.rb +56 -0
- data/lib/jdc/cli/help.rb +15 -0
- data/lib/jdc/cli/interactive.rb +105 -0
- data/lib/jdc/cli/login_requirements.rb +15 -0
- data/lib/jdc/cli/organization/base.rb +14 -0
- data/lib/jdc/cli/organization/create.rb +37 -0
- data/lib/jdc/cli/organization/delete.rb +63 -0
- data/lib/jdc/cli/organization/org.rb +45 -0
- data/lib/jdc/cli/organization/orgs.rb +30 -0
- data/lib/jdc/cli/organization/rename.rb +37 -0
- data/lib/jdc/cli/populators/base.rb +16 -0
- data/lib/jdc/cli/populators/organization.rb +32 -0
- data/lib/jdc/cli/populators/populator_methods.rb +64 -0
- data/lib/jdc/cli/populators/space.rb +33 -0
- data/lib/jdc/cli/populators/target.rb +13 -0
- data/lib/jdc/cli/route/base.rb +9 -0
- data/lib/jdc/cli/route/delete.rb +28 -0
- data/lib/jdc/cli/route/map.rb +68 -0
- data/lib/jdc/cli/route/routes.rb +26 -0
- data/lib/jdc/cli/route/unmap.rb +56 -0
- data/lib/jdc/cli/service/base.rb +9 -0
- data/lib/jdc/cli/service/bind.rb +44 -0
- data/lib/jdc/cli/service/create.rb +159 -0
- data/lib/jdc/cli/service/delete.rb +83 -0
- data/lib/jdc/cli/service/rename.rb +36 -0
- data/lib/jdc/cli/service/service.rb +42 -0
- data/lib/jdc/cli/service/service_instance_helper.rb +99 -0
- data/lib/jdc/cli/service/services.rb +111 -0
- data/lib/jdc/cli/service/unbind.rb +37 -0
- data/lib/jdc/cli/space/base.rb +29 -0
- data/lib/jdc/cli/space/create.rb +67 -0
- data/lib/jdc/cli/space/delete.rb +56 -0
- data/lib/jdc/cli/space/rename.rb +38 -0
- data/lib/jdc/cli/space/space.rb +66 -0
- data/lib/jdc/cli/space/spaces.rb +57 -0
- data/lib/jdc/cli/space/switch.rb +19 -0
- data/lib/jdc/cli/start/base.rb +41 -0
- data/lib/jdc/cli/start/colors.rb +13 -0
- data/lib/jdc/cli/start/target.rb +50 -0
- data/lib/jdc/cli/start/target_prettifier.rb +17 -0
- data/lib/jdc/cli/start/targets.rb +16 -0
- data/lib/jdc/cli/user/base.rb +30 -0
- data/lib/jdc/cli/user/create.rb +52 -0
- data/lib/jdc/cli/user/passwd.rb +37 -0
- data/lib/jdc/cli/user/register.rb +43 -0
- data/lib/jdc/cli/user/users.rb +32 -0
- data/lib/jdc/constants.rb +11 -0
- data/lib/jdc/errors.rb +19 -0
- data/lib/jdc/object_extensions.rb +15 -0
- data/lib/jdc/plugin.rb +56 -0
- data/lib/jdc/spacing.rb +89 -0
- data/lib/jdc/spec_helper.rb +1 -0
- data/lib/jdc/test_support.rb +6 -0
- data/lib/jdc/version.rb +3 -0
- data/lib/manifests/errors.rb +35 -0
- data/lib/manifests/loader.rb +31 -0
- data/lib/manifests/loader/builder.rb +39 -0
- data/lib/manifests/loader/normalizer.rb +145 -0
- data/lib/manifests/loader/resolver.rb +79 -0
- data/lib/manifests/manifests.rb +344 -0
- data/lib/manifests/plugin.rb +140 -0
- data/lib/micro/README.md +9 -0
- data/lib/micro/errors.rb +4 -0
- data/lib/{jdc → micro}/micro.rb +15 -15
- data/lib/micro/plugin.rb +197 -0
- data/lib/micro/switcher/base.rb +79 -0
- data/lib/{jdc/micro → micro}/switcher/darwin.rb +5 -3
- data/lib/{jdc/micro → micro}/switcher/dummy.rb +1 -1
- data/lib/micro/switcher/linux.rb +16 -0
- data/lib/{jdc/micro → micro}/switcher/windows.rb +5 -5
- data/lib/{jdc/micro → micro}/vmrun.rb +26 -19
- data/lib/tasks/gem_release.rake +42 -0
- data/lib/tunnel/README.md +29 -0
- data/{config → lib/tunnel/config}/clients.yml +2 -2
- data/lib/tunnel/helper-app/Gemfile +10 -0
- data/lib/tunnel/helper-app/Gemfile.lock +48 -0
- data/{caldecott_helper → lib/tunnel/helper-app}/server.rb +5 -5
- data/lib/tunnel/plugin.rb +183 -0
- data/lib/tunnel/tunnel.rb +295 -0
- metadata +371 -210
- data/README.md +0 -102
- data/config/micro/paths.yml +0 -22
- data/config/micro/refresh_ip.rb +0 -20
- data/lib/cli.rb +0 -53
- data/lib/cli/commands/admin.rb +0 -58
- data/lib/cli/commands/apps.rb +0 -1129
- data/lib/cli/commands/base.rb +0 -228
- data/lib/cli/commands/manifest.rb +0 -56
- data/lib/cli/commands/micro.rb +0 -115
- data/lib/cli/commands/misc.rb +0 -126
- data/lib/cli/commands/services.rb +0 -178
- data/lib/cli/commands/user.rb +0 -14
- data/lib/cli/config.rb +0 -173
- data/lib/cli/console_helper.rb +0 -170
- data/lib/cli/core_ext.rb +0 -122
- data/lib/cli/errors.rb +0 -19
- data/lib/cli/frameworks.rb +0 -265
- data/lib/cli/manifest_helper.rb +0 -300
- data/lib/cli/runner.rb +0 -505
- data/lib/cli/services_helper.rb +0 -84
- data/lib/cli/tunnel_helper.rb +0 -332
- data/lib/cli/usage.rb +0 -86
- data/lib/cli/version.rb +0 -7
- data/lib/cli/zip_util.rb +0 -77
- data/lib/jdc/client.rb +0 -457
- data/lib/jdc/const.rb +0 -25
- data/lib/jdc/micro/switcher/base.rb +0 -97
- data/lib/jdc/micro/switcher/linux.rb +0 -16
- data/lib/jdc/signature/version.rb +0 -27
- data/lib/jdc/signer.rb +0 -13
- data/lib/jdc/timer.rb +0 -12
data/lib/jdc/const.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
module JDC
|
2
|
-
|
3
|
-
# This is the internal JDC version number, and is not necessarily
|
4
|
-
# the same as the RubyGem version (JDC::Cli::VERSION).
|
5
|
-
VERSION = '0.2.1'
|
6
|
-
|
7
|
-
# Targets
|
8
|
-
DEFAULT_TARGET = 'https://api.jd-app.com'
|
9
|
-
DEFAULT_LOCAL_TARGET = 'http://api.vcap.me'
|
10
|
-
|
11
|
-
# General Paths
|
12
|
-
INFO_PATH = 'info'
|
13
|
-
GLOBAL_SERVICES_PATH = ['info', 'services']
|
14
|
-
GLOBAL_RUNTIMES_PATH = ['info', 'runtimes']
|
15
|
-
RESOURCES_PATH = 'resources'
|
16
|
-
|
17
|
-
# User specific paths
|
18
|
-
APPS_PATH = 'apps'
|
19
|
-
SERVICES_PATH = 'services'
|
20
|
-
USERS_PATH = 'users'
|
21
|
-
|
22
|
-
#Enviroment Argument
|
23
|
-
ACCESS_KEY = "ACCESS_KEY"
|
24
|
-
SECRET_KEY = "SECRET_KEY"
|
25
|
-
end
|
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'interact'
|
2
|
-
|
3
|
-
module JDC::Micro::Switcher
|
4
|
-
class Base
|
5
|
-
include Interactive
|
6
|
-
|
7
|
-
def initialize(config)
|
8
|
-
@config = config
|
9
|
-
|
10
|
-
@vmrun = JDC::Micro::VMrun.new(config)
|
11
|
-
unless @vmrun.running?
|
12
|
-
if ask("JingDong Cloud VM is not running. Do you want to start it?", :choices => ['y', 'n']) == 'y'
|
13
|
-
display "Starting JingDong Cloud VM: ", false
|
14
|
-
@vmrun.start
|
15
|
-
say "done".green
|
16
|
-
else
|
17
|
-
err "JingDong Cloud VM needs to be running."
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
err "JingDong Cloud VM initial setup needs to be completed before using 'jdc micro'" unless @vmrun.ready?
|
22
|
-
end
|
23
|
-
|
24
|
-
def offline
|
25
|
-
unless @vmrun.offline?
|
26
|
-
# save online connection type so we can restore it later
|
27
|
-
@config['online_connection_type'] = @vmrun.connection_type
|
28
|
-
|
29
|
-
if (@config['online_connection_type'] != 'nat')
|
30
|
-
if ask("Reconfigure JingDong Cloud VM network to nat mode and reboot?", :choices => ['y', 'n']) == 'y'
|
31
|
-
display "Rebooting JingDong Cloud VM: ", false
|
32
|
-
@vmrun.connection_type = 'nat'
|
33
|
-
@vmrun.reset
|
34
|
-
say "done".green
|
35
|
-
else
|
36
|
-
err "Aborted"
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
display "Setting JingDong Cloud VM to offline mode: ", false
|
41
|
-
@vmrun.offline!
|
42
|
-
say "done".green
|
43
|
-
display "Setting host DNS server: ", false
|
44
|
-
|
45
|
-
@config['domain'] = @vmrun.domain
|
46
|
-
@config['ip'] = @vmrun.ip
|
47
|
-
set_nameserver(@config['domain'], @config['ip'])
|
48
|
-
say "done".green
|
49
|
-
else
|
50
|
-
say "JingDong Cloud VM already in offline mode".yellow
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def online
|
55
|
-
if @vmrun.offline?
|
56
|
-
current_connection_type = @vmrun.connection_type
|
57
|
-
@config['online_connection_type'] ||= current_connection_type
|
58
|
-
|
59
|
-
if (@config['online_connection_type'] != current_connection_type)
|
60
|
-
# TODO handle missing connection type in saved config
|
61
|
-
question = "Reconfigure JingDong Cloud VM network to #{@config['online_connection_type']} mode and reboot?"
|
62
|
-
if ask(question, :choices => ['y', 'n']) == 'y'
|
63
|
-
display "Rebooting JingDong Cloud VM: ", false
|
64
|
-
@vmrun.connection_type = @config['online_connection_type']
|
65
|
-
@vmrun.reset
|
66
|
-
say "done".green
|
67
|
-
else
|
68
|
-
err "Aborted"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
display "Unsetting host DNS server: ", false
|
73
|
-
# TODO handle missing domain and ip in saved config (look at the VM)
|
74
|
-
@config['domain'] ||= @vmrun.domain
|
75
|
-
@config['ip'] ||= @vmrun.ip
|
76
|
-
unset_nameserver(@config['domain'], @config['ip'])
|
77
|
-
say "done".green
|
78
|
-
|
79
|
-
display "Setting JingDong Cloud VM to online mode: ", false
|
80
|
-
@vmrun.online!
|
81
|
-
say "done".green
|
82
|
-
else
|
83
|
-
say "JingDong Cloud already in online mode".yellow
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def status
|
88
|
-
mode = @vmrun.offline? ? 'offline' : 'online'
|
89
|
-
say "JingDong Cloud VM currently in #{mode.green} mode"
|
90
|
-
# should the VMX path be unescaped?
|
91
|
-
say "VMX Path: #{@vmrun.vmx}"
|
92
|
-
say "Domain: #{@vmrun.domain.green}"
|
93
|
-
say "IP Address: #{@vmrun.ip.green}"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module JDC::Micro::Switcher
|
2
|
-
|
3
|
-
class Linux < Base
|
4
|
-
def set_nameserver(domain, ip)
|
5
|
-
JDC::Micro.run_command("sudo", "sed -i'.backup' '1 i nameserver #{ip}' /etc/resolv.conf")
|
6
|
-
# lock resolv.conf so Network Manager doesn't clear out the file when offline
|
7
|
-
JDC::Micro.run_command("sudo", "chattr +i /etc/resolv.conf")
|
8
|
-
end
|
9
|
-
|
10
|
-
def unset_nameserver(domain, ip)
|
11
|
-
JDC::Micro.run_command("sudo", "chattr -i /etc/resolv.conf")
|
12
|
-
JDC::Micro.run_command("sudo", "sed -i'.backup' '/#{ip}/d' /etc/resolv.conf")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#encoding=utf-8
|
3
|
-
|
4
|
-
require File.expand_path('../../signer.rb', __FILE__)
|
5
|
-
|
6
|
-
module JDC
|
7
|
-
module Signature
|
8
|
-
module Version
|
9
|
-
|
10
|
-
include JDC::Signer
|
11
|
-
|
12
|
-
def generate_signature secret_key, req
|
13
|
-
return sign(secret_key, string_to_sign(req))
|
14
|
-
end
|
15
|
-
|
16
|
-
def string_to_sign req
|
17
|
-
str = [
|
18
|
-
req[:method],
|
19
|
-
req[:headers]['Content-MD5'],
|
20
|
-
req[:headers]['Content-Type'],
|
21
|
-
req[:headers]['Date'],
|
22
|
-
req[:headers]['Path']
|
23
|
-
].join("\n")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/jdc/signer.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
#encoding=utf-8
|
3
|
-
|
4
|
-
require 'base64'
|
5
|
-
require 'openssl'
|
6
|
-
|
7
|
-
module JDC
|
8
|
-
module Signer
|
9
|
-
def sign secret_key, string_to_sign, digest = 'sha1'
|
10
|
-
return Base64.encode64(OpenSSL::HMAC.digest(digest, secret_key, string_to_sign)).strip
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|