Fixed issue 858649 on Launchpad -- Distinguishes between tenant name and tenant id.

The recent changes to keystone switched from sending the tenant id to sending the tenant name as "tenant", thus breaking various tenant-related calls. This patch differentiates the two and names them as separate attributes on request.user. It also switches to using novaclient for the api.tenant_quota_get function.
This commit is contained in:
Gabriel Hurley 2011-09-26 14:39:03 -07:00
parent 233febe407
commit ebca6f7a6a
45 changed files with 110 additions and 106 deletions

View File

@ -374,7 +374,7 @@ def novaclient(request):
' and url "%s"' % (request.user.token, url_for(request, 'nova')))
c = client.Client(username=request.user.username,
api_key=request.user.token,
project_id=request.user.tenant,
project_id=request.user.tenant_id,
auth_url=url_for(request, 'nova'))
c.client.auth_token = request.user.token
c.client.management_url=url_for(request, 'nova')
@ -400,7 +400,7 @@ def swift_api(request):
def quantum_api(request):
tenant = None
if hasattr(request, 'user'):
tenant = request.user.tenant
tenant = request.user.tenant_id
else:
tenant = settings.QUANTUM_TENANT
@ -634,7 +634,7 @@ def token_create_scoped_with_token(request, tenant, token):
def tenant_quota_get(request, tenant):
return admin_api(request).quota_sets.get(tenant)
return novaclient(request).quotas.get(tenant)
@check_openstackx

View File

@ -62,7 +62,7 @@ class CreateContainer(forms.SelfHandlingForm):
def handle(self, request, data):
api.swift_create_container(request, data['name'])
messages.success(request, "Container was successfully created.")
return shortcuts.redirect("dash_containers", request.user.tenant)
return shortcuts.redirect("dash_containers", request.user.tenant_id)
@login_required

View File

@ -80,7 +80,7 @@ class FloatingIpAssociate(forms.SelfHandlingForm):
LOG.error("ClientException in FloatingIpAssociate", exc_info=True)
messages.error(request, 'Error associating Floating IP: %s'
% e.message)
return shortcuts.redirect('dash_floating_ips', request.user.tenant)
return shortcuts.redirect('dash_floating_ips', request.user.tenant_id)
class FloatingIpDisassociate(forms.SelfHandlingForm):
@ -100,7 +100,7 @@ class FloatingIpDisassociate(forms.SelfHandlingForm):
LOG.error("ClientException in FloatingIpAssociate", exc_info=True)
messages.error(request, 'Error disassociating Floating IP: %s'
% e.message)
return shortcuts.redirect('dash_floating_ips', request.user.tenant)
return shortcuts.redirect('dash_floating_ips', request.user.tenant_id)
class FloatingIpAllocate(forms.SelfHandlingForm):
@ -120,7 +120,7 @@ class FloatingIpAllocate(forms.SelfHandlingForm):
messages.error(request, 'Error allocating Floating IP "%s"\
to tenant "%s": %s' %
(fip.ip, data['tenant_id'], e.message))
return shortcuts.redirect('dash_floating_ips', request.user.tenant)
return shortcuts.redirect('dash_floating_ips', request.user.tenant_id)
@login_required
@ -139,7 +139,7 @@ def index(request, tenant_id):
return shortcuts.render_to_response(
'django_openstack/dash/floating_ips/index.html', {
'allocate_form': FloatingIpAllocate(initial={
'tenant_id': request.user.tenant}),
'tenant_id': request.user.tenant_id}),
'disassociate_form': FloatingIpDisassociate(),
'floating_ips': floating_ips,
'release_form': ReleaseFloatingIp(),

View File

@ -118,7 +118,7 @@ def index(request, tenant_id):
tenant = {}
try:
tenant = api.token_get_tenant(request, request.user.tenant)
tenant = api.token_get_tenant(request, request.user.tenant_id)
except api_exceptions.ApiException, e:
messages.error(request, "Unable to retrienve tenant info\
from keystone: %s" % e.message)
@ -185,8 +185,8 @@ def launch(request, tenant_id, image_id):
# TODO(mgius): Any reason why these can't be after the launchform logic?
# If The form is valid, we've just wasted these two api calls
image = api.image_get(request, image_id)
tenant = api.token_get_tenant(request, request.user.tenant)
quotas = api.tenant_quota_get(request, request.user.tenant)
tenant = api.token_get_tenant(request, request.user.tenant_id)
quotas = api.tenant_quota_get(request, request.user.tenant_id)
try:
quotas.ram = int(quotas.ram) / 100
except Exception, e:

View File

@ -168,7 +168,7 @@ def usage(request, tenant_id=None):
usage = {}
if not tenant_id:
tenant_id = request.user.tenant
tenant_id = request.user.tenant_id
try:
usage = api.usage_get(request, tenant_id, datetime_start, datetime_end)

View File

@ -65,7 +65,7 @@ class CreateNetwork(forms.SelfHandlingForm):
LOG.info(msg)
messages.success(request, msg)
return shortcuts.redirect('dash_networks',
tenant_id=request.user.tenant)
tenant_id=request.user.tenant_id)
class DeleteNetwork(forms.SelfHandlingForm):
@ -147,7 +147,7 @@ def index(request, tenant_id):
def create(request, tenant_id):
network_form, handled = CreateNetwork.maybe_handle(request)
if handled:
return shortcuts.redirect('dash_networks', request.user.tenant)
return shortcuts.redirect('dash_networks', request.user.tenant_id)
return shortcuts.render_to_response(
'django_openstack/dash/networks/create.html', {
@ -187,7 +187,7 @@ def rename(request, tenant_id, network_id):
network_details = api.quantum_network_details(request, network_id)
if handled:
return shortcuts.redirect('dash_networks', request.user.tenant)
return shortcuts.redirect('dash_networks', request.user.tenant_id)
return shortcuts.render_to_response(
'django_openstack/dash/networks/rename.html', {

View File

@ -155,7 +155,7 @@ def create(request, tenant_id, network_id):
if handled:
return shortcuts.redirect(
'dash_networks_detail',
tenant_id=request.user.tenant,
tenant_id=request.user.tenant_id,
network_id=network_id
)
@ -172,7 +172,7 @@ def attach(request, tenant_id, network_id, port_id):
if handled:
return shortcuts.redirect('dash_networks_detail',
request.user.tenant, network_id)
request.user.tenant_id, network_id)
# Get all avaliable vifs
vifs = _get_available_vifs(request)

View File

@ -25,10 +25,12 @@ import openstack
class User(object):
def __init__(self, token, user, tenant, admin, service_catalog):
def __init__(self, token=None, user=None, tenant_id=None, admin=None,
service_catalog=None, tenant_name=None):
self.token = token
self.username = user
self.tenant = tenant
self.tenant_id = tenant_id
self.tenant_name = tenant_name
self.admin = admin
self.service_catalog = service_catalog
@ -42,12 +44,13 @@ class User(object):
def get_user_from_request(request):
if 'user' not in request.session:
return User(None, None, None, None, None)
return User(request.session['token'],
request.session['user'],
request.session['tenant'],
request.session['admin'],
request.session['serviceCatalog'])
return User()
return User(token=request.session['token'],
user=request.session['user'],
tenant_id=request.session['tenant_id'],
tenant_name=request.session['tenant'],
admin=request.session['admin'],
service_catalog=request.session['serviceCatalog'])
class LazyUser(object):

View File

@ -4,20 +4,20 @@
<h3>Manage Compute</h3>
<ul class='sub_nav'>
<li><a {% if current_sidebar == "overview" %} class="active" {% endif %} href="{% url dash_overview %}">Overview</a></li>
<li><a {% if current_sidebar == "instances" %} class="active" {% endif %} href="{% url dash_instances request.user.tenant %}">Instances</a></li>
<li><a {% if current_sidebar == "images" %} class="active" {% endif %} href="{% url dash_images request.user.tenant %}">Images</a></li>
<li><a {% if current_sidebar == "snapshots" %} class="active" {% endif %} href="{% url dash_snapshots request.user.tenant %}">Snapshots</a></li>
<li><a {% if current_sidebar == "keypairs" %} class="active" {% endif %} href="{% url dash_keypairs request.user.tenant %}">Keypairs</a></li>
<li><a {% if current_sidebar == "floatingips" %} class="active" {% endif %} href="{% url dash_floating_ips request.user.tenant %}">Floating IPs</a></li>
<li><a {% if current_sidebar == "security_groups" %} class="active" {% endif %} href="{% url dash_security_groups request.user.tenant %}">Security Groups</a></li>
<li><a {% if current_sidebar == "instances" %} class="active" {% endif %} href="{% url dash_instances request.user.tenant_id %}">Instances</a></li>
<li><a {% if current_sidebar == "images" %} class="active" {% endif %} href="{% url dash_images request.user.tenant_id %}">Images</a></li>
<li><a {% if current_sidebar == "snapshots" %} class="active" {% endif %} href="{% url dash_snapshots request.user.tenant_id %}">Snapshots</a></li>
<li><a {% if current_sidebar == "keypairs" %} class="active" {% endif %} href="{% url dash_keypairs request.user.tenant_id %}">Keypairs</a></li>
<li><a {% if current_sidebar == "floatingips" %} class="active" {% endif %} href="{% url dash_floating_ips request.user.tenant_id %}">Floating IPs</a></li>
<li><a {% if current_sidebar == "security_groups" %} class="active" {% endif %} href="{% url dash_security_groups request.user.tenant_id %}">Security Groups</a></li>
{% if quantum_configured %}
<li><a {% if current_sidebar == "networks" %} class="active" {% endif %} href="{% url dash_networks request.user.tenant %}">Networks</a></li>
<li><a {% if current_sidebar == "networks" %} class="active" {% endif %} href="{% url dash_networks request.user.tenant_id %}">Networks</a></li>
{% endif %}
</ul>
{% if swift_configured %}
<h3>Manage Object Store</h3>
<ul class='sub_nav'>
<li><a {% if current_sidebar == "containers" %} class="active" {% endif %} href="{% url dash_containers request.user.tenant %}">Containers</a></li>
<li><a {% if current_sidebar == "containers" %} class="active" {% endif %} href="{% url dash_containers request.user.tenant_id %}">Containers</a></li>
</ul>
{% endif %}

View File

@ -9,8 +9,8 @@
<td id="actions">
<ul>
<li class="form">{% include "django_openstack/dash/containers/_delete.html" with form=delete_form %}</li>
<li><a href="{% url dash_objects request.user.tenant container.name %}">List Objects</a></li>
<li><a href="{% url dash_objects_upload request.user.tenant container.name %}">Upload Object</a></li>
<li><a href="{% url dash_objects request.user.tenant_id container.name %}">List Objects</a></li>
<li><a href="{% url dash_objects_upload request.user.tenant_id container.name %}">Upload Object</a></li>
</ul>
</td>
</tr>

View File

@ -7,12 +7,12 @@
{% endblock %}
{% block page_header %}
{% url dash_images request.user.tenant as refresh_link %}
{% url dash_images request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Containers" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
{% block dash_main %}
{% include 'django_openstack/dash/containers/_list.html' %}
<a class="action_link large-rounded" href="{% url dash_containers_create request.user.tenant %}">Create New Container &gt;&gt;</a>
<a class="action_link large-rounded" href="{% url dash_containers_create request.user.tenant_id %}">Create New Container &gt;&gt;</a>
{% endblock %}

View File

@ -26,7 +26,7 @@
{% if ip.fixed_ip %}
<li class="form">{% include "django_openstack/dash/floating_ips/_disassociate.html" with form=disassociate_form %}</li>
{% else %}
<li class="form"><a href="{% url dash_floating_ips_associate request.user.tenant ip.id %}">Associate to instance</a></li>
<li class="form"><a href="{% url dash_floating_ips_associate request.user.tenant_id ip.id %}">Associate to instance</a></li>
{% endif %}
</ul>
</td>

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_floating_ips request.user.tenant as refresh_link %}
{% url dash_floating_ips request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Floating IPs" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}

View File

@ -16,7 +16,7 @@
<td>{{image.status|capfirst}}</td>
<td id="actions">
<ul>
<li><a id="launch_{{image.id}}" class="launch" href="{% url dash_images_launch request.user.tenant image.id %}">Launch</a></li>
<li><a id="launch_{{image.id}}" class="launch" href="{% url dash_images_launch request.user.tenant_id image.id %}">Launch</a></li>
</ul>
</td>
</tr>

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_images request.user.tenant as refresh_link %}
{% url dash_images request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Images" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}

View File

@ -59,10 +59,10 @@
<ul>
<li class="form">{% include "django_openstack/common/instances/_terminate.html" with form=terminate_form %}</li>
<li class="form">{% include "django_openstack/common/instances/_reboot.html" with form=reboot_form %}</li>
<li><a target="_blank" href="{% url dash_instances_console request.user.tenant instance.id %}">Log</a></li>
<li><a target="_blank" href="{% url dash_instances_vnc request.user.tenant instance.id %}">VNC Console</a></li>
<li><a href="{% url dash_instances_update request.user.tenant instance.id %}">Edit</a></li>
<li><a href="{% url dash_snapshots_create request.user.tenant instance.id %}">Snapshot</a></li>
<li><a target="_blank" href="{% url dash_instances_console request.user.tenant_id instance.id %}">Log</a></li>
<li><a target="_blank" href="{% url dash_instances_vnc request.user.tenant_id instance.id %}">VNC Console</a></li>
<li><a href="{% url dash_instances_update request.user.tenant_id instance.id %}">Edit</a></li>
<li><a href="{% url dash_snapshots_create request.user.tenant_id instance.id %}">Snapshot</a></li>
</ul>
</td>
</tr>

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_instances request.user.tenant as refresh_link %}
{% url dash_instances request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Instances" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -18,7 +18,7 @@
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no instances. You can launch an instance from the <a href='{% url dash_images request.user.tenant %}'>Images Page.</a></p>
<p>There are currently no instances. You can launch an instance from the <a href='{% url dash_images request.user.tenant_id %}'>Images Page.</a></p>
</div>
{% endif %}
{% endblock %}
@ -29,7 +29,7 @@
function loadInstances(){
if ($("#ajax_option_box").is(':checked')) {
$('.refresh').addClass("refreshing");
$('#instances').load('{% url dash_instances_refresh request.user.tenant %}', function(){
$('#instances').load('{% url dash_instances_refresh request.user.tenant_id %}', function(){
$('.refresh').removeClass("refreshing");
});
};

View File

@ -15,7 +15,7 @@
<div class="dash_block">
<div class="left">
{% include 'django_openstack/dash/instances/_form.html' with form=form %}
<h3><a href="{% url dash_instances request.user.tenant %}"><< Return to Instances List</a></h3>
<h3><a href="{% url dash_instances request.user.tenant_id %}"><< Return to Instances List</a></h3>
</div>
<div class="right">
@ -32,7 +32,7 @@
$("#spinner").hide()
function loadInstances(){
$('#spinner').show();
$('#instances').load('{% url dash_instances_refresh request.user.tenant %}', function(){
$('#instances').load('{% url dash_instances_refresh request.user.tenant_id %}', function(){
$("#spinner").hide()
});
}

View File

@ -93,7 +93,7 @@
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no instances.<br/><br/>You can launch an instance from the <a href='{% url dash_images request.user.tenant %}'>Images Page.</a></p>
<p>There are currently no instances.<br/><br/>You can launch an instance from the <a href='{% url dash_images request.user.tenant_id %}'>Images Page.</a></p>
</div>
{% endif %}

View File

@ -28,7 +28,7 @@
<div class="left">
<h3>Your private key is being downloaded.</h3>
{% include 'django_openstack/dash/keypairs/_form.html' with form=create_form %}
<h3><a href="{% url dash_keypairs request.user.tenant %}"><< Return to keypairs list</a></h3>
<h3><a href="{% url dash_keypairs request.user.tenant_id %}"><< Return to keypairs list</a></h3>
</div>
<div class="right">

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_keypairs request.user.tenant as refresh_link %}
{% url dash_keypairs request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Keypairs" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -15,11 +15,11 @@
{% block dash_main %}
{% if keypairs %}
{% include 'django_openstack/dash/keypairs/_list.html' %}
<a id="keypairs_create_link" class="action_link large-rounded" href="{% url dash_keypairs_create request.user.tenant %}">Create New Keypair</a>
<a id="keypairs_create_link" class="action_link large-rounded" href="{% url dash_keypairs_create request.user.tenant_id %}">Create New Keypair</a>
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no keypairs. <a href='{% url dash_keypairs_create request.user.tenant %}'>Create A Keypair &gt;&gt;</a></p>
<p>There are currently no keypairs. <a href='{% url dash_keypairs_create request.user.tenant_id %}'>Create A Keypair &gt;&gt;</a></p>
</div>
{% endif %}
{% endblock %}

View File

@ -32,7 +32,7 @@
{% if port.attachment %}
<li class="form">{% include "django_openstack/dash/networks/_detach_port.html" with form=detach_port_form %}</li>
{% else %}
<li><a href='{% url dash_ports_attach request.user.tenant network.id port.id %}'>Attach</a></li>
<li><a href='{% url dash_ports_attach request.user.tenant_id network.id port.id %}'>Attach</a></li>
{% endif %}
<li class="form">{% include "django_openstack/dash/networks/_delete_port.html" with form=delete_port_form %}</li>
<li class="form">{% include "django_openstack/dash/networks/_toggle_port.html" with form=toggle_port_form %}</li>

View File

@ -10,7 +10,7 @@
<tbody class='main'>
{% for network in networks %}
<tr class="{% cycle 'odd' 'even' %}" id="{{network.id}}">
<td><a href='{% url dash_networks_detail request.user.tenant network.id %}'>{{network.id}}</a></td>
<td><a href='{% url dash_networks_detail request.user.tenant_id network.id %}'>{{network.id}}</a></td>
<td class="name">{{network.name}}</td>
<td>{{network.total}}</td>
<td>{{network.available}}</td>
@ -18,7 +18,7 @@
<td id="actions">
<ul>
<li class="form">{% include "django_openstack/dash/networks/_delete.html" with form=delete_form %}</li>
<li><a href='{% url dash_network_rename request.user.tenant network.id %}'>Rename</a></li>
<li><a href='{% url dash_network_rename request.user.tenant_id network.id %}'>Rename</a></li>
</ul>
</td>
</tr>

View File

@ -15,7 +15,7 @@
<div class="dash_block">
<div class="left">
{% include 'django_openstack/dash/networks/_form.html' with form=network_form %}
<h3><a href="{% url dash_networks request.user.tenant %}"><< Return to networks list</a></h3>
<h3><a href="{% url dash_networks request.user.tenant_id %}"><< Return to networks list</a></h3>
</div>
<div class="right">

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_networks_detail request.user.tenant network.id as refresh_link %}
{% url dash_networks_detail request.user.tenant_id network.id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title=network.name refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -20,11 +20,11 @@
{% block dash_main %}
{% if network.ports %}
{% include 'django_openstack/dash/networks/_detail.html' %}
<a id="network_create_link" class="action_link large-rounded" href="{% url dash_ports_create request.user.tenant network.id %}">Create Ports</a>
<a id="network_create_link" class="action_link large-rounded" href="{% url dash_ports_create request.user.tenant_id network.id %}">Create Ports</a>
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no ports in this network. <a href="{% url dash_ports_create request.user.tenant network.id %}">Create Ports &gt;&gt;</a></p>
<p>There are currently no ports in this network. <a href="{% url dash_ports_create request.user.tenant_id network.id %}">Create Ports &gt;&gt;</a></p>
</div>
{% endif %}
{% endblock %}

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_networks request.user.tenant as refresh_link %}
{% url dash_networks request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Networks" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -15,11 +15,11 @@
{% block dash_main %}
{% if networks %}
{% include 'django_openstack/dash/networks/_list.html' %}
<a id="network_create_link" class="action_link large-rounded" href="{% url dash_network_create request.user.tenant %}">Create New Network</a>
<a id="network_create_link" class="action_link large-rounded" href="{% url dash_network_create request.user.tenant_id %}">Create New Network</a>
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no networks. <a href='{% url dash_network_create request.user.tenant %}'>Create A Network &gt;&gt;</a></p>
<p>There are currently no networks. <a href='{% url dash_network_create request.user.tenant_id %}'>Create A Network &gt;&gt;</a></p>
</div>
{% endif %}
</div>

View File

@ -23,7 +23,7 @@
<div class="dash_block">
<div class="left">
{% include 'django_openstack/dash/networks/_rename_form.html' with form=rename_form %}
<h3><a href="{% url dash_networks request.user.tenant %}"><< Return to networks list</a></h3>
<h3><a href="{% url dash_networks request.user.tenant_id %}"><< Return to networks list</a></h3>
</div>
<div class="right">

View File

@ -8,9 +8,9 @@
<td>{{ object.name }}</td>
<td id="actions">
<ul>
<li><a href="{% url dash_object_copy request.user.tenant container_name object.name %}">Copy</a></li>
<li><a href="{% url dash_object_copy request.user.tenant_id container_name object.name %}">Copy</a></li>
<li class="form">{% include "django_openstack/dash/objects/_delete.html" with form=delete_form %}</li>
<li><a href="{% url dash_objects_download request.user.tenant container_name object.name %}">Download</a>
<li><a href="{% url dash_objects_download request.user.tenant_id container_name object.name %}">Download</a>
</ul>
</td>
</tr>

View File

@ -17,7 +17,7 @@
<div class="left">
<h3>Copy Object: '{{object_name}}'</h3>
{% include 'django_openstack/dash/objects/_copy.html' with form=copy_form greeting="HI" %}
<h3><a href="{% url dash_objects request.user.tenant container_name %}">&lt;&lt; Return to objects list</a></h3>
<h3><a href="{% url dash_objects request.user.tenant_id container_name %}">&lt;&lt; Return to objects list</a></h3>
</div>
<div class="right">

View File

@ -13,7 +13,7 @@
<div class='search'>
{% include 'django_openstack/dash/objects/_filter.html' with form=filter_form %}
</div>
<a class="refresh" title="Refresh" href="{% url dash_objects request.user.tenant container_name %}">Refresh List</a>
<a class="refresh" title="Refresh" href="{% url dash_objects request.user.tenant_id container_name %}">Refresh List</a>
</div>
</div>
{% endblock %}
@ -26,9 +26,9 @@
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no objects in the container {{container_name}}. You can upload a new object from the <a href='{% url dash_objects_upload request.user.tenant container_name %}'>Object Upload Page &gt;&gt;</a></p>
<p>There are currently no objects in the container {{container_name}}. You can upload a new object from the <a href='{% url dash_objects_upload request.user.tenant_id container_name %}'>Object Upload Page &gt;&gt;</a></p>
</div>
{% endif %}
<a class="action_link large-rounded" href="{% url dash_objects_upload request.user.tenant container_name %}">Upload New Object &gt;&gt;</a>
<a class="action_link large-rounded" href="{% url dash_objects_upload request.user.tenant_id container_name %}">Upload New Object &gt;&gt;</a>
{% endblock %}

View File

@ -16,7 +16,7 @@
<div class="dash_block wide form">
<div class="left">
{% include 'django_openstack/dash/objects/_form.html' with form=upload_form %}
<h3><a href="{% url dash_objects request.user.tenant container_name %}">&lt;&lt; Return to objects list</a></h3>
<h3><a href="{% url dash_objects request.user.tenant_id container_name %}">&lt;&lt; Return to objects list</a></h3>
</div>
<div class="right">

View File

@ -34,7 +34,7 @@
<div class="dash_block">
<div class="left">
{% include 'django_openstack/dash/ports/_attach.html' with form=attach_form %}
<h3><a href="{% url dash_networks_detail request.user.tenant network %}"><< Return to network detail</a></h3>
<h3><a href="{% url dash_networks_detail request.user.tenant_id network %}"><< Return to network detail</a></h3>
</div>
<div class="right">

View File

@ -15,7 +15,7 @@
<div class="dash_block">
<div class="left">
{% include 'django_openstack/dash/ports/_create.html' with form=create_form %}
<h3><a href="{% url dash_networks_detail request.user.tenant network_id %}"><< Return to network detail</a></h3>
<h3><a href="{% url dash_networks_detail request.user.tenant_id network_id %}"><< Return to network detail</a></h3>
</div>
<div class="right">

View File

@ -12,7 +12,7 @@
<td>{{ security_group.description }}</td>
<td id="actions">
<ul>
<li><a href="{% url dash_security_groups_edit_rules request.user.tenant security_group.id %}">Edit Rules</a></li>
<li><a href="{% url dash_security_groups_edit_rules request.user.tenant_id security_group.id %}">Edit Rules</a></li>
{% if security_group.name != 'default' %}
<li class="form">{% include "django_openstack/dash/security_groups/_delete.html" with form=delete_form %}</li>
{% endif %}

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_security_groups request.user.tenant as refresh_link %}
{% url dash_security_groups request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Security Groups" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -15,11 +15,11 @@
{% block dash_main %}
{% if security_groups %}
{% include 'django_openstack/dash/security_groups/_list.html' %}
<a id="security_groups_create_link" class="action_link large-rounded" href="{% url dash_security_groups_create request.user.tenant %}">Create Security Group</a>
<a id="security_groups_create_link" class="action_link large-rounded" href="{% url dash_security_groups_create request.user.tenant_id %}">Create Security Group</a>
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no security groups. <a href='{% url dash_security_groups_create request.user.tenant %}'>Create A Security Group &gt;&gt;</a></p>
<p>There are currently no security groups. <a href='{% url dash_security_groups_create request.user.tenant_id %}'>Create A Security Group &gt;&gt;</a></p>
</div>
{% endif %}
{% endblock %}

View File

@ -23,7 +23,7 @@
<div class="left">
<h3>Choose a name for your snapshot.</h3>
{% include 'django_openstack/dash/snapshots/_form.html' with form=create_form %}
<h3><a href="{% url dash_snapshots request.user.tenant %}"><< Return to snapshots list</a></h3>
<h3><a href="{% url dash_snapshots request.user.tenant_id %}"><< Return to snapshots list</a></h3>
</div>
<div class="right">

View File

@ -7,7 +7,7 @@
{% endblock %}
{% block page_header %}
{% url dash_snapshots request.user.tenant as refresh_link %}
{% url dash_snapshots request.user.tenant_id as refresh_link %}
{# to make searchable false, just remove it from the include statement #}
{% include "django_openstack/common/_page_header.html" with title="Snapshots" refresh_link=refresh_link searchable="true" %}
{% endblock page_header %}
@ -18,7 +18,7 @@
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no snapshots. You can create snapshots from running instances. <a href='{% url dash_instances request.user.tenant %}'>View Running Instances &gt;&gt;</a></p>
<p>There are currently no snapshots. You can create snapshots from running instances. <a href='{% url dash_instances request.user.tenant_id %}'>View Running Instances &gt;&gt;</a></p>
</div>
{% endif %}
{% endblock %}

View File

@ -44,8 +44,8 @@
<ul>
<li class="form">{% include "django_openstack/common/instances/_terminate.html" with form=terminate_form %}</li>
<li class="form">{% include "django_openstack/common/instances/_reboot.html" with form=reboot_form %}</li>
<li><a target="_blank" href="{% url dash_instances_console request.user.tenant instance.id %}">Console Log</a></li>
<li><a target="_blank" href="{% url dash_instances_vnc request.user.tenant instance.id %}">VNC Console</a></li>
<li><a target="_blank" href="{% url dash_instances_console request.user.tenant_id instance.id %}">Console Log</a></li>
<li><a target="_blank" href="{% url dash_instances_vnc request.user.tenant_id instance.id %}">VNC Console</a></li>
</ul>
</td>
</tr>

View File

@ -18,7 +18,7 @@
{% else %}
<div class="message_box info">
<h2>Info</h2>
<p>There are currently no instances. You can launch an instance from the <a href='{% url dash_images request.user.tenant %}'>Images Page.</a></p>
<p>There are currently no instances. You can launch an instance from the <a href='{% url dash_images request.user.tenant_id %}'>Images Page.</a></p>
</div>
{% endif %}
{% endblock %}

View File

@ -27,7 +27,8 @@ from django_openstack.middleware import keystone
class TestCase(test.TestCase):
TEST_STAFF_USER = 'staffUser'
TEST_TENANT = 'aTenant'
TEST_TENANT = '1'
TEST_TENANT_NAME = 'aTenant'
TEST_TOKEN = 'aToken'
TEST_USER = 'test'
@ -82,8 +83,8 @@ class TestCase(test.TestCase):
self.mox.UnsetStubs()
keystone.get_user_from_request = self._real_get_user_from_request
def setActiveUser(self, token, username,
tenant, is_admin, service_catalog):
def setActiveUser(self, token=None, username=None, tenant_id=None,
is_admin=None, service_catalog=None, tenant_name=None):
keystone.get_user_from_request = \
lambda x: keystone.User(token, username, tenant,
is_admin, service_catalog)
lambda x: keystone.User(token, username, tenant_id,
is_admin, service_catalog, tenant_name)

View File

@ -29,7 +29,7 @@ from mox import IsA
class AuthViewTests(base.BaseViewTests):
def setUp(self):
super(AuthViewTests, self).setUp()
self.setActiveUser(None, None, None, None, None)
self.setActiveUser()
self.PASSWORD = 'secret'
def test_login_index(self):

View File

@ -114,8 +114,8 @@ class ContainerViewTests(base.BaseViewTests):
messages.success(IgnoreArg(), IsA(str))
res = self.client.post(reverse('dash_containers_create',
args=[self.request.user.tenant]),
args=[self.request.user.tenant_id]),
formData)
self.assertRedirectsNoFollow(res, reverse('dash_containers',
args=[self.request.user.tenant]))
args=[self.request.user.tenant_id]))

View File

@ -95,11 +95,11 @@ class NetworkViewTests(base.BaseViewTests):
'method': 'CreateNetwork'}
res = self.client.post(reverse('dash_network_create',
args=[self.request.user.tenant]),
args=[self.request.user.tenant_id]),
formData)
self.assertRedirectsNoFollow(res, reverse('dash_networks',
args=[self.request.user.tenant]))
args=[self.request.user.tenant_id]))
self.mox.VerifyAll()
def test_network_delete(self):
@ -128,7 +128,7 @@ class NetworkViewTests(base.BaseViewTests):
'method': 'DeleteNetwork'}
res = self.client.post(reverse('dash_networks',
args=[self.request.user.tenant]),
args=[self.request.user.tenant_id]),
formData)
def test_network_rename(self):
@ -158,7 +158,7 @@ class NetworkViewTests(base.BaseViewTests):
'method': 'RenameNetwork'}
res = self.client.post(reverse('dash_network_rename',
args=[self.request.user.tenant, "n1"]),
args=[self.request.user.tenant_id, "n1"]),
formData)
def test_network_details(self):

View File

@ -43,11 +43,11 @@ class PortViewTests(base.BaseViewTests):
messages.success(IgnoreArg(), IsA(str))
res = self.client.post(reverse('dash_ports_create',
args=[self.request.user.tenant, "n1"]),
args=[self.request.user.tenant_id, "n1"]),
formData)
self.assertRedirectsNoFollow(res, reverse('dash_networks_detail',
args=[self.request.user.tenant,
args=[self.request.user.tenant_id,
"n1"]))
def test_port_delete(self):
@ -63,7 +63,7 @@ class PortViewTests(base.BaseViewTests):
messages.success(IgnoreArg(), IsA(str))
res = self.client.post(reverse('dash_networks_detail',
args=[self.request.user.tenant, "n1"]),
args=[self.request.user.tenant_id, "n1"]),
formData)
def test_port_attach(self):
@ -80,11 +80,11 @@ class PortViewTests(base.BaseViewTests):
messages.success(IgnoreArg(), IsA(str))
res = self.client.post(reverse('dash_ports_attach',
args=[self.request.user.tenant, "n1", "p1"]),
args=[self.request.user.tenant_id, "n1", "p1"]),
formData)
self.assertRedirectsNoFollow(res, reverse('dash_networks_detail',
args=[self.request.user.tenant,
args=[self.request.user.tenant_id,
"n1"]))
def test_port_detach(self):
@ -100,5 +100,5 @@ class PortViewTests(base.BaseViewTests):
messages.success(IgnoreArg(), IsA(str))
res = self.client.post(reverse('dash_networks_detail',
args=[self.request.user.tenant, "n1"]),
args=[self.request.user.tenant_id, "n1"]),
formData)

View File

@ -11,10 +11,10 @@
NOT _LOGGED_IN_TOPBAR
{% endif %}
</ul>
<div id="user_bar">
<a id="current_tenant" href="{% url dash_overview %}">
<h4>{{request.user.tenant}}</h4>
<h4>{{request.user.tenant_name}}</h4>
<span>as {{request.user.username}}</span>
</a>
<a id="drop_btn" href="#">&nbsp;</a>
@ -28,6 +28,6 @@
<li id="sign_out"><a href="{% url auth_logout %}">Sign Out</a></li>
</ul>
</div>
</div>