コード例 #1
0
def main(argv):
    parser = argparse.ArgumentParser()
    parser.add_argument("application", default="ceph-mon", nargs="*")
    parser.add_argument("units", default=[0, 1], nargs="*")
    options = parser.parse_args()
    application = mojo_utils.parse_mojo_arg(options,
                                            'application',
                                            multiargs=False)
    units = mojo_utils.parse_mojo_arg(options, 'units', multiargs=True)

    mojo_utils.remote_run('{}/{}'.format(application, units[-1]),
                          'ceph osd pool create rbd 128')
    # Check
    mojo_utils.remote_run('{}/{}'.format(application, units[0]),
                          'echo 123456789 > /tmp/input.txt')
    mojo_utils.remote_run('{}/{}'.format(application, units[0]),
                          'rados put -p rbd test_input /tmp/input.txt')

    # Check
    output = mojo_utils.remote_run('{}/{}'.format(application, units[-1]),
                                   'rados get -p rbd test_input /dev/stdout')

    # Cleanup
    mojo_utils.remote_run('{}/{}'.format(application, units[-1]),
                          'rados rm -p rbd test_input')
    if output[0].strip() != "123456789":
        sys.exit(1)
コード例 #2
0
def rabbit_unit_status(unit):
    cmd = 'rabbitmqctl -q cluster_status'
    output = mojo_utils.remote_run(unit, remote_cmd=cmd)[0]
    output = output.replace('\n', '')
    matchObj = re.search(r'running_nodes,(.*)}, {partitions', output)
    machine_numbers = []
    for machine in ast.literal_eval(matchObj.group(1)):
        machine_numbers.append(int(machine.split('-')[-1]))
    return machine_numbers
コード例 #3
0
def main(argv):
    cert_script = mojo_utils.get_mojo_file('checksum_keystone_certs.py')
    remote_script = '/home/ubuntu/checksum_keystone_certs.py'
    hashes = set()
    for unit in mojo_utils.get_juju_units(service='keystone'):
        mojo_utils.remote_upload(unit, cert_script, remote_script)
        hashes.add(mojo_utils.remote_run(unit, remote_script)[0].strip())
    if len(hashes) != 1:
        raise Exception('Keystone cert mismatch')
コード例 #4
0
def unit_crm_online(unit):
    output = mojo_utils.remote_run(unit, remote_cmd='crm_mon -X')
    xml_out = output[0]
    tree = xml.dom.minidom.parseString(xml_out)
    itemlist = tree.getElementsByTagName('node')
    online_units = []
    for s in itemlist:
        if 'online' in s.attributes.keys() \
                and s.attributes['online'].value == 'true':
            online_units.append(int(s.attributes['name'].value.split('-')[-1]))
    online_units.sort()
    return online_units
コード例 #5
0
def check_crm_status(service):
    juju_units = mojo_utils.get_juju_units(service=service)
    if not juju_units:
        return
    cmd = 'which crm_mon || echo "Not Found"'
    output = mojo_utils.remote_run(juju_units[0], remote_cmd=cmd)
    if output[0].rstrip() == "Not Found":
        return
    for unit in juju_units:
        mach_nums = get_machine_numbers(service)
        crm_online = unit_crm_online(unit)
        if mach_nums == crm_online:
            logging.info('Service %s status on %s look good' % (service, unit))
        else:
            logging.info('%s != %s' % (str(mach_nums), str(crm_online)))
            msg = ('Mismatch on crm status for service {} '
                   'on unit {}'.format(service, unit))
            raise Exception(msg)
コード例 #6
0
def main(argv):
    addr = mojo_utils.juju_get('nova-cloud-controller', 'vip')
    # The second vip is the os-internal-network one
    addr = addr.split(' ')[1]
    for unit in mojo_utils.get_juju_units(service='nova-cloud-controller'):
        for conf, entry, url in [[
                '/etc/nova/nova.conf', 'neutron_url',
                "http://%s:9696" % (addr)
        ],
                                 [
                                     '/etc/neutron/neutron.conf', 'nova_url',
                                     "http://%s:8774/v2" % (addr)
                                 ]]:
            out = mojo_utils.remote_run(unit, 'grep %s %s' % (entry, conf))
            if url not in out[0]:
                raise Exception("Did not get expected %s in %s (got='%s', "
                                "wanted='%s')" % (entry, conf, out, url))

            logging.info("%s checked and good." % (conf))
コード例 #7
0
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('--peer-application', '-a',
                        help='BGP Peer application name. Default: quagga',
                        default='quagga')
    options = parser.parse_args()

    peer_application_name = mojo_utils.parse_mojo_arg(options,
                                                      'peer_application')
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    # Run show ip route on BGP peer
    peer_unit = mojo_utils.get_juju_units(service=peer_application_name)[0]
    logging.info("Checking routes on BGP peer {}".format(peer_unit))
    routes = mojo_utils.remote_run(peer_unit,
                                   remote_cmd="vtysh -c 'show ip route'")[0]
    logging.debug(routes)

    # Check for expected advertised routes
    private_cidr = neutronc.list_subnets(
        name='private_subnet')['subnets'][0]['cidr']
    floating_ip_cidr = "{}/32".format(
        neutronc.list_floatingips()['floatingips'][0]['floating_ip_address'])
    assert private_cidr in routes, ("Private subnet CIDR, {}, not advertised "
                                    "to BGP peer".format(private_cidr))
    logging.info("Private subnet CIDR, {}, found in routing table"
                 .format(private_cidr))
    assert floating_ip_cidr in routes, ("Floating IP, {}, not advertised "
                                        "to BGP peer".format(floating_ip_cidr))
    logging.info("Floating IP CIDR, {}, found in routing table"
                 .format(floating_ip_cidr))
コード例 #8
0
def main(argv):
    for unit in mojo_utils.get_juju_units(service='neutron-gateway'):
        cmd = 'sudo service neutron-plugin-openvswitch-agent restart'
        mojo_utils.remote_run(unit, remote_cmd=cmd)
コード例 #9
0
            continue
        hashsum, filename = line.split()
        ring_data[filename] = hashsum
    return ring_data


def verify_ring_data(ring_data):
    ring_dict = ring_data.itervalues().next()
    for unit in ring_data.iterkeys():
        if ring_data[unit] != ring_dict:
            return False
    return True


juju_status = mojo_utils.get_juju_status(service='swift-proxy')
sp_units = mojo_utils.get_juju_units(juju_status=juju_status)
ring_data = {}

for unit in sp_units:
    cmd = 'ls -1 /etc/swift/*{.builder,.ring.gz,arse} 2>/dev/null ' \
          '| xargs -l md5sum'
    out, err = mojo_utils.remote_run(unit, remote_cmd=cmd)
    ring_data[unit] = process_ring_info(out)

if verify_ring_data(ring_data):
    logging.info('Ring data consistent accross proxies')
    sys.exit(0)
else:
    logging.error('Ring data inconsistent accross proxies')
    sys.exit(1)