Exemple #1
0
 def backup(self):
     status = mcollective.get_mco_ping_status()
     content = json.dumps(status)
     info = tarfile.TarInfo(self.filename)
     info.size = len(content)
     fileobj = io.BytesIO(content)
     self.archive.addfile(info, fileobj=fileobj)
Exemple #2
0
 def restore(self):
     with fuel_client.set_auth_context(self.context):
         nodes = objects.Node.get_all()
         for node in nodes:
             node_util.restart_mcollective(node)
     content = self.archive.extractfile(self.filename)
     if content is not None:
         orig_status = json.load(content)
         new_status = mcollective.get_mco_ping_status()
         offline = mcollective.compair_mco_ping_statuses(orig_status,
                                                         new_status)
         if offline:
             LOG.warning("Some nodes went offline after the upgrade of the "
                         "master node (check them manually): %s",
                         ", ".join(offline))
def test_get_mco_ping_status(mocker, status):
    stdout = io.BytesIO(json.dumps(status))
    mock_popen = mocker.patch("octane.util.subprocess.popen")
    mock_popen.return_value.__enter__.return_value.stdout = stdout
    result = mcollective.get_mco_ping_status()
    assert result == status