(cls, module_name)
| 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 |
no test coverage detected