Module: Puppet_X::Coi::Jboss::Provider::Datasource
Overview
A class for JBoss datasource provider
Defined Under Namespace
Modules: Static
Classes: PostWildFlyProvider, PreWildFlyProvider
Constant Summary
Constants included
from Constants
Constants::ABSENTLIKE, Constants::ABSENTLIKE_WITH_S
Instance Method Summary
collapse
Instance Method Details
#controller ⇒ Object
116
117
118
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 116
def controller
getproperty :controller
end
|
#create ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 7
def create
cmd = [ "#{create_delete_cmd} add --name=#{@resource[:name]}" ]
jta_opt(cmd)
cmd.push "--jndi-name=#{@resource[:jndiname].inspect}"
cmd.push "--driver-name=#{@resource[:drivername].inspect}"
cmd.push "--min-pool-size=#{@resource[:minpoolsize].inspect}"
cmd.push "--max-pool-size=#{@resource[:maxpoolsize].inspect}"
cmd.push "--user-name=#{@resource[:username].inspect}"
cmd.push "--password=#{@resource[:password].inspect}"
if @resource[:xa]
xa_properties = xa_datasource_properties_wrapper(createXaProperties)
cmd.push "--xa-datasource-properties=#{xa_properties}"
else
cmd.push "--connection-url=#{connectionUrl.inspect}"
end
@resource[:options].each do |attribute, value|
cmd.push "--#{attribute}=#{value.inspect}"
end
bringUp 'Datasource', cmd.join(' ')
setenabled true
end
|
#dbname ⇒ Object
224
225
226
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 224
def dbname
connectionHash()[:DatabaseName]
end
|
#dbname=(value) ⇒ Object
228
229
230
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 228
def dbname= value
writeConnection :DatabaseName, value
end
|
#destroy ⇒ Object
30
31
32
33
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 30
def destroy
cmd = "#{create_delete_cmd} remove --name=#{@resource[:name]}"
bringDown 'Datasource', cmd
end
|
#drivername ⇒ Object
134
135
136
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 134
def drivername
getattrib 'driver-name'
end
|
#drivername=(value) ⇒ Object
138
139
140
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 138
def drivername= value
setattrib 'driver-name', value
end
|
#enabled ⇒ Object
191
192
193
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 191
def enabled
getattrib('enabled').to_s
end
|
#enabled=(value) ⇒ Object
195
196
197
198
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 195
def enabled= value
Puppet.debug "Enabling datasource #{@resource[:name]} to #{value}"
setenabled value
end
|
#exists? ⇒ Boolean
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 74
def exists?
prepare_resource
if @resource[:dbname].nil?
@resource[:dbname] = @resource[:name]
end
@data = nil
cmd = compilecmd "#{datasource_path}:read-resource(recursive=true)"
res = executeAndGet cmd
if(res[:result] == false)
Puppet.debug "Datasorce (xa: #{xa?}) `#{@resource[:name]}` does NOT exist"
return false
end
Puppet.debug "Datasorce (xa: #{xa?}) `#{@resource[:name]}` exists: #{res[:data].inspect}"
@data = res[:data]
return true
end
|
#getattrib(name, default = nil) ⇒ Object
232
233
234
235
236
237
238
239
240
241
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 232
def getattrib name, default=nil
if not @readed
exists?
@readed = true
end
if not @data.nil? and @data.key? name
return @data[name]
end
return default
end
|
#getproperty(name, default = nil) ⇒ Object
95
96
97
98
99
100
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 95
def getproperty name, default=nil
if @property_hash.nil? or (@property_hash.respond_to? :key? and not @property_hash.key? name) or @property_hash[name].nil?
return default
end
return @property_hash[name]
end
|
#host ⇒ Object
208
209
210
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 208
def host
connectionHash()[:ServerName].to_s
end
|
#host=(value) ⇒ Object
212
213
214
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 212
def host= value
writeConnection :ServerName, value
end
|
#jdbcscheme ⇒ Object
200
201
202
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 200
def jdbcscheme
connectionHash()[:Scheme]
end
|
#jdbcscheme=(value) ⇒ Object
204
205
206
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 204
def jdbcscheme= value
writeConnection :Scheme, value
end
|
#jndiname ⇒ Object
126
127
128
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 126
def jndiname
getattrib 'jndi-name'
end
|
#jndiname=(value) ⇒ Object
130
131
132
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 130
def jndiname= value
setattrib 'jndi-name', value
end
|
#jta ⇒ Object
248
249
250
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 248
def jta
provider_impl.jta
end
|
#jta=(value) ⇒ Object
252
253
254
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 252
def jta= value
provider_impl.jta = value
end
|
#jta_opt(cmd) ⇒ Object
268
269
270
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 268
def jta_opt(cmd)
provider_impl.jta_opt(cmd)
end
|
#maxpoolsize ⇒ Object
150
151
152
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 150
def maxpoolsize
getattrib('max-pool-size').to_s
end
|
#maxpoolsize=(value) ⇒ Object
154
155
156
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 154
def maxpoolsize= value
setattrib 'max-pool-size', value
end
|
#minpoolsize ⇒ Object
142
143
144
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 142
def minpoolsize
getattrib('min-pool-size').to_s
end
|
#minpoolsize=(value) ⇒ Object
146
147
148
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 146
def minpoolsize= value
setattrib 'min-pool-size', value
end
|
#name ⇒ Object
91
92
93
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 91
def name
@property_hash[:name]
end
|
#options ⇒ Object
174
175
176
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 174
def options
managed_fetched_options
end
|
#options=(value) ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 178
def options= value
managed_fetched_options.each do |key, fetched_value|
if ABSENTLIKE.include?(value)
expected_value = nil
else
expected_value = value[key]
end
if expected_value != fetched_value
setattrib(key, expected_value)
end
end
end
|
#password ⇒ Object
166
167
168
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 166
def password
getattrib('password')
end
|
#password=(value) ⇒ Object
170
171
172
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 170
def password= value
setattrib 'password', value
end
|
#port ⇒ Object
216
217
218
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 216
def port
connectionHash()[:PortNumber].to_i
end
|
#port=(value) ⇒ Object
220
221
222
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 220
def port= value
writeConnection :PortNumber, value
end
|
#prepare_resource ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 53
def prepare_resource
if @resource.nil?
@resource = {}
end
if @resource[:name].nil?
@resource[:name] = @property_hash[:name]
end
if @resource[:controller].nil?
@resource[:controller] = controller
end
if @resource[:runasdomain].nil?
@resource[:runasdomain] = runasdomain
end
if @resource[:profile].nil?
@resource[:profile] = profile
end
if @resource[:xa].nil?
@resource[:xa] = xa
end
end
|
#profile ⇒ Object
119
120
121
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 119
def profile
getproperty :profile, default_profile
end
|
#runasdomain ⇒ Object
122
123
124
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 122
def runasdomain
getproperty :runasdomain
end
|
#setattrib(name, value) ⇒ Object
243
244
245
246
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 243
def setattrib name, value
setattribute datasource_path, name, value
@data[name] = value
end
|
#setenabled(setting) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 37
def setenabled setting
Puppet.debug "setenabled #{setting.inspect}"
cmd = compilecmd "#{datasource_path}:read-attribute(name=enabled)"
res = executeAndGet cmd
enabled = res[:data]
Puppet.debug "Enabling datasource #{@resource[:name]} = #{enabled}: #{setting}"
if enabled != setting
if setting
cmd = compilecmd "#{datasource_path}:enable(persistent=true)"
else
cmd = compilecmd "#{datasource_path}:disable(persistent=true)"
end
bringUp "Datasource enable set to #{setting.to_s}", cmd
end
end
|
#username ⇒ Object
158
159
160
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 158
def username
getattrib('user-name')
end
|
#username=(value) ⇒ Object
162
163
164
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 162
def username= value
setattrib 'user-name', value
end
|
#xa ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 101
def xa
setting = getproperty :xa, nil
if not setting.nil?
return setting
else
return xa?
end
end
|
#xa=(value) ⇒ Object
109
110
111
112
113
114
115
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 109
def xa= value
actual = getproperty :xa, false
if actual.to_s != value.to_s
destroy
create
end
end
|
#xa? ⇒ Boolean
256
257
258
259
260
261
262
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 256
def xa?
if not @resource[:xa].nil?
return @resource[:xa]
else
return false
end
end
|
#xa_datasource_properties_wrapper(parameters) ⇒ Object
264
265
266
|
# File 'lib/puppet_x/coi/jboss/provider/datasource.rb', line 264
def xa_datasource_properties_wrapper(parameters)
provider_impl.xa_datasource_properties_wrapper(parameters)
end
|