Skip to content

Commit

Permalink
Removes the admin launch instance function.
Browse files Browse the repository at this point in the history
It was added as a proof-of-concept for workflows, primarily,
and it has grave implications for security, accounting, and
other concerns. Given that no one even asked for the feature
to begin with, it seems wiser to take it back out.

Fixes bug 1036233.

Change-Id: I59ba56d2eae4b590ecd4671c1ae9e784a9861e39
  • Loading branch information
gabrielhurley committed Aug 15, 2012
1 parent f280caa commit 9947225
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 260 deletions.
6 changes: 3 additions & 3 deletions horizon/dashboards/nova/instances/workflows.py
Expand Up @@ -50,9 +50,9 @@ def __init__(self, request, *args, **kwargs):

class Meta:
name = _("Project & User")
permissions = ("openstack.roles.admin",)
help_text = _("Admin users may optionally select the project and "
"user for whom the instance should be created.")
# Unusable permission so this is always hidden. However, we
# keep this step in the workflow for validation/verification purposes.
permissions = ("!",)


class SelectProjectUser(workflows.Step):
Expand Down
8 changes: 2 additions & 6 deletions horizon/dashboards/syspanel/instances/tables.py
Expand Up @@ -25,16 +25,12 @@
from horizon.dashboards.nova.instances.tables import (TerminateInstance,
EditInstance, ConsoleLink, LogLink, CreateSnapshot,
TogglePause, ToggleSuspend, RebootInstance, get_size, UpdateRow,
LaunchLink, get_ips, get_power_state)
get_ips, get_power_state)
from horizon.utils.filters import replace_underscores

LOG = logging.getLogger(__name__)


class AdminLaunchLink(LaunchLink):
url = "horizon:syspanel:instances:launch"


class AdminUpdateRow(UpdateRow):
def get_data(self, request, instance_id):
instance = super(AdminUpdateRow, self).get_data(request, instance_id)
Expand Down Expand Up @@ -95,7 +91,7 @@ class Meta:
name = "instances"
verbose_name = _("Instances")
status_columns = ["status", "task"]
table_actions = (AdminLaunchLink, TerminateInstance,)
table_actions = (TerminateInstance,)
row_class = AdminUpdateRow
row_actions = (EditInstance, ConsoleLink, LogLink, CreateSnapshot,
TogglePause, ToggleSuspend, RebootInstance,
Expand Down
75 changes: 0 additions & 75 deletions horizon/dashboards/syspanel/instances/tests.py
Expand Up @@ -140,78 +140,3 @@ def test_ajax_loading_instances(self):
self.assertContains(res, "512MB RAM | 1 VCPU | 0 Disk", 1, 200)
self.assertContains(res, "Active", 1, 200)
self.assertContains(res, "Running", 1, 200)

@test.create_stubs({api.nova: ('flavor_list', 'keypair_list',
'security_group_list', 'volume_list',
'volume_snapshot_list',
'tenant_quota_usages', 'server_create'),
api.keystone: ('tenant_list',),
api.quantum: ('network_list',),
api.glance: ('image_list_detailed',)})
def test_launch_post(self):
flavor = self.flavors.first()
image = self.images.first()
keypair = self.keypairs.first()
server = self.servers.first()
volume = self.volumes.first()
sec_group = self.security_groups.first()
customization_script = 'user data'
device_name = u'vda'
volume_choice = "%s:vol" % volume.id
block_device_mapping = {device_name: u"%s::0" % volume_choice}
network = self.networks.first()
nics = [{"net-id": network.id, "v4-fixed-ip": ''}]
selected_network = json.dumps({'id': network.id,
'name': network.name,
'tenant_id': network.tenant_id})

api.nova.flavor_list(IsA(http.HttpRequest)) \
.AndReturn(self.flavors.list())
api.nova.keypair_list(IsA(http.HttpRequest)) \
.AndReturn(self.keypairs.list())
api.nova.security_group_list(IsA(http.HttpRequest)) \
.AndReturn(self.security_groups.list())
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'is_public': True}) \
.AndReturn([self.images.list(), False])
api.glance.image_list_detailed(IsA(http.HttpRequest),
filters={'property-owner_id': self.tenant.id}) \
.AndReturn([[], False])
api.nova.volume_list(IsA(http.HttpRequest)) \
.AndReturn(self.volumes.list())
api.nova.volume_snapshot_list(IsA(http.HttpRequest)).AndReturn([])
api.quantum.network_list(IsA(http.HttpRequest)) \
.AndReturn(self.networks.list())
api.keystone.tenant_list(IsA(http.HttpRequest), admin=True) \
.AndReturn(self.tenants.list())
api.nova.server_create(IsA(http.HttpRequest),
server.name,
image.id,
flavor.id,
keypair.name,
customization_script,
[sec_group.name],
block_device_mapping,
nics=nics,
instance_count=IsA(int))
self.mox.ReplayAll()

form_data = {'flavor': flavor.id,
'source_type': 'image_id',
'image_id': image.id,
'keypair': keypair.name,
'name': server.name,
'customization_script': customization_script,
'project_id': self.tenants.first().id,
'user_id': self.user.id,
'groups': sec_group.name,
'volume_type': 'volume_id',
'volume_id': volume_choice,
'device_name': device_name,
'network': [selected_network],
'count': 1}
url = reverse('horizon:syspanel:instances:launch')
res = self.client.post(url, form_data)
self.assertNoFormErrors(res)
self.assertRedirectsNoFollow(res,
reverse('horizon:syspanel:instances:index'))
3 changes: 1 addition & 2 deletions horizon/dashboards/syspanel/instances/urls.py
Expand Up @@ -20,15 +20,14 @@

from django.conf.urls.defaults import url, patterns

from .views import DetailView, AdminIndexView, AdminLaunchView
from .views import DetailView, AdminIndexView


INSTANCES = r'^(?P<instance_id>[^/]+)/%s$'


urlpatterns = patterns('horizon.dashboards.syspanel.instances.views',
url(r'^$', AdminIndexView.as_view(), name='index'),
url(r'^launch$', AdminLaunchView.as_view(), name='launch'),
url(INSTANCES % 'detail', DetailView.as_view(), name='detail'),
url(INSTANCES % 'console', 'console', name='console'),
url(INSTANCES % 'vnc', 'vnc', name='vnc'),
Expand Down
14 changes: 1 addition & 13 deletions horizon/dashboards/syspanel/instances/views.py
Expand Up @@ -28,23 +28,11 @@
from horizon import exceptions
from horizon import tables
from horizon.dashboards.syspanel.instances.tables import SyspanelInstancesTable
from horizon.dashboards.nova.instances.views import (console, DetailView,
vnc, LaunchInstanceView)
from .workflows import AdminLaunchInstance

from horizon.dashboards.nova.instances.views import console, DetailView, vnc

LOG = logging.getLogger(__name__)


class AdminLaunchView(LaunchInstanceView):
workflow_class = AdminLaunchInstance

def get_initial(self):
initial = super(LaunchInstanceView, self).get_initial()
initial['user_id'] = self.request.user.id
return initial


class AdminIndexView(tables.DataTableView):
table_class = SyspanelInstancesTable
template_name = 'syspanel/instances/index.html'
Expand Down
161 changes: 0 additions & 161 deletions horizon/dashboards/syspanel/instances/workflows.py

This file was deleted.

0 comments on commit 9947225

Please sign in to comment.