Example #1
0
    def _alloc_row(partition, name, alloc):
        """Transform allocation into a DataFrame-ready dict."""
        if not name:
            name = 'root'
        if not partition:
            partition = '-'

        traitz = traits.format_traits(trait_codes, alloc.traits)

        return {
            'partition': partition,
            'name': name,
            'mem': alloc.reserved[0],
            'cpu': alloc.reserved[1],
            'disk': alloc.reserved[2],
            'rank': alloc.rank,
            'rank_adj': alloc.rank_adjustment,
            'traits': traitz,
            'max_util': alloc.max_utilization,
        }
Example #2
0
    def _server_row(server):
        """Transform server into a DataFrame-ready dict."""
        partition = list(server.labels)[0]
        traitz = traits.format_traits(trait_codes, server.traits.traits)
        row = {
            'name': server.name,
            'location':
            '/'.join(reversed(list(_server_location(server.parent)))),
            'partition': partition if partition else '-',
            'traits': traitz,
            'state': server.state.value,
            'valid_until': server.valid_until,
            'mem': server.init_capacity[0],
            'cpu': server.init_capacity[1],
            'disk': server.init_capacity[2],
            'mem_free': server.free_capacity[0],
            'cpu_free': server.free_capacity[1],
            'disk_free': server.free_capacity[2]
        }

        return row
Example #3
0
 def _app_row(item):
     """Transform app into a DataFrame-ready dict."""
     rank, util0, util1, pending, order, app = item
     return {
         'instance': app.name,
         'affinity': app.affinity.name,
         'allocation': app.allocation.name,
         'rank': rank,
         'partition': app.allocation.label or '-',
         'util0': util0,
         'util1': util1,
         'pending': pending,
         'order': order,
         'identity_group': app.identity_group,
         'identity': app.identity,
         'mem': app.demand[0],
         'cpu': app.demand[1],
         'disk': app.demand[2],
         'traits': traits.format_traits(trait_codes, app.traits),
         'lease': app.lease,
         'expires': app.placement_expiry,
         'data_retention': app.data_retention_timeout,
         'server': app.server
     }
Example #4
0
def _transform(codes, trait_list, use_invalid=False, add_new=False):
    """Encode then decode traitz"""
    result, new_codes = traits.encode(codes, trait_list, use_invalid, add_new)
    return traits.format_traits(new_codes, result)
Example #5
0
def _transform(code, traitz, use_invalid=False):
    """Encode then decode traitz"""
    return traits.format_traits(code, traits.encode(code, traitz, use_invalid))
Example #6
0
def _transform(code, traitz):
    """Encode then decode traitz"""
    return traits.format_traits(code, traits.encode(code, traitz))