示例#1
0
def main():

    username = process_config('production', 'user')
    key = process_config('production', 'passwd')
    tenant_name = process_config('production', 'name')
    url = process_config('production', 'url')
    zone = process_config('config', 'zone')
    client = createNovaConnection(username, key, tenant_name, url)
    az = process_config('config', 'az')
    opt_ = get_args()

    if opt_.t is None:
        data = RunCollect(client, zone, opt=True)
        data2 = CombineResource(data)

        if opt_.o is 'n':
            printOptions(data, data_2=data2, options='all')

        elif opt_.o == 'html':
            templateLoader(data, data2)

        elif opt_.o == 'csv':
            multiCSVNode(data)
            createCSVFileCloud(data2)

        elif opt_.o == 'both':
            templateLoader(data, data2)
            multiCSVNode(data)
            createCSVFileCloud(data2)

        elif opt_.o == 'email':
            file_l = templateLoader(data, data2, opt='email')
            email_user(file_l)

    elif opt_.t in az:
        data = RunCollect(client, zone, opt=opt_.t)
        if opt_.o is 'n':
            printOptions(data)

        elif opt_.o == 'html':
            templateLoader(data, cell=opt_.t)

        elif opt_.o == 'csv':
            createCSVFileNode(data)

        elif opt_.o == 'both':
            templateLoader(data, cell=opt_.t)
            createCSVFileNode(data)

        elif opt_.o == 'email':
            file_l = templateLoader(data, cell=opt_.t, opt='email')
            email_user(file_l)

    else:
        print "Error!, cell %s not found. Current cell %s " % (opt_.t,
                                                               az)
        return sys.exit(1)
def main():
    parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)
    parser.add_argument('-a', nargs='?', dest='target_cell', action='store',
                        required=True, default=True,
                        help='{specify 1 cell name to overide,e,g -a np}')
    parser.add_argument('-o', nargs='?', dest='output', default='n',
                        choices=['html', 'csv', 'both', 'email'],
                        required=False,
                        help='output, {default: console}, {email: email html }')

    opts = parser.parse_args()

    username = processConfig('production', 'user')
    key = processConfig('production', 'passwd')
    tenant_name = processConfig('production', 'name')
    url = processConfig('production', 'url')
    zone = processConfig('config', 'zone')
    client = createNovaConnection(username, key, tenant_name, url)
    az = processConfig('config', 'az')
    if opts.target_cell is not None:
        if opts.target_cell not in az:
            parser.error("Error!, cell %s not found. Current cell %s " %
                         (opts.target_cell, az))
    else:
        opts.target_cell = True

    data = collect_all(client, zone, opt=opts.target_cell)
    if opts.target_cell is True:
        data2 = combineResource(data)
    else:
        data2 = None

    if opts.output is 'n':
        printOptions(data, data_2=data2, options='all')

    elif opts.output == 'html':
        templateLoader(data, data2)

    elif opts.output == 'csv':
        if opts.target_cell is True:
            multiCSVNode(data)
            createCSVFileCloud(data2)
        else:
            createCSVFileNode(data)

    elif opts.output == 'both':
        templateLoader(data, data2, cell=opts.target_cell)
        if opts.target_cell is True:
            multiCSVNode(data)
            createCSVFileCloud(data2)
        else:
            createCSVFileNode(data)

    elif opts.output == 'email':
        file_l = templateLoader(data, data2, cell=opts.target_cell, opt='email')
        emailUser(file_l)
示例#3
0
def main():

    username = process_config('production', 'user')
    key = process_config('production', 'passwd')
    tenant_name = process_config('production', 'name')
    url = process_config('production', 'url')
    zone = process_config('config', 'zone')
    client = createNovaConnection(username, key, tenant_name, url)
    az = process_config('config', 'az')
    opt_ = get_args()

    if opt_.t is None:
        data = RunCollect(client, zone, opt=True)
        data2 = CombineResource(data)

        if opt_.o is 'n':
            printOptions(data, data_2=data2, options='all')

        elif opt_.o == 'html':
            templateLoader(data, data2)

        elif opt_.o == 'csv':
            multiCSVNode(data)
            createCSVFileCloud(data2)

        elif opt_.o == 'both':
            templateLoader(data, data2)
            multiCSVNode(data)
            createCSVFileCloud(data2)

        elif opt_.o == 'email':
            file_l = templateLoader(data, data2, opt='email')
            email_user(file_l)

    elif opt_.t in az:
        data = RunCollect(client, zone, opt=opt_.t)
        if opt_.o is 'n':
            printOptions(data)

        elif opt_.o == 'html':
            templateLoader(data, cell=opt_.t)

        elif opt_.o == 'csv':
            createCSVFileNode(data)

        elif opt_.o == 'both':
            templateLoader(data, cell=opt_.t)
            createCSVFileNode(data)

        elif opt_.o == 'email':
            file_l = templateLoader(data, cell=opt_.t, opt='email')
            email_user(file_l)

    else:
        print "Error!, cell %s not found. Current cell %s " % (opt_.t, az)
        return sys.exit(1)
示例#4
0
def main():
    parser = argparse.ArgumentParser(argument_default=argparse.SUPPRESS)
    parser.add_argument('-a',
                        nargs='?',
                        dest='target_cell',
                        action='store',
                        required=True,
                        default=True,
                        help='{specify 1 cell name to overide,e,g -a np}')
    parser.add_argument(
        '-o',
        nargs='?',
        dest='output',
        default='n',
        choices=['html', 'csv', 'both', 'email'],
        required=False,
        help='output, {default: console}, {email: email html }')

    opts = parser.parse_args()

    username = processConfig('production', 'user')
    key = processConfig('production', 'passwd')
    tenant_name = processConfig('production', 'name')
    url = processConfig('production', 'url')
    zone = processConfig('config', 'zone')
    client = createNovaConnection(username, key, tenant_name, url)
    az = processConfig('config', 'az')
    if opts.target_cell is not None:
        if opts.target_cell not in az:
            parser.error("Error!, cell %s not found. Current cell %s " %
                         (opts.target_cell, az))
    else:
        opts.target_cell = True

    data = collect_all(client, zone, opt=opts.target_cell)
    if opts.target_cell is True:
        data2 = combineResource(data)
    else:
        data2 = None

    if opts.output is 'n':
        printOptions(data, data_2=data2, options='all')

    elif opts.output == 'html':
        templateLoader(data, data2)

    elif opts.output == 'csv':
        if opts.target_cell is True:
            multiCSVNode(data)
            createCSVFileCloud(data2)
        else:
            createCSVFileNode(data)

    elif opts.output == 'both':
        templateLoader(data, data2, cell=opts.target_cell)
        if opts.target_cell is True:
            multiCSVNode(data)
            createCSVFileCloud(data2)
        else:
            createCSVFileNode(data)

    elif opts.output == 'email':
        file_l = templateLoader(data,
                                data2,
                                cell=opts.target_cell,
                                opt='email')
        emailUser(file_l)