lds-cf-plugin 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/lds-cf-plugin/custom_service.rb +5 -28
- data/lib/lds-cf-plugin/http_service.rb +116 -0
- data/lib/lds-cf-plugin/lds_account_service.rb +113 -0
- data/lib/lds-cf-plugin/oracle_service.rb +8 -30
- data/lib/lds-cf-plugin/plugin.rb +3 -0
- data/lib/lds-cf-plugin/tunnel.rb +2 -2
- data/lib/lds-cf-plugin/version.rb +1 -1
- data/lib/lds-cf-plugin/wam_service.rb +51 -0
- metadata +8 -5
@@ -11,11 +11,6 @@ module LdsCfPlugin
|
|
11
11
|
group :lds, :services
|
12
12
|
input :name, :desc => "Name for your service", :argument => :optional
|
13
13
|
input :credentials, :desc => "The service credentials JSON string to be passed to the application", :argument => :optional
|
14
|
-
input :plan, :desc => "Service plan",
|
15
|
-
:from_given => find_by_name_insensitive("plan"),
|
16
|
-
:default => proc {
|
17
|
-
interact
|
18
|
-
}
|
19
14
|
def create_custom_service
|
20
15
|
offerings = client.services
|
21
16
|
offerings.keep_if { |s| s.label == 'custom-service' && s.provider == 'ICS' }
|
@@ -24,6 +19,10 @@ module LdsCfPlugin
|
|
24
19
|
if !service
|
25
20
|
fail "Cannot find custom service on #{client.target}"
|
26
21
|
end
|
22
|
+
|
23
|
+
if service.version != "0.1"
|
24
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
25
|
+
end
|
27
26
|
|
28
27
|
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
29
28
|
rest_client.trace = client.trace
|
@@ -33,15 +32,6 @@ module LdsCfPlugin
|
|
33
32
|
instance_name = ask("Name")
|
34
33
|
end
|
35
34
|
|
36
|
-
if plan = input.direct(:plan)
|
37
|
-
service.reject! do |s|
|
38
|
-
if plan.is_a?(String)
|
39
|
-
s.service_plans.none? { |p| p.name == plan.upcase }
|
40
|
-
else
|
41
|
-
s.service_plans.include? plan
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
35
|
plan = service.service_plans.first
|
46
36
|
|
47
37
|
credentials = input[:credentials]
|
@@ -68,7 +58,7 @@ module LdsCfPlugin
|
|
68
58
|
|
69
59
|
|
70
60
|
# Create service instance
|
71
|
-
instance = client.
|
61
|
+
instance = client.managed_service_instance
|
72
62
|
instance.name = instance_name
|
73
63
|
|
74
64
|
instance.service_plan = plan
|
@@ -80,18 +70,5 @@ module LdsCfPlugin
|
|
80
70
|
|
81
71
|
instance
|
82
72
|
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def ask_plan(plans, default_plan = nil)
|
87
|
-
ask "Which plan?",
|
88
|
-
:choices => plans.sort_by(&:name),
|
89
|
-
:indexed => true,
|
90
|
-
:display => proc { |p| "#{p.name}: #{p.description || 'No description'}" },
|
91
|
-
:default => default_plan,
|
92
|
-
:complete => proc(&:name)
|
93
|
-
end
|
94
|
-
|
95
73
|
end
|
96
|
-
|
97
74
|
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
require "json"
|
3
|
+
require "uri"
|
4
|
+
|
5
|
+
module LdsCfPlugin
|
6
|
+
class HttpService < CF::CLI
|
7
|
+
def precondition
|
8
|
+
check_target
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Create an Http service"
|
12
|
+
group :lds, :services
|
13
|
+
input :name, :desc => "Name for your service", :argument => :optional
|
14
|
+
input :url, :desc => "The http URL you wish to add as a service.", :argument => :optional
|
15
|
+
|
16
|
+
def create_http_service
|
17
|
+
offerings = client.services
|
18
|
+
offerings.keep_if { |s| s.label == 'http-service' && s.provider == 'ICS' }
|
19
|
+
service = offerings.first
|
20
|
+
|
21
|
+
if !service
|
22
|
+
fail "Cannot find Http service on #{client.target}"
|
23
|
+
end
|
24
|
+
|
25
|
+
if service.version != "0.1"
|
26
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
27
|
+
end
|
28
|
+
|
29
|
+
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
30
|
+
rest_client.trace = client.trace
|
31
|
+
|
32
|
+
instance_name = input[:name]
|
33
|
+
if !instance_name
|
34
|
+
instance_name = ask("Name")
|
35
|
+
end
|
36
|
+
|
37
|
+
plan = service.service_plans.first
|
38
|
+
|
39
|
+
url = input[:url]
|
40
|
+
while !url || !is_valid_url(url)[0]
|
41
|
+
success, result = is_valid_url(url);
|
42
|
+
if url && !success
|
43
|
+
line c("The url you provided #{b("'#{url}'")} is not valid.", :bad)
|
44
|
+
line c("Error: #{result}", :bad) unless result.nil?
|
45
|
+
end
|
46
|
+
url = ask("URL")
|
47
|
+
end
|
48
|
+
|
49
|
+
parsedUrl = URI.parse(url)
|
50
|
+
|
51
|
+
prompt_credentials = parsedUrl.user.nil?
|
52
|
+
if !input[:url]
|
53
|
+
prompt_credentials = ask("Provide Credentials?", :default => false) if parsedUrl.user.nil? && input[:username].nil?
|
54
|
+
else
|
55
|
+
prompt_credentials = false
|
56
|
+
end
|
57
|
+
|
58
|
+
username = input[:username]
|
59
|
+
if !username && prompt_credentials
|
60
|
+
username = ask("Username")
|
61
|
+
end
|
62
|
+
|
63
|
+
password = input[:password]
|
64
|
+
if !password && prompt_credentials
|
65
|
+
password = ask("Password", :echo => "*", :forget => true, :default => "")
|
66
|
+
end
|
67
|
+
|
68
|
+
# Register service with gateway
|
69
|
+
|
70
|
+
payload = {
|
71
|
+
:space_guid => client.current_space.guid,
|
72
|
+
:name => instance_name,
|
73
|
+
:url => url,
|
74
|
+
}
|
75
|
+
if parsedUrl.user.nil?
|
76
|
+
payload[:username] = username
|
77
|
+
payload[:password] = password
|
78
|
+
end
|
79
|
+
options = {
|
80
|
+
:payload => JSON.generate(payload)
|
81
|
+
}
|
82
|
+
request, response = rest_client.request("POST", "/register", options)
|
83
|
+
if response[:status].to_i != 200
|
84
|
+
fail "Error registering Http service with gateway:\n#{response[:body]}"
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
# Create service instance
|
89
|
+
instance = client.managed_service_instance
|
90
|
+
instance.name = instance_name
|
91
|
+
|
92
|
+
instance.service_plan = plan
|
93
|
+
instance.space = client.current_space
|
94
|
+
|
95
|
+
with_progress("Creating service #{c(instance.name, :name)}") do
|
96
|
+
instance.create!
|
97
|
+
end
|
98
|
+
|
99
|
+
instance
|
100
|
+
end
|
101
|
+
|
102
|
+
def is_valid_url(url)
|
103
|
+
begin
|
104
|
+
parsedUrl = URI.parse(url)
|
105
|
+
unless(parsedUrl.scheme == "https" || parsedUrl.scheme == "http")
|
106
|
+
return false, "Scheme '#{parsedUrl.scheme}' is invalid."
|
107
|
+
end
|
108
|
+
rescue => e
|
109
|
+
return false, e.message
|
110
|
+
end
|
111
|
+
return true, nil
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module LdsCfPlugin
|
5
|
+
class LDSAccountService < CF::CLI
|
6
|
+
def precondition
|
7
|
+
check_target
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Create an LDS Account service"
|
11
|
+
group :lds, :services
|
12
|
+
input :name, :desc => "Name for your service", :argument => :optional
|
13
|
+
input :env, :desc => "LDS Account Environment (prod, stage, community)", :argument => :optional
|
14
|
+
input :cn, :desc => "The application account Common Name (cn)", :argument => :optional
|
15
|
+
input :password, :desc => "The password used to connect to the database", :argument => :optional
|
16
|
+
|
17
|
+
def create_lds_account_service
|
18
|
+
offerings = client.services
|
19
|
+
offerings.keep_if { |s| s.label == 'lds-account-service' && s.provider == 'ICS' }
|
20
|
+
service = offerings.first
|
21
|
+
|
22
|
+
if !service
|
23
|
+
fail "Cannot find LDS Account service on #{client.target}"
|
24
|
+
end
|
25
|
+
|
26
|
+
if service.version != "0.1"
|
27
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
28
|
+
end
|
29
|
+
|
30
|
+
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
31
|
+
rest_client.trace = client.trace
|
32
|
+
|
33
|
+
instance_name = input[:name]
|
34
|
+
if !instance_name
|
35
|
+
instance_name = ask("Name")
|
36
|
+
end
|
37
|
+
|
38
|
+
plan = service.service_plans.first
|
39
|
+
|
40
|
+
choices = ["prod", "stage", "community"]
|
41
|
+
|
42
|
+
env = input[:env]
|
43
|
+
if !env || !choices.include?(env)
|
44
|
+
options = {
|
45
|
+
:choices => choices,
|
46
|
+
:display => proc { |choice|
|
47
|
+
if choice == "prod"
|
48
|
+
"Prod (gdir)"
|
49
|
+
elsif choice == "stage"
|
50
|
+
"Stage (gdirstage)"
|
51
|
+
elsif choice == "community"
|
52
|
+
"Community (cdir)"
|
53
|
+
end
|
54
|
+
},
|
55
|
+
:default => "prod",
|
56
|
+
:allow_other => false
|
57
|
+
}
|
58
|
+
env = ask("LDS Account environment to use", options)
|
59
|
+
end
|
60
|
+
|
61
|
+
cn = input[:cn]
|
62
|
+
while !cn || !is_valid_cn(cn)
|
63
|
+
if cn && !is_valid_cn(cn)
|
64
|
+
line c("The cn you provided #{b("'#{cn}'")} is invalid.", :bad)
|
65
|
+
line c("Perhaps you tried providing a fully qualified principal? We only want the cn= portion. Try again.", :bad)
|
66
|
+
end
|
67
|
+
cn = ask("Application account principal Common Name (cn)")
|
68
|
+
end
|
69
|
+
|
70
|
+
password = input[:password]
|
71
|
+
if !password
|
72
|
+
password = ask("Application account password", :echo => "*", :forget => true)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Register service with gateway
|
76
|
+
|
77
|
+
payload = {
|
78
|
+
:space_guid => client.current_space.guid,
|
79
|
+
:name => instance_name,
|
80
|
+
:env => env,
|
81
|
+
:cn => cn,
|
82
|
+
:password => password
|
83
|
+
}
|
84
|
+
options = {
|
85
|
+
:payload => JSON.generate(payload)
|
86
|
+
}
|
87
|
+
request, response = rest_client.request("POST", "/register", options)
|
88
|
+
if response[:status].to_i != 200
|
89
|
+
fail "Error registering LDS Account service with gateway:\n#{response[:body]}"
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Create service instance
|
94
|
+
instance = client.managed_service_instance
|
95
|
+
instance.name = instance_name
|
96
|
+
|
97
|
+
instance.service_plan = plan
|
98
|
+
instance.space = client.current_space
|
99
|
+
|
100
|
+
with_progress("Creating service #{c(instance.name, :name)}") do
|
101
|
+
instance.create!
|
102
|
+
end
|
103
|
+
|
104
|
+
instance
|
105
|
+
end
|
106
|
+
|
107
|
+
def is_valid_cn(cn)
|
108
|
+
!(cn.include?("cn=") || cn.include?("ou=") || cn.include?("o=")|| cn.include?(","))
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -2,7 +2,7 @@ require "cf/cli"
|
|
2
2
|
require "json"
|
3
3
|
|
4
4
|
module LdsCfPlugin
|
5
|
-
class
|
5
|
+
class OracleService < CF::CLI
|
6
6
|
def precondition
|
7
7
|
check_target
|
8
8
|
end
|
@@ -12,12 +12,8 @@ module LdsCfPlugin
|
|
12
12
|
input :name, :desc => "Name for your service", :argument => :optional
|
13
13
|
input :service, :desc => "The Oracle database to connect to", :argument => :optional
|
14
14
|
input :schema, :desc => "The schema (user) to use", :argument => :optional
|
15
|
-
input :password, :desc => "The password used to
|
16
|
-
|
17
|
-
:from_given => find_by_name_insensitive("plan"),
|
18
|
-
:default => proc {
|
19
|
-
interact
|
20
|
-
}
|
15
|
+
input :password, :desc => "The password used to connect to the database", :argument => :optional
|
16
|
+
|
21
17
|
def create_oracle_service
|
22
18
|
offerings = client.services
|
23
19
|
offerings.keep_if { |s| s.label == 'oracle-service' && s.provider == 'ICS' }
|
@@ -26,6 +22,10 @@ module LdsCfPlugin
|
|
26
22
|
if !service
|
27
23
|
fail "Cannot find Oracle service on #{client.target}"
|
28
24
|
end
|
25
|
+
|
26
|
+
if service.version != "0.1"
|
27
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
28
|
+
end
|
29
29
|
|
30
30
|
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
31
31
|
rest_client.trace = client.trace
|
@@ -35,15 +35,6 @@ module LdsCfPlugin
|
|
35
35
|
instance_name = ask("Name")
|
36
36
|
end
|
37
37
|
|
38
|
-
if plan = input.direct(:plan)
|
39
|
-
service.reject! do |s|
|
40
|
-
if plan.is_a?(String)
|
41
|
-
s.service_plans.none? { |p| p.name == plan.upcase }
|
42
|
-
else
|
43
|
-
s.service_plans.include? plan
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
38
|
plan = service.service_plans.first
|
48
39
|
|
49
40
|
service = input[:service]
|
@@ -80,7 +71,7 @@ module LdsCfPlugin
|
|
80
71
|
|
81
72
|
|
82
73
|
# Create service instance
|
83
|
-
instance = client.
|
74
|
+
instance = client.managed_service_instance
|
84
75
|
instance.name = instance_name
|
85
76
|
|
86
77
|
instance.service_plan = plan
|
@@ -92,18 +83,5 @@ module LdsCfPlugin
|
|
92
83
|
|
93
84
|
instance
|
94
85
|
end
|
95
|
-
|
96
|
-
private
|
97
|
-
|
98
|
-
def ask_plan(plans, default_plan = nil)
|
99
|
-
ask "Which plan?",
|
100
|
-
:choices => plans.sort_by(&:name),
|
101
|
-
:indexed => true,
|
102
|
-
:display => proc { |p| "#{p.name}: #{p.description || 'No description'}" },
|
103
|
-
:default => default_plan,
|
104
|
-
:complete => proc(&:name)
|
105
|
-
end
|
106
|
-
|
107
86
|
end
|
108
|
-
|
109
87
|
end
|
data/lib/lds-cf-plugin/plugin.rb
CHANGED
@@ -8,4 +8,7 @@ Mothership::Help.groups(
|
|
8
8
|
|
9
9
|
require "lds-cf-plugin/custom_service"
|
10
10
|
require "lds-cf-plugin/oracle_service"
|
11
|
+
require "lds-cf-plugin/lds_account_service"
|
12
|
+
require "lds-cf-plugin/http_service"
|
13
|
+
require "lds-cf-plugin/wam_service"
|
11
14
|
require "lds-cf-plugin/tunnel"
|
data/lib/lds-cf-plugin/tunnel.rb
CHANGED
@@ -117,7 +117,7 @@ module LdsCfPlugin
|
|
117
117
|
tunnel_console do |instances|
|
118
118
|
visualvm = input[:jvisualvm] ? input[:jvisualvm] : "jvisualvm"
|
119
119
|
EventMachine::defer do
|
120
|
-
if system("#{visualvm} -cp:a #{JMXMP_JAR_FILE}") == nil
|
120
|
+
if system("''#{visualvm}'' -cp:a #{JMXMP_JAR_FILE}") == nil
|
121
121
|
fail("Unable to run '#{visualvm}'. Is it in your PATH?")
|
122
122
|
end
|
123
123
|
end
|
@@ -131,7 +131,7 @@ module LdsCfPlugin
|
|
131
131
|
instances.each do |instance|
|
132
132
|
jmxurl = "service:jmx:jmxmp://#{host}:#{port}"
|
133
133
|
puts "Adding instance #{c('#' + instance.id, :instance)} to VisualVM (#{c(jmxurl, :instance)})"
|
134
|
-
system("#{visualvm} --openjmx #{jmxurl}")
|
134
|
+
system("''#{visualvm}'' --openjmx #{jmxurl}")
|
135
135
|
port = port + 1
|
136
136
|
end
|
137
137
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module LdsCfPlugin
|
5
|
+
class WamService < CF::CLI
|
6
|
+
def precondition
|
7
|
+
check_target
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Create a Wam Service"
|
11
|
+
group :lds, :services
|
12
|
+
input :name, :desc => "Name for your service", :argument => :optional
|
13
|
+
|
14
|
+
def create_wam_service
|
15
|
+
offerings = client.services
|
16
|
+
offerings.keep_if { |s| s.label == 'wam-service' && s.provider == 'ICS' }
|
17
|
+
service = offerings.first
|
18
|
+
|
19
|
+
if !service
|
20
|
+
fail "Cannot find Wam service on #{client.target}"
|
21
|
+
end
|
22
|
+
|
23
|
+
if service.version != "0.1"
|
24
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
25
|
+
end
|
26
|
+
|
27
|
+
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
28
|
+
rest_client.trace = client.trace
|
29
|
+
|
30
|
+
instance_name = input[:name]
|
31
|
+
if !instance_name
|
32
|
+
instance_name = ask("Name")
|
33
|
+
end
|
34
|
+
|
35
|
+
plan = service.service_plans.first
|
36
|
+
|
37
|
+
# Create service instance
|
38
|
+
instance = client.managed_service_instance
|
39
|
+
instance.name = instance_name
|
40
|
+
|
41
|
+
instance.service_plan = plan
|
42
|
+
instance.space = client.current_space
|
43
|
+
|
44
|
+
with_progress("Creating service #{c(instance.name, :name)}") do
|
45
|
+
instance.create!
|
46
|
+
end
|
47
|
+
|
48
|
+
instance
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lds-cf-plugin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,16 +9,16 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: cf
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 5.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 5.2.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: eventmachine
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,12 +67,15 @@ extensions: []
|
|
67
67
|
extra_rdoc_files: []
|
68
68
|
files:
|
69
69
|
- Rakefile
|
70
|
+
- lib/lds-cf-plugin/http_service.rb
|
70
71
|
- lib/lds-cf-plugin/custom_service.rb
|
72
|
+
- lib/lds-cf-plugin/lds_account_service.rb
|
71
73
|
- lib/lds-cf-plugin/oracle_service.rb
|
72
74
|
- lib/lds-cf-plugin/tunnel.rb
|
73
75
|
- lib/lds-cf-plugin/version.rb
|
74
76
|
- lib/lds-cf-plugin/plugin.rb
|
75
77
|
- lib/lds-cf-plugin/tunnel/tunnelclient.rb
|
78
|
+
- lib/lds-cf-plugin/wam_service.rb
|
76
79
|
homepage: http://ui.app.lds.org/
|
77
80
|
licenses: []
|
78
81
|
post_install_message:
|