Example #1
0
def _node_to_view(name, hosts):
    result = link_for_node(name)
    for h in hosts:
        if h.project == '(total)':
            result['memory'] = from_mb(h.memory_mb)
            result['cpus'] = h.cpu
        elif h.project == '(used_now)':
            result['memory-used'] = from_mb(h.memory_mb)
            result['cpus-used'] = h.cpu
    return result
Example #2
0
def _node_to_view(name, hosts):
    result = link_for_node(name)
    for h in hosts:
        if h.project == '(total)':
            result['memory'] = from_mb(h.memory_mb)
            result['cpus'] = h.cpu
        elif h.project == '(used_now)':
            result['memory-used'] = from_mb(h.memory_mb)
            result['cpus-used'] = h.cpu
    return result
Example #3
0
def _project_to_view(tenant, net, quotaset):
    network = None if net is None else {
        u'id': net.id,
        u'name': net.label,
        u'href': url_for('networks.get_network', net_id=net.id)
    }

    result = {
        u'id': tenant.id,
        u'name': tenant.name,
        u'href': url_for('projects.get_project', project_id=tenant.id),
        u'description': tenant.description,
        u'network': network,
        u'links': {
            u'stats':
            url_for('stats.get_project_stats', project_id=tenant.id),
            u'manage-users':
            url_for('project_users.list_project_users', project_id=tenant.id)
        }
    }

    if quotaset is not None:
        result[u'cpus-limit'] = quotaset.cores
        result[u'ram-limit'] = from_mb(quotaset.ram)
        result[u'instances-limit'] = quotaset.instances
    return result
Example #4
0
def _project_to_view(tenant, net, quotaset):
    network = None if net is None else {
        u'id': net.id,
        u'name': net.label,
        u'href': url_for('networks.get_network', net_id=net.id)
    }

    result = {
        u'id': tenant.id,
        u'name': tenant.name,
        u'href': url_for('projects.get_project', project_id=tenant.id),
        u'description': tenant.description,
        u'network': network,
        u'links': {
            u'stats': url_for('stats.get_project_stats',
                              project_id=tenant.id),
            u'manage-users': url_for('project_users.list_project_users',
                                     project_id=tenant.id)
        }
    }

    if quotaset is not None:
        result[u'cpus-limit'] = quotaset.cores
        result[u'ram-limit'] = from_mb(quotaset.ram)
        result[u'instances-limit'] = quotaset.instances
    return result
Example #5
0
def _instance_type_to_view(flavor):
    return {
        u'id': flavor.id,
        u'href': url_for('instance_types.get_instance_type',
                         instance_type_id=flavor.id),
        u'name': flavor.name,
        u'cpus': flavor.vcpus,
        u'ram': from_mb(flavor.ram),
        u'root-size': from_gb(flavor.disk),
        u'ephemeral-size': from_gb(flavor.ephemeral)
    }