lds-cf-plugin 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/lds-cf-plugin/plugin.rb
CHANGED
@@ -0,0 +1,190 @@
|
|
1
|
+
require "cf/cli"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module LdsCfPlugin
|
5
|
+
class ServiceManagerService < CF::CLI
|
6
|
+
def precondition
|
7
|
+
check_target
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Create a Service Manager Application Service"
|
11
|
+
group :lds, :services
|
12
|
+
#input :instance_name, :desc => "Service Manager application service name", :argument => :optional
|
13
|
+
input :name, :desc => "Service Instance Name", :argument => :optional
|
14
|
+
input :sm_app_name, :desc => "Service Manager application service name", :argument => :optional
|
15
|
+
input :env, :desc => "Environment", :argument => :optional
|
16
|
+
input :prexisting, :desc => "Environment", :argument => :optional
|
17
|
+
|
18
|
+
input :dutyPhone, :desc => "Duty Phone", :argument => :optional
|
19
|
+
input :primaryContact, :desc => "Primary Contact", :argument => :optional
|
20
|
+
input :solutionManager, :desc => "Solution Manager", :argument => :optional
|
21
|
+
input :supportGroup, :desc => "Support Group", :argument => :optional
|
22
|
+
|
23
|
+
input :portfolioId, :desc => "Portfolio ID", :argument => :optional
|
24
|
+
|
25
|
+
def create_servicemanager_service
|
26
|
+
offerings = client.services
|
27
|
+
offerings.keep_if { |s| s.label == 'servicemanager-service' && s.provider == 'ICS' }
|
28
|
+
service = offerings.first
|
29
|
+
|
30
|
+
if !service
|
31
|
+
fail "Cannot find Service Manager service on #{client.target}"
|
32
|
+
end
|
33
|
+
|
34
|
+
if service.version != "0.1"
|
35
|
+
fail "Your lds-cf-plugin version is out of date. To update execute `gem update lds-cf-plugin`"
|
36
|
+
end
|
37
|
+
|
38
|
+
rest_client = CFoundry::RestClient.new(service.url, client.token)
|
39
|
+
rest_client.trace = client.trace
|
40
|
+
|
41
|
+
instance_name = input[:name]
|
42
|
+
if !instance_name
|
43
|
+
instance_name = ask("Name")
|
44
|
+
end
|
45
|
+
|
46
|
+
sm_app_name = input[:sm_app_name]
|
47
|
+
if !sm_app_name
|
48
|
+
sm_app_name = ask("Service Manager App Name")
|
49
|
+
end
|
50
|
+
|
51
|
+
plan = service.service_plans.first
|
52
|
+
|
53
|
+
choices = ["Development","Functional Test", "Staging", "Stage Load","User Acceptance","BETA","Production"]
|
54
|
+
|
55
|
+
env = input[:env]
|
56
|
+
if !env || !choices.include?(env)
|
57
|
+
options = {
|
58
|
+
:choices => choices,
|
59
|
+
:display => proc { |choice|
|
60
|
+
if choice == "Development"
|
61
|
+
"Development"
|
62
|
+
elsif choice == "Functional Test"
|
63
|
+
"Functional Test"
|
64
|
+
elsif choice == "Staging"
|
65
|
+
"Staging"
|
66
|
+
elsif choice == "User Acceptance"
|
67
|
+
"User Acceptance"
|
68
|
+
elsif choice == "Stage Load"
|
69
|
+
"Stage Load"
|
70
|
+
elsif choice == "Production"
|
71
|
+
"Production"
|
72
|
+
elsif choice == "BETA"
|
73
|
+
"Beta"
|
74
|
+
end
|
75
|
+
},
|
76
|
+
:default => "Development",
|
77
|
+
:allow_other => false
|
78
|
+
}
|
79
|
+
env = ask("Service Manager environment to use", options)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# Register service with gateway
|
84
|
+
choices = ["y","n"]
|
85
|
+
|
86
|
+
prexisting = input[:prexisting]
|
87
|
+
if !prexisting || !choices.include?(prexisting)
|
88
|
+
options = {
|
89
|
+
:choices => choices,
|
90
|
+
:display => proc { |choice|
|
91
|
+
if choice == "y"
|
92
|
+
"yes"
|
93
|
+
elsif choice == "n"
|
94
|
+
"no"
|
95
|
+
end
|
96
|
+
},
|
97
|
+
:default => "y",
|
98
|
+
:allow_other => false
|
99
|
+
}
|
100
|
+
prexisting = ask("Use Pre-existing Service Manager application?",options)
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
if prexisting=='y'
|
106
|
+
payload = {
|
107
|
+
:space_guid => client.current_space.guid,
|
108
|
+
:name => instance_name,
|
109
|
+
:smApp => sm_app_name,
|
110
|
+
:Environment => env,
|
111
|
+
:prexisting => true
|
112
|
+
}
|
113
|
+
|
114
|
+
else
|
115
|
+
|
116
|
+
dutyPhone = input[:dutyPhone]
|
117
|
+
if !dutyPhone
|
118
|
+
dutyPhone = ask("Duty Phone (e.g. 1 801 555 5555 ")
|
119
|
+
end
|
120
|
+
|
121
|
+
primaryContact = input[:primaryContact]
|
122
|
+
if !primaryContact
|
123
|
+
primaryContact = ask("Primary Contact")
|
124
|
+
end
|
125
|
+
|
126
|
+
solutionManager = input[:solutionManager]
|
127
|
+
if !solutionManager
|
128
|
+
solutionManager = ask("Solution Manager")
|
129
|
+
end
|
130
|
+
|
131
|
+
supportGroup = input[:supportGroup]
|
132
|
+
if !supportGroup
|
133
|
+
supportGroup = ask("Support Group")
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
portfolioId = input[:portfolioId]
|
138
|
+
if !portfolioId
|
139
|
+
portfolioId = ask("Portfolio ID")
|
140
|
+
end
|
141
|
+
|
142
|
+
payload = {
|
143
|
+
:space_guid => client.current_space.guid,
|
144
|
+
:name => instance_name,
|
145
|
+
:smApp => sm_app_name,
|
146
|
+
:PrimaryContact => primaryContact,
|
147
|
+
:PrimarySupportGroup => supportGroup,
|
148
|
+
:Subtype2 => "CloudFoundryApp",
|
149
|
+
:Environment => env,
|
150
|
+
:Dept => "ICS Info And Comm Systems Dept [ICS]",
|
151
|
+
:DataClassification => "Internal Use",
|
152
|
+
:ChangeApprover => solutionManager,
|
153
|
+
:CriticalityClassification => "Low",
|
154
|
+
:DutyPhone => dutyPhone,
|
155
|
+
:SolutionManager => solutionManager,
|
156
|
+
:SupportContactName => "Support User",
|
157
|
+
:SuuportContactReason => "Primary Contact",
|
158
|
+
:PortfolioId => portfolioId,
|
159
|
+
:RegStandards => "None",
|
160
|
+
:SystemRiskLevel => "Low Risk"
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
options = {
|
165
|
+
:payload => JSON.generate(payload)
|
166
|
+
}
|
167
|
+
with_progress("Registering service ...") do
|
168
|
+
request, response = rest_client.request("POST", "/register", options)
|
169
|
+
if response[:status].to_i != 200
|
170
|
+
fail "Error registering Service Manager app with gateway:\n#{response[:body]}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# Create service instance
|
175
|
+
instance = client.managed_service_instance
|
176
|
+
instance.name = instance_name
|
177
|
+
|
178
|
+
instance.service_plan = plan
|
179
|
+
instance.space = client.current_space
|
180
|
+
|
181
|
+
with_progress("Creating service #{c(instance.name, :name)}") do
|
182
|
+
instance.create!
|
183
|
+
end
|
184
|
+
|
185
|
+
instance
|
186
|
+
end
|
187
|
+
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'eventmachine'
|
2
2
|
require 'interact/pretty'
|
3
|
-
require 'socket'
|
4
3
|
|
5
4
|
module TunnelClient
|
6
5
|
|
@@ -72,7 +71,6 @@ module TunnelClient
|
|
72
71
|
case frame_type
|
73
72
|
when 'E', 'e'
|
74
73
|
# Error
|
75
|
-
puts "Server error: #{frame_body}"
|
76
74
|
close_connection
|
77
75
|
raise frame_body
|
78
76
|
when 'R', 'r'
|
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cf
|
@@ -92,6 +92,7 @@ files:
|
|
92
92
|
- lib/lds-cf-plugin/plugin.rb
|
93
93
|
- lib/lds-cf-plugin/tunnel/tunnelclient.rb
|
94
94
|
- lib/lds-cf-plugin/wam_service.rb
|
95
|
+
- lib/lds-cf-plugin/servicemanager_service.rb
|
95
96
|
homepage: http://ui.app.lds.org/
|
96
97
|
licenses: []
|
97
98
|
post_install_message:
|