示例#1
0
    def restore(self):
        domain = helpers.get_astute_dict()["DNS_DOMAIN"]
        dirname = "/var/log/remote/"

        pairs = []

        with fuel_client.set_auth_context(self.context):
            for node in objects.Node.get_all():
                fqdn = node.data["meta"]["system"]["fqdn"]
                # log creation not required for nodes in bootstrap
                if fqdn.startswith('bootstrap'):
                    continue
                pairs.append((fqdn, node.data["ip"]))

        subprocess.call(["systemctl", "stop", "rsyslog"])
        try:
            for fqdn, ip_addr in pairs:
                if not fqdn.endswith(domain):
                    continue
                ip_addr_path = os.path.join(dirname, ip_addr)
                fqdn_path = os.path.join(dirname, fqdn)
                if os.path.islink(ip_addr_path):
                    continue
                if os.path.isdir(ip_addr_path):
                    os.rename(ip_addr_path, fqdn_path)
                else:
                    os.mkdir(fqdn_path)
                os.symlink(fqdn, ip_addr_path)
        finally:
            subprocess.call(["systemctl", "start", "rsyslog"])
示例#2
0
def test_simple_overwrite(mocker):

    class TestContext(object):

        user = "******"
        password = "******"

    conf = fuelclient_settings.get_settings()

    client_val = "Not empty val"

    assert conf.KEYSTONE_USER == client.APIClient.user
    assert conf.KEYSTONE_PASS == client.APIClient.password
    assert client.APIClient._session is None
    assert client.APIClient._keystone_client is None

    client.APIClient._session = client.APIClient._keystone_client = client_val

    with fuel_client.set_auth_context(TestContext()):
        assert TestContext.user == client.APIClient.user
        assert TestContext.password == client.APIClient.password
        assert client.APIClient._session is None
        assert client.APIClient._keystone_client is None

        client.APIClient._session = client_val
        client.APIClient._keystone_client = client_val

    assert conf.KEYSTONE_USER == client.APIClient.user
    assert conf.KEYSTONE_PASS == client.APIClient.password
    assert client.APIClient._session is None
    assert client.APIClient._keystone_client is None
示例#3
0
def upgrade_osd(orig_env_id, seed_env_id, user, password):
    with fuel_client.set_auth_context(
            backup_restore.NailgunCredentialsContext(user, password)):
        orig_env = env_obj.Environment(orig_env_id)
        nodes = list(env.get_nodes(orig_env, ["ceph-osd"]))
        seed_env = env_obj.Environment(seed_env_id)
        preference_priority = get_repo_highest_priority(orig_env)
        seed_repos = get_repos_for_upgrade(orig_env, seed_env)
    if not nodes:
        LOG.info("Nothing to upgrade")
        return
    controller = env.get_one_controller(seed_env)
    if is_same_versions_on_mon_and_osd(controller):
        LOG.warn("MONs and OSDs have the same version, nothing to upgrade.")
        return
    hostnames = [n.data['hostname'] for n in nodes]
    with applied_repos(nodes, preference_priority + 1, seed_repos):
        call_node = nodes[0]
        ssh.call(["ceph", "osd", "set", "noout"], node=call_node)
        ssh.call(['ceph-deploy', 'install', '--release', 'hammer'] + hostnames,
                 node=call_node)
    for node in nodes:
        ssh.call(["restart", "ceph-osd-all"], node=node)
    ssh.call(["ceph", "osd", "unset", "noout"], node=call_node)
    waiting_until_ceph_up(controller)
    if not is_same_versions_on_mon_and_osd(controller):
        msg = "OSDs not upgraded up to MONs version, please fix the problem"
        LOG.error(msg)
        raise Exception(msg)
示例#4
0
def is_creds_valid(user, password):
    with fuel_client.set_auth_context(Context(user, password)):
        resp = client.APIClient.get_request_raw('/clusters')
        if resp.status_code != 401:
            resp.raise_for_status()
            return True
        return False
示例#5
0
def enable_release(release_id, context):
    release_url = "/releases/{0}".format(release_id)
    with fuel_client.set_auth_context(context):
        data = client.APIClient.get_request(release_url)
        state = data.get('state')
        if state == magic_consts.RELEASE_STATUS_MANAGED:
            data['state'] = magic_consts.RELEASE_STATUS_ENABLED
            client.APIClient.put_request(release_url, data)
        else:
            exc_msg = ("Cannot enable release {0}: has status {1}, not {2}"
                       .format(release_id,
                               state,
                               magic_consts.RELEASE_STATUS_MANAGED))
            raise Exception(exc_msg)
示例#6
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))
示例#7
0
 def _create_links_on_remote_logs(self):
     domain = helpers.get_astute_dict()["DNS_DOMAIN"]
     dirname = "/var/log/docker-logs/remote/"
     with fuel_client.set_auth_context(self.context):
         pairs = [(n.data["meta"]["system"]["fqdn"], n.data["ip"])
                  for n in node.Node.get_all()]
     docker.run_in_container("rsyslog", ["service", "rsyslog", "stop"])
     try:
         for fqdn, ip_addr in pairs:
             if not fqdn.endswith(domain):
                 continue
             ip_addr_path = os.path.join(dirname, ip_addr)
             fqdn_path = os.path.join(dirname, fqdn)
             if os.path.islink(ip_addr_path):
                 continue
             if os.path.isdir(ip_addr_path):
                 os.rename(ip_addr_path, fqdn_path)
             else:
                 os.mkdir(fqdn_path)
             os.symlink(fqdn, ip_addr_path)
     finally:
         docker.run_in_container("rsyslog", ["service", "rsyslog", "start"])