[Sahara] Added links to security groups

Change-Id: Icbea013bd4b035f2049b16d9589f84b7854210ae
Closes-Bug: #1400889
This commit is contained in:
Andrew Lazarev 2014-12-09 15:10:38 -08:00
parent 6f0634a9a0
commit c7010c14d3
8 changed files with 57 additions and 10 deletions

View File

@ -62,6 +62,8 @@ class NodeGroupsTab(tabs.Tab):
ng["node_group_template"] = helpers.safe_call(
saharaclient.nodegroup_template_get,
request, ng.get("node_group_template_id", None))
ng["security_groups_full"] = helpers.get_security_groups(
request, ng.get("security_groups"))
except Exception:
template = {}
exceptions.handle(request,

View File

@ -29,8 +29,12 @@
<dt>{% trans "Security Groups" %}</dt>
<dd>
<ul class="list-bullet">
{% for group in node_group.security_groups %}
<li>{{ group }}</li>
{% for group in node_group.security_groups_full %}
{% if group.id %}
<li><a href="{% url 'horizon:project:access_and_security:security_groups:detail' group.id %}">{{ group.name }}</a></li>
{% else %}
<li>{{ group.name }}</li>
{% endif %}
{% endfor %}
</ul>
</dd>

View File

@ -105,6 +105,9 @@ class NodeGroupsTab(tabs.Tab):
ng["node_group_template"] = helpers.safe_call(
sahara.node_group_templates.get,
ng["node_group_template_id"])
ng["security_groups_full"] = helpers.get_security_groups(
request, ng["security_groups"])
except Exception:
cluster = {}
exceptions.handle(request,

View File

@ -32,8 +32,12 @@
<dt>{% trans "Security Groups" %}</dt>
<dd>
<ul class="list-bullet">
{% for group in node_group.security_groups %}
<li>{{ group }}</li>
{% for group in node_group.security_groups_full %}
{% if group.id %}
<li><a href="{% url 'horizon:project:access_and_security:security_groups:detail' group.id %}">{{ group.name }}</a></li>
{% else %}
<li>{{ group.name }}</li>
{% endif %}
{% endfor %}
</ul>
</dd>

View File

@ -23,6 +23,9 @@ from openstack_dashboard.api import nova
from openstack_dashboard.api import sahara as saharaclient
from openstack_dashboard.dashboards.project. \
data_processing.utils import workflow_helpers as helpers
LOG = logging.getLogger(__name__)
@ -57,8 +60,12 @@ class GeneralTab(tabs.Tab):
exceptions.handle(request,
_("Unable to fetch floating ip pools."))
security_groups = helpers.get_security_groups(
request, template.security_groups)
return {"template": template, "flavor": flavor,
"floating_ip_pool_name": floating_ip_pool_name}
"floating_ip_pool_name": floating_ip_pool_name,
"security_groups": security_groups}
def _get_floating_ip_pool_name(self, request, pool_id):
pools = [pool for pool in network.floating_ip_pools_list(

View File

@ -42,8 +42,12 @@
<dt>{% trans "Security Groups" %}</dt>
<dd>
<ul class="list-bullet">
{% for group in template.security_groups %}
<li>{{ group }}</li>
{% for group in security_groups %}
{% if group.id %}
<li><a href="{% url 'horizon:project:access_and_security:security_groups:detail' group.id %}">{{ group.name }}</a></li>
{% else %}
<li>{{ group.name }}</li>
{% endif %}
{% endfor %}
</ul>
</dd>

View File

@ -11,11 +11,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import logging
from django.utils.translation import ugettext_lazy as _
from horizon import forms
from horizon import workflows
from openstack_dashboard.api import network
LOG = logging.getLogger(__name__)
class Parameter(object):
def __init__(self, config):
@ -142,6 +148,20 @@ def safe_call(func, *args, **kwargs):
return None
def get_security_groups(request, security_group_ids):
security_groups = []
for group in security_group_ids or []:
try:
security_groups.append(network.security_group_get(
request, group))
except Exception:
LOG.info(_('Unable to retrieve security group %(group)s.') %
{'group': group})
security_groups.append({'name': group})
return security_groups
def get_plugin_and_hadoop_version(request):
plugin_name = request.REQUEST["plugin_name"]
hadoop_version = request.REQUEST["hadoop_version"]

View File

@ -125,7 +125,8 @@ def data(TEST):
"updated_at": None,
"volume_mount_prefix": "/volumes/disk",
"volumes_per_node": 0,
"volumes_size": 0
"volumes_size": 0,
"security_groups": []
}
ngt1 = node_group_templates.NodeGroupTemplate(
@ -241,7 +242,8 @@ def data(TEST):
"updated_at": "2014-06-04 20:02:14.841760",
"volume_mount_prefix": "/volumes/disk",
"volumes_per_node": 0,
"volumes_size": 0
"volumes_size": 0,
"security_groups": []
},
{
"count": 2,
@ -281,7 +283,8 @@ def data(TEST):
"updated_at": "2014-06-04 20:02:15.355745",
"volume_mount_prefix": "/volumes/disk",
"volumes_per_node": 0,
"volumes_size": 0
"volumes_size": 0,
"security_groups": ["b7857890-09bf-4ee0-a0d5-322d7a6978bf"]
}
],
"plugin_name": "vanilla",