summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-01-31 11:51:10 +0000
committerGerrit Code Review <review@openstack.org>2014-01-31 11:51:10 +0000
commit5520d657df4e511040862ae1d4f94d9f2278ed77 (patch)
tree10aba7a7aeb4558b95d704cacb33cb2aa97d050f
parent02e7b6e9af21f11c8c6cb384bcc16bb06c09692b (diff)
parent361b76698bf368d4b7f8d31241a2f526fd5e96d9 (diff)
downloadhorizon-5520d657df4e511040862ae1d4f94d9f2278ed77.tar.gz
Merge "disable volume creation, when cinder is disabled" into stable/havana
-rw-r--r--openstack_dashboard/dashboards/project/images_and_snapshots/images/tables.py3
-rw-r--r--openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tables.py5
-rw-r--r--openstack_dashboard/dashboards/project/instances/workflows/create_instance.py28
3 files changed, 21 insertions, 15 deletions
diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tables.py b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tables.py
index 5c402059f..77f953747 100644
--- a/openstack_dashboard/dashboards/project/images_and_snapshots/images/tables.py
+++ b/openstack_dashboard/dashboards/project/images_and_snapshots/images/tables.py
@@ -26,6 +26,7 @@ from horizon import tables
from horizon.utils.memoized import memoized # noqa
from openstack_dashboard import api
+from openstack_dashboard.api import base
class LaunchImage(tables.LinkAction):
@@ -103,7 +104,7 @@ class CreateVolumeFromImage(tables.LinkAction):
return "?".join([base_url, params])
def allowed(self, request, image=None):
- if image:
+ if image and base.is_service_enabled(request, 'volume'):
return image.status == "active"
return False
diff --git a/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tables.py b/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tables.py
index e5a3c6927..34a3b748a 100644
--- a/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tables.py
+++ b/openstack_dashboard/dashboards/project/images_and_snapshots/volume_snapshots/tables.py
@@ -23,6 +23,7 @@ from django.utils.translation import ugettext_lazy as _ # noqa
from horizon import tables
from openstack_dashboard import api
+from openstack_dashboard.api import base
from openstack_dashboard.api import cinder
from openstack_dashboard.dashboards.project.volumes \
@@ -50,7 +51,9 @@ class CreateVolumeFromSnapshot(tables.LinkAction):
return "?".join([base_url, params])
def allowed(self, request, volume=None):
- return volume.status == "available" if volume else False
+ if volume and base.is_service_enabled(request, 'volume'):
+ return volume.status == "available"
+ return False
class UpdateRow(tables.Row):
diff --git a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
index 669646944..a3eedfc4e 100644
--- a/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
+++ b/openstack_dashboard/dashboards/project/instances/workflows/create_instance.py
@@ -36,6 +36,7 @@ from horizon.utils import validators
from horizon import workflows
from openstack_dashboard import api
+from openstack_dashboard.api import base
from openstack_dashboard.api import cinder
from openstack_dashboard.usage import quotas
@@ -135,22 +136,23 @@ class SetInstanceDetailsAction(workflows.Action):
request, context, *args, **kwargs)
source_type_choices = [
('', _("--- Select source ---")),
- ("image_id", _("Boot from image.")),
- ("instance_snapshot_id", _("Boot from snapshot.")),
- ("volume_id", _("Boot from volume.")),
+ ("image_id", _("Boot from image")),
+ ("instance_snapshot_id", _("Boot from snapshot")),
]
+ if base.is_service_enabled(request, 'volume'):
+ source_type_choices.append(("volume_id", _("Boot from volume")))
- try:
- if api.nova.extension_supported("BlockDeviceMappingV2Boot",
- request):
- source_type_choices.append(("volume_image_id",
- _("Boot from image (creates a new volume).")))
- except Exception:
- exceptions.handle(request, _('Unable to retrieve extensions '
- 'information.'))
+ try:
+ if api.nova.extension_supported("BlockDeviceMappingV2Boot",
+ request):
+ source_type_choices.append(("volume_image_id",
+ _("Boot from image (creates a new volume).")))
+ except Exception:
+ exceptions.handle(request, _('Unable to retrieve extensions '
+ 'information.'))
- source_type_choices.append(("volume_snapshot_id",
- _("Boot from volume snapshot (creates a new volume).")))
+ source_type_choices.append(("volume_snapshot_id",
+ _("Boot from volume snapshot (creates a new volume).")))
self.fields['source_type'].choices = source_type_choices
def clean(self):