capistrano-karaf 1.2.6 → 1.3
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/capistrano-karaf/core.rb +258 -0
- data/lib/capistrano-karaf/extended.rb +125 -0
- data/lib/capistrano-karaf.rb +3 -188
- metadata +3 -1
@@ -0,0 +1,258 @@
|
|
1
|
+
# Core functionality of capistrano-karaf.
|
2
|
+
# This should only provide functions that map directly to karaf commands.
|
3
|
+
|
4
|
+
require 'sshkit'
|
5
|
+
|
6
|
+
SSHKit.config.command_map[:features_addurl] = 'features:addurl'
|
7
|
+
SSHKit.config.command_map[:features_listurl] = 'features:listurl'
|
8
|
+
SSHKit.config.command_map[:features_removeurl] = 'features:removeurl'
|
9
|
+
SSHKit.config.command_map[:features_refreshurl] = 'features:refreshurl'
|
10
|
+
SSHKit.config.command_map[:features_install] = 'features:install'
|
11
|
+
SSHKit.config.command_map[:features_uninstall] = 'features:uninstall'
|
12
|
+
SSHKit.config.command_map[:features_list] = 'features:list'
|
13
|
+
SSHKit.config.command_map[:features_info] = 'features:info'
|
14
|
+
SSHKit.config.command_map[:headers] = 'headers'
|
15
|
+
SSHKit.config.command_map[:list] = 'osgi:list -t 0'
|
16
|
+
SSHKit.config.command_map[:log_set] = 'log:set'
|
17
|
+
SSHKit.config.command_map[:stop] = 'osgi:stop'
|
18
|
+
SSHKit.config.command_map[:start] = 'osgi:start'
|
19
|
+
SSHKit.config.command_map[:uninstall] = 'osgi:uninstall --force'
|
20
|
+
|
21
|
+
module Capistrano_Karaf
|
22
|
+
# Add a feature url to the karaf server
|
23
|
+
#
|
24
|
+
# url - the string containing the url
|
25
|
+
#
|
26
|
+
# Examples
|
27
|
+
# add_url "mvn:com.melexis.esb/eventstore-feature/#{eventStoreVersion}/xml/features"
|
28
|
+
# # => nil
|
29
|
+
#
|
30
|
+
# Returns nothing
|
31
|
+
def add_url (url)
|
32
|
+
execute(:features_addurl, url)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Remove a feature url from the karaf server
|
36
|
+
#
|
37
|
+
# url - the string containing the url
|
38
|
+
#
|
39
|
+
# Examples
|
40
|
+
# remove_url "mvn:repository/eventstore-feature/1.0.0/xml/features"
|
41
|
+
# # => nil
|
42
|
+
#
|
43
|
+
# Returns nothing
|
44
|
+
def remove_url (url)
|
45
|
+
execute(:features_removeurl, url)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Refresh the urls containing the feature repositories on the karaf server
|
49
|
+
#
|
50
|
+
# Examples
|
51
|
+
# features_refreshurl
|
52
|
+
# # => nil
|
53
|
+
#
|
54
|
+
# Returns nothing
|
55
|
+
def features_refreshurl
|
56
|
+
execute(:features_refreshurl)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Install a feature on the karaf server
|
60
|
+
#
|
61
|
+
# name - the string containing the feature name
|
62
|
+
#
|
63
|
+
# Examples
|
64
|
+
# feature_install "hello"
|
65
|
+
# # => nil
|
66
|
+
#
|
67
|
+
# Returns nothing
|
68
|
+
def feature_install (name)
|
69
|
+
execute(:features_install, name)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Uninstall a feature on the karaf server
|
73
|
+
#
|
74
|
+
# name - the string containing the feature name
|
75
|
+
#
|
76
|
+
# Examples
|
77
|
+
# feature_uninstall "hello"
|
78
|
+
# # => nil
|
79
|
+
#
|
80
|
+
# Returns nothing
|
81
|
+
def feature_uninstall (name)
|
82
|
+
execute(:features_uninstall, name)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Set the log level on the karaf server
|
86
|
+
#
|
87
|
+
# level - the string containing the level
|
88
|
+
#
|
89
|
+
# Examples
|
90
|
+
# log_set "debug"
|
91
|
+
# # => nil
|
92
|
+
#
|
93
|
+
# Returns nothing
|
94
|
+
def log_set (level)
|
95
|
+
execute(:log_set, level)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Start a bundle with the specified bundleId on the karaf server
|
99
|
+
#
|
100
|
+
# bundleId - a number containing the id of the bundle
|
101
|
+
#
|
102
|
+
# Examples
|
103
|
+
# start 100
|
104
|
+
# # => nil
|
105
|
+
#
|
106
|
+
# Returns nothing
|
107
|
+
def start (bundleId)
|
108
|
+
execute(:start, bundleId)
|
109
|
+
end
|
110
|
+
|
111
|
+
# Stop a bundle with the specified bundleId on the karaf server
|
112
|
+
#
|
113
|
+
# bundleId - a number containing the id of the bundle
|
114
|
+
#
|
115
|
+
# Examples
|
116
|
+
# stop 100
|
117
|
+
# # => nil
|
118
|
+
#
|
119
|
+
# Returns nothing
|
120
|
+
def stop (bundleId)
|
121
|
+
execute(:stop, bundleId)
|
122
|
+
end
|
123
|
+
|
124
|
+
# Uninstall a bundle with the specified bundleId from the karaf server
|
125
|
+
#
|
126
|
+
# bundleId - a number containing the id of the bundle
|
127
|
+
#
|
128
|
+
# Examples
|
129
|
+
# start 100
|
130
|
+
# # => nil
|
131
|
+
#
|
132
|
+
# Returns nothing
|
133
|
+
def uninstall (bundleId)
|
134
|
+
execute(:uninstall, bundleId)
|
135
|
+
end
|
136
|
+
|
137
|
+
# List all feature urls on the karaf server
|
138
|
+
#
|
139
|
+
# Examples
|
140
|
+
# list_urls
|
141
|
+
# # => [{:status => "Installed", :groupID => "repository", :artifactID => "repository", :version => "1.0.0"}]
|
142
|
+
#
|
143
|
+
# Returns a list of hashmaps containing all feature repositories
|
144
|
+
def list_urls
|
145
|
+
url_line_matcher = %r{ (?<status> \w+){0}
|
146
|
+
(?<groupID> [\d\w\.\-]+){0}
|
147
|
+
(?<artifactID> [\w\.\-]+){0}
|
148
|
+
(?<version> [\w\.\-]+){0}
|
149
|
+
|
150
|
+
\s*\g<status>\s*mvn\:\g<groupID>\/\g<artifactID>\/\g<version>.*
|
151
|
+
}x
|
152
|
+
|
153
|
+
data = capture(:features_listurl)
|
154
|
+
matcher_to_hash(url_line_matcher, data)
|
155
|
+
end
|
156
|
+
|
157
|
+
# List all features on the karaf server
|
158
|
+
#
|
159
|
+
# Examples
|
160
|
+
# list_features
|
161
|
+
# # => [{:status => "Installed", :name => "camel-core", :repository => "repository", :version => "1.0.0"}]
|
162
|
+
#
|
163
|
+
# Returns a list of hashmaps containing all available features
|
164
|
+
def list_features
|
165
|
+
feature_line_matcher = %r{ (?<status> \w+){0}
|
166
|
+
(?<version> [\d\w\-\.\s]+){0}
|
167
|
+
(?<name> [\w\-\:]+){0}
|
168
|
+
(?<repository> [\w\-\s\:\.]+){0}
|
169
|
+
|
170
|
+
^\[\s*\g<status>\s*\]\s\[\s*\g<version>\s*\]\s*\g<name>\s*\g<repository>
|
171
|
+
}x
|
172
|
+
|
173
|
+
data = capture(:features_list)
|
174
|
+
matcher_to_hash(feature_line_matcher, data)
|
175
|
+
end
|
176
|
+
|
177
|
+
# List all bundles on the karaf server
|
178
|
+
#
|
179
|
+
# Examples
|
180
|
+
# list_bundles
|
181
|
+
# # => [{:id => "10", :status => "INSTALLED", :blueprint => "", :context => "", :level => "60", :name => "camel-core", :version => "1.0.0"}]
|
182
|
+
#
|
183
|
+
# Returns a list of hashmaps containing the installed bundles
|
184
|
+
def list_bundles
|
185
|
+
bundle_line_matcher = %r{(?<id> \d+){0}
|
186
|
+
(?<status> \w+){0}
|
187
|
+
(?<blueprint> \w*){0}
|
188
|
+
(?<context> \w*){0}
|
189
|
+
(?<level> \d+){0}
|
190
|
+
(?<name> [\w\s\-\:]+){0}
|
191
|
+
(?<version> .+){0}
|
192
|
+
|
193
|
+
^\[\s*\g<id>\]\s\[\s*\g<status>\s*\]\s\[\s*\g<blueprint>\s*\]\s\[\s*\g<context>\s*\]\s\[\s*\g<level>\s*\]\s\g<name>\s\(\g<version>\)
|
194
|
+
}x
|
195
|
+
|
196
|
+
data = capture(:list)
|
197
|
+
matcher_to_hash(bundle_line_matcher, data)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Get the headers for a bundle
|
201
|
+
#
|
202
|
+
# bundleId - A number containing the bundle id
|
203
|
+
#
|
204
|
+
# Examples
|
205
|
+
# headers 10
|
206
|
+
# # => "..."
|
207
|
+
#
|
208
|
+
# Returns the string containing the headers information for the bundle.
|
209
|
+
def headers (bundle)
|
210
|
+
data = capture(:headers, bundle)
|
211
|
+
extract_bundle_headers(data)
|
212
|
+
end
|
213
|
+
|
214
|
+
# List all bundles provided by a feature
|
215
|
+
#
|
216
|
+
# name - A string containing the name of the feature
|
217
|
+
#
|
218
|
+
# Examples
|
219
|
+
# feature_bundles "camel-core"
|
220
|
+
# # => [{:groupId => "org.apache.camel", :artifactId => "camel-core", :version => "2.18"}]
|
221
|
+
#
|
222
|
+
# Returns a list containing the hashes with the bundle information
|
223
|
+
def feature_bundles (name)
|
224
|
+
data = capture(:features_info, name)
|
225
|
+
extract_bundles_from_feature(data)
|
226
|
+
end
|
227
|
+
|
228
|
+
private
|
229
|
+
|
230
|
+
def matcher_to_hash (matcher,data)
|
231
|
+
breaklist = []
|
232
|
+
data.lines.each do |line|
|
233
|
+
m = matcher.match(line)
|
234
|
+
breaklist.push(m) unless m.nil?
|
235
|
+
end
|
236
|
+
breaklist.collect {|m| Hash[m.names.zip(m.captures)]}
|
237
|
+
end
|
238
|
+
|
239
|
+
def extract_bundles_from_feature (data)
|
240
|
+
bundles = []
|
241
|
+
data.lines.each do |l|
|
242
|
+
m = l.match(/.*mvn:(?<GroupId>[\w\.]+)\/(?<ArtifactId>[-\w\.]+)\/(?<Version>[-\d\w\.]+)/)
|
243
|
+
if m then
|
244
|
+
bundles.push({:groupId => m['GroupId'],
|
245
|
+
:artifactId => m['ArtifactId'],
|
246
|
+
:version => m['Version']})
|
247
|
+
end
|
248
|
+
end
|
249
|
+
bundles
|
250
|
+
end
|
251
|
+
|
252
|
+
def extract_bundle_headers (headers)
|
253
|
+
re = /(.+) = (.+)/
|
254
|
+
header = {}
|
255
|
+
headers.lines.map {|l| m = l.match(re); if m then header[m[1].strip!] = m[2] end}
|
256
|
+
header
|
257
|
+
end
|
258
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# Functions that build on capistrano-karaf/core to provide extra functionality
|
2
|
+
require 'capistrano-karaf/core'
|
3
|
+
|
4
|
+
module Capistrano_Karaf
|
5
|
+
|
6
|
+
# Remove all feature repositories with a given groupID and artifactID
|
7
|
+
#
|
8
|
+
# groupID - a string containing the groupID
|
9
|
+
# artifactID - a string containing the artifactID
|
10
|
+
#
|
11
|
+
# Examples
|
12
|
+
# remove_artifact_urls("repository", "blaat")
|
13
|
+
# # => nil
|
14
|
+
#
|
15
|
+
# Returns nothing
|
16
|
+
def remove_artifact_urls (groupID, artifactID)
|
17
|
+
urlsToRemove=list_urls.select {|url| url['groupID'] == groupID && url['artifactID'] == artifactID}
|
18
|
+
urlsToRemove.each do |url|
|
19
|
+
remove_url "mvn:#{url["groupID"]}/#{url["artifactID"]}/#{url["version"]}/xml/features"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Remove a feature in a safe way
|
24
|
+
#
|
25
|
+
# This function verifies if the feature is installed before uninstalling it. This
|
26
|
+
# way it tries to avoid an exception on the karaf server.
|
27
|
+
#
|
28
|
+
# name - a string containing the feature name
|
29
|
+
#
|
30
|
+
# Examples
|
31
|
+
# feature_uninstall_safe "test"
|
32
|
+
# # => nil
|
33
|
+
#
|
34
|
+
# Returns nothing
|
35
|
+
def feature_uninstall_safe (name)
|
36
|
+
feature_uninstall name unless !feature_installed? name
|
37
|
+
end
|
38
|
+
|
39
|
+
# Verify if a bundle is a fragment bundle
|
40
|
+
#
|
41
|
+
# bundleId - a number containing the bundleId
|
42
|
+
#
|
43
|
+
# Examples
|
44
|
+
# fragment_bundle? 101
|
45
|
+
# # => false
|
46
|
+
#
|
47
|
+
# Returns a boolean
|
48
|
+
def fragment_bundle? (bundleId)
|
49
|
+
headers(bundleId).lines.any? {|l| l.match('^Fragment-Host.*')}
|
50
|
+
end
|
51
|
+
|
52
|
+
# Wait till all bundle return true for the specified predicate ( or the timeout is exceeded )
|
53
|
+
#
|
54
|
+
# pred - a block that can be used as predicate
|
55
|
+
#
|
56
|
+
# Optional parameters:
|
57
|
+
# :timeout - a number containing the timeout in seconds ( defaults to 60 )
|
58
|
+
# :sleeptime - a number containing the timeout between tries in seconds ( defaults to 5 )
|
59
|
+
#
|
60
|
+
# Examples
|
61
|
+
# wait_for_all_bundles {|b| b[:context] == "STARTED"}
|
62
|
+
# # => nil
|
63
|
+
#
|
64
|
+
# Returns nothing
|
65
|
+
def wait_for_all_bundles (args={}, &pred)
|
66
|
+
args = {:timeout => 60, :sleeptime => 5}.merge(args)
|
67
|
+
timeout = Time.now + args[:timeout]
|
68
|
+
|
69
|
+
until Time.now > timeout or list_bundles.all? { |b| pred.call b}
|
70
|
+
puts "Some bundles are still failing the predicate"
|
71
|
+
sleep args[:sleeptime]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
# Wait till the predicate passes for a bundle
|
76
|
+
#
|
77
|
+
# pred - a block that can be used as predicate
|
78
|
+
#
|
79
|
+
# Optional parameters:
|
80
|
+
# :timeout - a number containing the timeout in seconds ( defaults to 60 )
|
81
|
+
# :sleeptime - a number containing the timeout between tries in seconds ( defaults to 5 )
|
82
|
+
#
|
83
|
+
# Examples
|
84
|
+
# wait_for_all_bundle {|b| b[:context] == "STARTED"}
|
85
|
+
# # => nil
|
86
|
+
#
|
87
|
+
# Returns nothing
|
88
|
+
def wait_for_bundle (args={}, &pred)
|
89
|
+
args = {:timeout => 60, :sleeptime => 5}.merge(args)
|
90
|
+
timeout = Time.now + args[:timeout]
|
91
|
+
|
92
|
+
while Time.now < timeout and list_bundles.none? { |b| pred.call b}
|
93
|
+
puts "Bundle not yet started"
|
94
|
+
sleep args[:sleeptime]
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
# Verify if a feature is installed
|
99
|
+
#
|
100
|
+
# name - a string containing the name of the feature
|
101
|
+
#
|
102
|
+
# Examples
|
103
|
+
# feature_installed? "camel-core"
|
104
|
+
# # => true
|
105
|
+
#
|
106
|
+
# Returns true if the feature is installed
|
107
|
+
def feature_installed? (name)
|
108
|
+
feature = list_features.find {|f| f['name']==name}
|
109
|
+
feature['status'] == 'installed' unless feature.nil?
|
110
|
+
end
|
111
|
+
|
112
|
+
# Verify if a the bundle context is started
|
113
|
+
#
|
114
|
+
# name - a string containing the name of the bundle
|
115
|
+
#
|
116
|
+
# Examples
|
117
|
+
# started? "camel-core"
|
118
|
+
# # => true
|
119
|
+
#
|
120
|
+
# Returns true if the bundle is started
|
121
|
+
def started? (name)
|
122
|
+
bundle = list_bundles.find {|b| b[:name] == name}
|
123
|
+
bundle[0][:context] == 'Started'
|
124
|
+
end
|
125
|
+
end
|
data/lib/capistrano-karaf.rb
CHANGED
@@ -1,202 +1,17 @@
|
|
1
|
-
require '
|
1
|
+
require 'capistrano-karaf/core'
|
2
|
+
require 'capistrano-karaf/extended'
|
2
3
|
|
3
|
-
|
4
|
-
SSHKit.config.command_map[:features_listurl] = 'features:listurl'
|
5
|
-
SSHKit.config.command_map[:features_removeurl] = 'features:removeurl'
|
6
|
-
SSHKit.config.command_map[:features_refreshurl] = 'features:refreshurl'
|
7
|
-
SSHKit.config.command_map[:features_install] = 'features:install'
|
8
|
-
SSHKit.config.command_map[:features_uninstall] = 'features:uninstall'
|
9
|
-
SSHKit.config.command_map[:features_list] = 'features:list'
|
10
|
-
SSHKit.config.command_map[:features_info] = 'features:info'
|
11
|
-
SSHKit.config.command_map[:headers] = 'headers'
|
12
|
-
SSHKit.config.command_map[:list] = 'osgi:list'
|
13
|
-
SSHKit.config.command_map[:log_set] = 'log:set'
|
14
|
-
SSHKit.config.command_map[:stop] = 'osgi:stop'
|
15
|
-
SSHKit.config.command_map[:start] = 'osgi:start'
|
16
|
-
SSHKit.config.command_map[:uninstall] = 'osgi:uninstall'
|
4
|
+
include Capistrano_Karaf
|
17
5
|
|
18
|
-
def add_url (url)
|
19
|
-
execute(:features_addurl, url)
|
20
|
-
end
|
21
6
|
|
22
7
|
|
23
|
-
def remove_artifact_urls (groupID, artifactID)
|
24
|
-
urlsToRemove=list_urls.select {|url| url['groupID']==groupID&&url['artifactID']==artifactID}
|
25
|
-
urlsToRemove.each do |url|
|
26
|
-
remove_url ("mvn:#{url["groupID"]}/#{url["artifactID"]}/#{url["version"]}/xml/features")
|
27
|
-
end
|
28
|
-
end
|
29
8
|
|
30
|
-
def remove_url (url)
|
31
|
-
execute(:features_removeurl, url)
|
32
|
-
end
|
33
9
|
|
34
|
-
def features_refreshurl
|
35
|
-
execute(:features_refreshurl)
|
36
|
-
end
|
37
10
|
|
38
|
-
def feature_install (name)
|
39
|
-
execute(:features_install, name)
|
40
|
-
end
|
41
11
|
|
42
|
-
def feature_uninstall_safe (name)
|
43
|
-
if (feature_installed? (name))
|
44
|
-
execute(:features_uninstall, name)
|
45
|
-
else
|
46
|
-
puts "features:#{name} is not installed so does not need to uninstall it"
|
47
|
-
end
|
48
|
-
end
|
49
12
|
|
50
|
-
def feature_uninstall (name)
|
51
|
-
execute(:features_uninstall, name)
|
52
|
-
end
|
53
13
|
|
54
|
-
def log_set (level)
|
55
|
-
execute(:log_set, level)
|
56
|
-
end
|
57
14
|
|
58
|
-
def start (bundleId)
|
59
|
-
execute(:start, bundleId)
|
60
|
-
end
|
61
15
|
|
62
|
-
def stop (bundleId)
|
63
|
-
execute(:stop, bundleId)
|
64
|
-
end
|
65
16
|
|
66
|
-
def uninstall (bundleId)
|
67
|
-
execute(:uninstall, bundleId)
|
68
|
-
end
|
69
17
|
|
70
|
-
def fragment_bundle? (bundleId)
|
71
|
-
headers = capture(:headers)
|
72
|
-
headers.lines.any? {|l| l.match('^Fragment-Host.*')}
|
73
|
-
end
|
74
|
-
|
75
|
-
def break_listing (matcher,data)
|
76
|
-
breaklist = []
|
77
|
-
data.lines.each do |line|
|
78
|
-
m = matcher.match(line)
|
79
|
-
if m then
|
80
|
-
breaklist.push(m)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
breaklist.collect {|m| Hash[m.names.zip(m.captures)]}
|
84
|
-
end
|
85
|
-
|
86
|
-
def list_urls ()
|
87
|
-
url_line_matcher = %r{
|
88
|
-
(?<status> \w+){0}
|
89
|
-
(?<groupID> [\d\w\.\-]+){0}
|
90
|
-
(?<artifactID> [\w\.\-]+){0}
|
91
|
-
(?<version> [\w\.\-]+){0}
|
92
|
-
\s*\g<status>\s*mvn\:\g<groupID>\/\g<artifactID>\/\g<version>.*
|
93
|
-
}x
|
94
|
-
data=capture(:features_listurl)
|
95
|
-
break_listing url_line_matcher,data
|
96
|
-
end
|
97
|
-
|
98
|
-
def list_features ()
|
99
|
-
feature_line_matcher = %r{
|
100
|
-
(?<status> \w+){0}
|
101
|
-
(?<version> [\d\w\-\.\s]+){0}
|
102
|
-
(?<name> [\w\-\:]+){0}
|
103
|
-
(?<repository> [\w\-\s\:\.]+){0}
|
104
|
-
^\[\s*\g<status>\s*\]\s\[\s*\g<version>\s*\]\s*\g<name>\s*\g<repository>}x
|
105
|
-
data=capture(:features_list)
|
106
|
-
break_listing feature_line_matcher,data
|
107
|
-
end
|
108
|
-
|
109
|
-
def list_bundles ()
|
110
|
-
bundle_line_matcher = %r{(?<id> \d+){0}
|
111
|
-
(?<status> \w+){0}
|
112
|
-
(?<blueprint> \w*){0}
|
113
|
-
(?<context> \w*){0}
|
114
|
-
(?<level> \d+){0}
|
115
|
-
(?<name> [\w\s\-\:]+){0}
|
116
|
-
(?<version> .+){0}
|
117
|
-
|
118
|
-
^\[\s*\g<id>\]\s\[\s*\g<status>\s*\]\s\[\s*\g<blueprint>\s*\]\s\[\s*\g<context>\s*\]\s\[\s*\g<level>\s*\]\s\g<name>\s\(\g<version>\)
|
119
|
-
}x
|
120
|
-
|
121
|
-
data = capture(:list)
|
122
|
-
|
123
|
-
break_listing bundle_line_matcher,data
|
124
|
-
end
|
125
|
-
|
126
|
-
def wait_for_all_bundles (args={}, &pred)
|
127
|
-
args = {:timeout => 60, :sleeptime => 1}.merge(args)
|
128
|
-
timeout = Time.now + args[:timeout]
|
129
|
-
|
130
|
-
until Time.now > timeout or list_bundles.all? { |b| pred.call b}
|
131
|
-
puts "Some bundles are still failing the predicate"
|
132
|
-
sleep args[:sleeptime]
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
def feature_installed? (name)
|
137
|
-
feature=list_features.find {|f| f['name']==name}
|
138
|
-
feature['status']=='installed' unless feature.nil?
|
139
|
-
end
|
140
|
-
|
141
|
-
def wait_for_bundle (args={}, &pred)
|
142
|
-
args = {:timeout => 60, :sleeptime => 1}.merge(args)
|
143
|
-
timeout = Time.now + args[:timeout]
|
144
|
-
|
145
|
-
while Time.now < timeout and list_bundles.none? { |b| pred.call b}
|
146
|
-
puts "Bundle not yet started"
|
147
|
-
sleep args[:sleeptime]
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
|
152
|
-
def started? (name)
|
153
|
-
bundle = list_bundles.find {|b| b[:name] == name}
|
154
|
-
bundle[0][:context] == 'Started'
|
155
|
-
end
|
156
|
-
|
157
|
-
def list ()
|
158
|
-
capture(:features_list)
|
159
|
-
end
|
160
|
-
|
161
|
-
def headers (bundle)
|
162
|
-
data = capture(:headers, bundle)
|
163
|
-
extract_bundle_headers(data)
|
164
|
-
end
|
165
|
-
|
166
|
-
def feature_bundles (name)
|
167
|
-
data = capture(:features_info, name)
|
168
|
-
extract_bundles_from_feature(data)
|
169
|
-
end
|
170
|
-
|
171
|
-
def feature_bundles_numbers (name)
|
172
|
-
bundles = list_bundles
|
173
|
-
bundleIds = bundles.map {|bundle| bundle[:id]}
|
174
|
-
bundleHeaders = bundleIds.map {|bundleId| headers(bundleId).store(:bundleId, bundleId)}
|
175
|
-
featureBundles = feature_bundles(name)
|
176
|
-
bundlesInFeature = bundles.select {|b| find_feature_bundle(featureBundles, b[:artifactId], b[:version] != nil)}
|
177
|
-
bundlesInFeature.map {|b| b[:id]}
|
178
|
-
end
|
179
|
-
|
180
|
-
def find_feature_bundle (featureBundles, name, version)
|
181
|
-
featureBundles.select {|fb| fb["Bundle-SymbolicName"] == name && fb["Bundle-Version"] == version }
|
182
|
-
end
|
183
|
-
|
184
|
-
def extract_bundle_headers (headers)
|
185
|
-
re = /(.+) = (.+)/
|
186
|
-
header = {}
|
187
|
-
headers.lines.map {|l| m = l.match(re); if m then header[m[1].strip!] = m[2] end}
|
188
|
-
header
|
189
|
-
end
|
190
|
-
|
191
|
-
def extract_bundles_from_feature (data)
|
192
|
-
bundles = []
|
193
|
-
data.lines.each do |l|
|
194
|
-
m = l.match(/.*mvn:(?<GroupId>[\w\.]+)\/(?<ArtifactId>[-\w\.]+)\/(?<Version>[-\d\w\.]+)/)
|
195
|
-
if m then
|
196
|
-
bundles.push({:groupId => m['GroupId'],
|
197
|
-
:artifactId => m['ArtifactId'],
|
198
|
-
:version => m['Version']})
|
199
|
-
end
|
200
|
-
end
|
201
|
-
bundles
|
202
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-karaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -18,6 +18,8 @@ extensions: []
|
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
20
|
- lib/capistrano-karaf.rb
|
21
|
+
- lib/capistrano-karaf/core.rb
|
22
|
+
- lib/capistrano-karaf/extended.rb
|
21
23
|
homepage: http://github.com/bhoflack/capistrano-karaf
|
22
24
|
licenses:
|
23
25
|
- bsd
|