コード例 #1
0
def RequestRetries(meth, client, var_=None):

    attempt = process_config('config', 'retries')

    for x in xrange(int(attempt)):
        try:
            if meth == 'gr':
                return client.hosts.get(var_)
                break
        except ClientException:
            time.sleep(5)
    return False
コード例 #2
0
ファイル: util_nova.py プロジェクト: djagadisan/landfile
def RequestRetries(meth, client, var_=None):

    attempt = process_config('config', 'retries')

    for x in xrange(int(attempt)):
        try:
            if meth == 'gr':
                return client.hosts.get(var_)
                break
        except ClientException:
            time.sleep(5)
    return False
コード例 #3
0
ファイル: run_main.py プロジェクト: djagadisan/landfile
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
ファイル: run_main.py プロジェクト: pombredanne/landfile
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)
コード例 #5
0
def RequestRetries(meth, client, var_=None):

    attempt = process_config('config', 'retries')

    for x in xrange(int(attempt)):
        try:
            if meth == 'gr':
                return client.hosts.get(var_)
                break
            if meth == 'host_list':
                return client.hypervisors.list()
            if meth == 'host_list_all':
                return client.hosts.list_all(var_)
        except Exception:
            time.sleep(5)
    return False
コード例 #6
0
def RequestRetries(meth, client, var_=None):

    attempt = process_config('config', 'retries')

    for x in xrange(int(attempt)):
        try:
            if meth == 'gr':
                return client.hosts.get(var_)
                break
            if meth == 'host_list':
                return client.hypervisors.list()
            if meth == 'host_list_all':
                return client.hosts.list_all(var_)
        except Exception:
            time.sleep(5)
    return False
コード例 #7
0
def RunCollect(client, zone, opt=None):
    flav = getAvailFlav(client)
    cell = filterAz(client, zone)
    if cell != False:
        timeout = process_config('config', 'timeout')
        if opt == True:
            jobs = []
            r_outs = [Queue() for q in range(len(cell[0]))]
            for z, i in enumerate(cell[0]):
                # rate limit seems to kick in
                client = create_connection()
                p = threading.Thread(name=z,
                                     target=computeStats,
                                     args=(cell[1][z], flav, zone, i, client,
                                           r_outs[z], True))
                jobs.append(p)
                p.start()

            for p in jobs:
                p.join(int(timeout))
                if p.is_alive():
                    p.terminate()
                    return False

            html_array = []
            for q in r_outs:
                html_array.append(q.get())

            return html_array
        else:

            if opt in cell[1]:

                index_id = cell[1].index(opt)

            a_name = cell[0][index_id]

            return computeStats(opt,
                                flav,
                                zone,
                                a_name,
                                client,
                                r_outs=None,
                                opt=None)
    else:
        return False
コード例 #8
0
def RunCollect(client, zone, opt=None):
    flav = getAvailFlav(client)
    cell = filterAz(client, zone)

    timeout = process_config('config', 'timeout')
    while cell:
        if opt == True:
            jobs = []
            r_outs = [Queue() for q in range(len(cell) + 1)]

            for z, i in enumerate(cell[0]):
                p = Process(name=z,
                            target=computeStats,
                            args=(cell[1][z], cell[2][z], flav, zone, i,
                                  client, r_outs[z], True))
                jobs.append(p)
                p.start()

            for p in jobs:
                p.join(int(timeout))
                if p.is_alive():
                    p.terminate()
                    return False

                html_array = []
                for q in r_outs:
                    html_array.append(q.get())

                    return html_array
        else:
            if opt in cell[1]:
                index_id = cell[1].index(opt)
                a_name = cell[0][index_id]
                c_name = cell[2][index_id]

        return computeStats(opt,
                            c_name,
                            flav,
                            zone,
                            a_name,
                            client,
                            r_outs=None,
                            opt=None)
    else:
        return False
コード例 #9
0
def RunCollect(client, zone, opt=None):
    flav = getAvailFlav(client)
    cell = filterAz(client, zone)
    if cell != False:
        timeout = process_config('config', 'timeout')
        if opt == True:
            jobs = []
            r_outs = [Queue() for q in range(len(cell[0]))]
            for z, i in enumerate(cell[0]):
                # rate limit seems to kick in
                client =  create_connection()
                p = threading.Thread(name=z, target=computeStats,
                            args=(cell[1][z], flav,
                                    zone, i, client, r_outs[z],
                                    True))
                jobs.append(p)
                p.start()
    
            for p in jobs:
                p.join(int(timeout))
                if p.is_alive():
                    p.terminate()
                    return False
    
            html_array = []
            for q in r_outs:
                html_array.append(q.get())
    
            return html_array
        else:
            
            
            if opt in cell[1]:
                
                index_id = cell[1].index(opt)
                
            a_name = cell[0][index_id]
    
            return computeStats(opt, flav, zone, a_name, client,
                                            r_outs=None, opt=None)
    else:
        return False
コード例 #10
0
def collect_data(client, zone, opt=None):
    vm_flavor = getAvailFlav(client)
    availability_zone = filterAz(client, zone)
    timeout = process_config('config', 'timeout')
    if availability_zone != False:
        if opt == True:
            thread_jobs = []
            result_queue = [Queue() for q in range(len(availability_zone[0]))]
            for key, value in enumerate(availability_zone[0]):
                client = create_connection()
                work_thread = threading.Thread(
                    name=key,
                    target=computeStats,
                    args=(availability_zone[1][key], vm_flavor, zone, value,
                          client, result_queue[key], True))
                thread_jobs.append(work_thread)
                work_thread.start()

            for data_thread in thread_jobs:
                data_thread.join(int(timeout))
                if data_thread.is_alive():
                    data_tread.terminate()
                    return false

            data_display = []
            for rq in result_queue:
                data_display.append(rq.get())

            return data_display
        else:
            if opt in cell[1]:
                index_id = cell[1].index(opt)
            az_name = cell[0][index_id]
            return computeStats(opt,
                                flav,
                                zone,
                                az_name,
                                client,
                                r_outs=None,
                                opt=None)
    else:
        return False
コード例 #11
0
ファイル: process_report.py プロジェクト: djagadisan/landfile
def RunCollect(client, zone, opt=None):
    flav = getAvailFlav(client)
    cell = filterAz(client, zone)

    timeout = process_config('config', 'timeout')
    while cell:
        if opt == True:
            jobs = []
            r_outs = [Queue() for q in range(len(cell) + 1)]

            for z, i in enumerate(cell[0]):
                p = Process(name=z, target=computeStats,
                    args=(cell[1][z], cell[2][z], flav,
                          zone, i, client, r_outs[z],
                          True)
                        )
                jobs.append(p)
                p.start()

            for p in jobs:
                p.join(int(timeout))
                if p.is_alive():
                    p.terminate()
                    return False

                html_array = []
                for q in r_outs:
                    html_array.append(q.get())

                    return html_array
        else:
            if opt in cell[1]:
                index_id = cell[1].index(opt)
                a_name = cell[0][index_id]
                c_name = cell[2][index_id]

        return computeStats(opt, c_name, flav, zone, a_name, client,
                                        r_outs=None, opt=None)
    else:
        return False
コード例 #12
0
def collect_data(client, zone, opt=None):
    vm_flavor = getAvailFlav(client)
    availability_zone = filterAz(client, zone)
    timeout = process_config('config', 'timeout')
    if availability_zone != False:
        if opt == True:
            thread_jobs = [] 
            result_queue = [Queue() for q in range (len(availability_zone[0]))]
            for key, value in enumerate(availability_zone[0]):
                client = create_connection()
                work_thread = threading.Thread(name=key, target=computeStats,
                                               args=(availability_zone[1][key], vm_flavor,
                                               zone, value, client, result_queue[key],
                                               True))
                thread_jobs.append(work_thread)
                work_thread.start()
            
            for data_thread in thread_jobs:
                data_thread.join(int(timeout))
                if data_thread.is_alive():
                    data_tread.terminate()
                    return false
                
            data_display = []
            for rq in result_queue:
                data_display.append(rq.get())
            
            return data_display
        else:
            if opt in cell[1]:
               index_id = cell[1].index(opt)
            az_name = cell[0][index_id]
            return computeStats(opt, flav, zone, az_name, client,
                                            r_outs=None, opt=None)
    else:
        return False