How to use the ocflib.lab.stats.list_desktops function in ocflib

To help you get started, we’ve selected a few ocflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ocf / ocfweb / ocfweb / stats / daily_graph.py View on Github external
def get_daily_plot(day: date) -> Figure:
    """Return matplotlib plot representing a day's plot."""
    start, end = get_open_close(day)
    desktops = list_desktops(public_only=True)
    profiles = UtilizationProfile.from_hostnames(desktops, start, end).values()
    desks_count = len(desktops)

    now: Any = datetime.now()
    latest = min(end, now)
    minute = timedelta(minutes=1)
    times = [start + i * minute for i in range((latest - start) // minute + 1)]
    if now >= end or now <= start:
        now = None
    sums = []

    for t in times:
        instant15 = t + timedelta(seconds=15)
        instant45 = t + timedelta(seconds=45)
        in_use = sum(1 if profile.in_use(instant15) or profile.in_use(instant45) else 0 for profile in profiles)
        sums.append(in_use)
github ocf / ocflib / tests-manual / lab / print_logins.py View on Github external
@contextmanager
def timeit():
    start = time.time()
    yield
    print('Time taken: {}'.format(time.time() - start))


if __name__ == '__main__':
    start = datetime(2015, 11, 23)
    end = start + timedelta(days=1)

    print('Testing naive time to create profiles.')
    with timeit():
        slow_profiles = {
            host + '.ocf.berkeley.edu': UtilizationProfile.from_hostname(host, start, end)
            for host in list_desktops()
        }

    print('Testing optimized time to create profiles.')
    with timeit():
        fast_profiles = UtilizationProfile.from_hostnames(list_desktops(), start, end)
github ocf / ocfweb / ocfweb / api / lab.py View on Github external
def _list_public_desktops() -> List[Any]:
    return list_desktops(public_only=True)
github ocf / ocfweb / ocfweb / docs / views / servers.py View on Github external
description='NFS host, KVM hypervisor for most NFS-using VMs',
            children=[
                Host.from_ldap(hostname)
                for hostname in ['biohazard', 'death', 'tsunami']
            ],
        ),

        Host.from_ldap('fallingrocks'),

        Host('blackhole', 'network', 'Managed Cisco Catalyst 2960S-48TS-L Switch', []),

        Host('deforestation', 'printer', '', []),
        Host('logjam', 'printer', '', []),
    ] + [
        Host.from_ldap(desktop, type='desktop')
        for desktop in list_desktops(public_only=True)
    ]