Ejemplo n.º 1
0
def ostack_inspect_task(request):
    logger.info('Starting OpenStack inspection')

    discovery = OpenstackDiscovery()

    try:
        openstack = discovery.discover(request.nodes,
                                       private_key=request.private_key)
    except Exception:
        message = traceback.format_exc()
        logger.error(message)
        return InspectionResult(request, message)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        try:
            x = inspection()
            x.inspect(openstack)
        except Exception:
            message = traceback.format_exc()
            logger.error(message)
            openstack.report_issue(
                Issue(
                    Issue.ERROR,
                    'Unexpected error running inspection "%s". See log for '
                    'details' %
                    inspection.name))

    logger.info('Finished OpenStack inspection')

    return InspectionResult(request, openstack)
Ejemplo n.º 2
0
def main(argv):
    args = parse_args(argv)
    params = vars(args)

    logging.basicConfig(level=logging.WARNING)
    logging.getLogger('rubick').setLevel(params['loglevel'])

    discovery = OpenstackDiscovery()
    try:
        with open('test_rsa') as f:
            private_key = f.read()
    except Exception:
        private_key = sys.stdin.read()

    openstack = discovery.discover(
        ['172.18.65.179'],
        private_key=private_key)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        x = inspection()
        x.inspect(openstack)

    if params['json']:
        print(json.dumps(openstack_for_json(openstack)))
    else:
        print_openstack(openstack)
Ejemplo n.º 3
0
def ostack_discover_task(cluster_id):
    db = get_db()
    cluster_doc = db['clusters'].find_one({'_id': ObjectId(cluster_id)})
    if not cluster_doc:
        logger.error('Cluster with ID=%s was not found' % cluster_id)
        return

    cluster = Cluster.from_doc(cluster_doc)

    logger.info('Starting OpenStack discovery for cluster "%s" (id=%s)' %
                (cluster.name, cluster.id))

    discovery = OpenstackDiscovery()

    openstack = None
    try:
        openstack = discovery.discover(cluster.nodes,
                                       cluster.private_key)
    except Exception:
        message = traceback.format_exc()
        logger.error(message)

    logger.info('Finished OpenStack discovery for cluster "%s" (id=%s)' %
                (cluster.name, cluster.id))

    cluster.data = openstack_for_json(openstack)

    db['clusters'].save(cluster.as_doc())
Ejemplo n.º 4
0
def ostack_inspect_task(request):
    logger.info('Starting OpenStack inspection')

    discovery = OpenstackDiscovery()

    try:
        openstack = discovery.discover(request.nodes,
                                       private_key=request.private_key)
    except:
        message = traceback.format_exc()
        logger.error(message)
        return InspectionResult(request, message)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        try:
            x = inspection()
            x.inspect(openstack)
        except:
            message = traceback.format_exc()
            logger.error(message)
            openstack.report_issue(
                Issue(
                    Issue.ERROR,
                    'Unexpected error running inspection "%s". See log for '
                    'details' % inspection.name))

    logger.info('Finished OpenStack inspection')

    return InspectionResult(request, openstack)
Ejemplo n.º 5
0
def ostack_discover_task(cluster_id):
    db = get_db()
    cluster_doc = db['clusters'].find_one({'_id': ObjectId(cluster_id)})
    if not cluster_doc:
        logger.error('Cluster with ID=%s was not found' % cluster_id)
        return

    cluster = Cluster.from_doc(cluster_doc)

    logger.info('Starting OpenStack discovery for cluster "%s" (id=%s)' %
                (cluster.name, cluster.id))

    discovery = OpenstackDiscovery()

    openstack = None
    try:
        openstack = discovery.discover(cluster.nodes, cluster.private_key)
    except:
        message = traceback.format_exc()
        logger.error(message)

    logger.info('Finished OpenStack discovery for cluster "%s" (id=%s)' %
                (cluster.name, cluster.id))

    cluster.data = openstack_for_json(openstack)

    db['clusters'].save(cluster.as_doc())
Ejemplo n.º 6
0
def main():
    logging.basicConfig(level=logging.WARNING)
    logging.getLogger("rubick").setLevel(logging.DEBUG)

    discovery = OpenstackDiscovery()
    try:
        with open("test_rsa") as f:
            private_key = f.read()
    except:
        private_key = sys.stdin.read()

    openstack = discovery.discover(["172.18.65.179"], private_key=private_key)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        x = inspection()
        x.inspect(openstack)

    # print_openstack(openstack)
    print(json.dumps(openstack_for_json(openstack)))
Ejemplo n.º 7
0
def main():
    logging.basicConfig(level=logging.WARNING)
    logging.getLogger('rubick').setLevel(logging.DEBUG)

    discovery = OpenstackDiscovery()
    try:
        with open('test_rsa') as f:
            private_key = f.read()
    except Exception:
        private_key = sys.stdin.read()

    openstack = discovery.discover(
        ['172.18.65.179'],
        private_key=private_key)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        x = inspection()
        x.inspect(openstack)

    print_openstack(openstack)
Ejemplo n.º 8
0
def main():
    logging.basicConfig(level=logging.WARNING)
    logging.getLogger('rubick').setLevel(logging.DEBUG)

    discovery = OpenstackDiscovery()
    try:
        with open('test_rsa') as f:
            private_key = f.read()
    except:
        private_key = sys.stdin.read() 

    openstack = discovery.discover(
        ['172.18.65.179'],
        private_key=private_key)

    all_inspections = Inspection.all_inspections()
    for inspection in all_inspections:
        x = inspection()
        x.inspect(openstack)

    # print_openstack(openstack)
    print(json.dumps(openstack_for_json(openstack)))