capistrano-karaf 1.6.1 → 1.6.2
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 +15 -0
- data/lib/capistrano-karaf/install.rb +33 -4
- metadata +1 -1
@@ -19,6 +19,7 @@ SSHKit.config.command_map[:log_set] = 'log:set'
|
|
19
19
|
SSHKit.config.command_map[:stop] = 'osgi:stop'
|
20
20
|
SSHKit.config.command_map[:start] = 'osgi:start'
|
21
21
|
SSHKit.config.command_map[:uninstall] = 'osgi:uninstall --force'
|
22
|
+
SSHKit.config.command_map[:startlevel] = 'osgi:start-level'
|
22
23
|
|
23
24
|
module Capistrano_Karaf
|
24
25
|
# Add a feature url to the karaf server
|
@@ -113,6 +114,20 @@ module Capistrano_Karaf
|
|
113
114
|
execute(:log_set, level)
|
114
115
|
end
|
115
116
|
|
117
|
+
# Set the start level on the karaf server
|
118
|
+
#
|
119
|
+
# level - the string containing the level
|
120
|
+
#
|
121
|
+
# Examples
|
122
|
+
# startlevel_set 60
|
123
|
+
# # => nil
|
124
|
+
#
|
125
|
+
# Returns nothing
|
126
|
+
def startlevel_set (level)
|
127
|
+
execute(:startlevel, level)
|
128
|
+
end
|
129
|
+
|
130
|
+
|
116
131
|
# Start a bundle with the specified bundleId on the karaf server
|
117
132
|
#
|
118
133
|
# bundleId - a number containing the id of the bundle
|
@@ -12,7 +12,7 @@ module Install
|
|
12
12
|
include Semantic_Versions
|
13
13
|
|
14
14
|
# Upgrade a list of projects in karaf
|
15
|
-
#
|
15
|
+
#
|
16
16
|
# projects - a list of hashes containing either:
|
17
17
|
# - :feature_url - the string containing the feature url
|
18
18
|
# - :feature - the string containing the feature name to upgrade
|
@@ -40,6 +40,12 @@ module Install
|
|
40
40
|
# :after_install_feature,
|
41
41
|
# :after_upgrade_feature
|
42
42
|
#
|
43
|
+
#
|
44
|
+
# args - a hash containing optional args:
|
45
|
+
# - :startlevel_before_upgrade - the number of the startlevel to go to before upgrading
|
46
|
+
# - :startlevel_after_upgrade - the number of the startlevel to go to after upgrading
|
47
|
+
#
|
48
|
+
#
|
43
49
|
# Examples
|
44
50
|
# upgrade([{:feature_url => "mvn:repository/featurea/xml/features/1.1.0",
|
45
51
|
# :feature => "featurea",
|
@@ -55,16 +61,27 @@ module Install
|
|
55
61
|
# :repository => "featureb",
|
56
62
|
# :feature => "featureb",
|
57
63
|
# :version => :latest
|
58
|
-
# }
|
59
64
|
# }])
|
60
65
|
# # => nil
|
61
66
|
#
|
62
67
|
# Returns nothing
|
63
|
-
def upgrade (projects)
|
68
|
+
def upgrade (projects, args={})
|
69
|
+
args = {:startlevel_before_upgrade => 60, :startlevel_after_upgrade => 100}.merge(args)
|
64
70
|
features = list_features()
|
65
71
|
|
66
72
|
to_uninstall, to_install = calculate_upgrade_actions(projects, features)
|
67
73
|
|
74
|
+
# decrease the start level
|
75
|
+
startlevel_set args[:startlevel_before_upgrade]
|
76
|
+
|
77
|
+
wait_for_all_bundles(:timeout => 180, :sleeptime => 10) do |b|
|
78
|
+
if b[:level].to_i > args[:startlevel_before_upgrade]
|
79
|
+
b[:status] == "Resolved"
|
80
|
+
else
|
81
|
+
true
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
68
85
|
# first start uninstalling features in reverse order
|
69
86
|
to_uninstall.reverse.each do |f|
|
70
87
|
trigger_event(f, :before_uninstall_feature)
|
@@ -72,7 +89,7 @@ module Install
|
|
72
89
|
trigger_event(f, :after_uninstall_feature)
|
73
90
|
end
|
74
91
|
|
75
|
-
#
|
92
|
+
# now install the new features
|
76
93
|
to_install.each do |f|
|
77
94
|
remove_otherversion_urls(f[:feature_url])
|
78
95
|
add_url(f[:feature_url])
|
@@ -81,8 +98,20 @@ module Install
|
|
81
98
|
trigger_event(f, :after_install_feature)
|
82
99
|
end
|
83
100
|
|
101
|
+
# increase the start level
|
102
|
+
startlevel_set args[:startlevel_after_upgrade]
|
103
|
+
wait_for_all_bundles(:timeout => 180, :sleeptime => 10) do |b|
|
104
|
+
if (b[:level].to_i > args[:startlevel_before_upgrade] and
|
105
|
+
b[:level].to_i <= args[:startlevel_after_upgrade])
|
106
|
+
["Active","Resolved"].include? b[:status]
|
107
|
+
else
|
108
|
+
true
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
84
112
|
list_bundles.find_all {|b| !b[:fragment] && b[:context] == "Failed"}
|
85
113
|
.each {|b| restart_bundle b[:id]}
|
114
|
+
|
86
115
|
end
|
87
116
|
|
88
117
|
# Extract the latest version from a maven-metadata file
|