MCPcopy Create free account
hub / github.com/ceph/ceph / _load_module

Method _load_module

qa/tasks/mgr/mgr_test_case.py:163–197  ·  view source on GitHub ↗
(cls, module_name)

Source from the content-addressed store, hash-verified

161
162 @classmethod
163 def _load_module(cls, module_name):
164 loaded = json.loads(cls.mgr_cluster.mon_manager.raw_cluster_cmd(
165 "mgr", "module", "ls", "--format=json-pretty"))['enabled_modules']
166 if module_name in loaded:
167 # The enable command is idempotent, but our wait for a restart
168 # isn't, so let's return now if it's already loaded
169 return
170
171 initial_mgr_map = cls.mgr_cluster.get_mgr_map()
172
173 # check if the the module is configured as an always on module
174 mgr_daemons = json.loads(cls.mgr_cluster.mon_manager.raw_cluster_cmd(
175 "mgr", "metadata"))
176
177 for daemon in mgr_daemons:
178 if daemon["name"] == initial_mgr_map["active_name"]:
179 ceph_version = daemon["ceph_release"]
180 always_on = initial_mgr_map["always_on_modules"].get(ceph_version, [])
181 if module_name in always_on:
182 return
183
184 log.debug("Loading Mgr module %s ...", module_name)
185 initial_gid = initial_mgr_map['active_gid']
186 cls.mgr_cluster.mon_manager.raw_cluster_cmd(
187 "mgr", "module", "enable", module_name, "--force")
188
189 # Wait for the module to load
190 def has_restarted():
191 mgr_map = cls.mgr_cluster.get_mgr_map()
192 done = mgr_map['active_gid'] != initial_gid and mgr_map['available']
193 if done:
194 log.debug("Restarted after module load (new active {0}/{1})".format(
195 mgr_map['active_name'], mgr_map['active_gid']))
196 return done
197 cls.wait_until_true(has_restarted, timeout=30)
198
199
200 @classmethod

Callers 15

setUpMethod · 0.45
setUpMethod · 0.45
setUpMethod · 0.45
setUpMethod · 0.45
setUpMethod · 0.45
_selftest_pluginMethod · 0.45
test_selftest_runMethod · 0.45
test_module_commandsMethod · 0.45
test_module_remoteMethod · 0.45

Calls 5

raw_cluster_cmdMethod · 0.80
get_mgr_mapMethod · 0.80
getMethod · 0.45
debugMethod · 0.45
wait_until_trueMethod · 0.45

Tested by

no test coverage detected