Works around a failure to load openstack dashboard
This hack enables to load dashboard correctly by using django based implementation that is used in xena. Ideally, we should use angular based implementation like horizon, but I propose this workaround firstly because the current problem is really painful for us to develop Trove server side without dashboard. Task: 44413 Story: 2009825 Change-Id: I7da457f3a4fccb251288ac8b51df40a25a7e6e4a
This commit is contained in:
parent
1602afbd7e
commit
61a751d0ac
@ -0,0 +1,4 @@
|
||||
{% load i18n horizon %}
|
||||
|
||||
<p>{% blocktrans %}Choose network from Available networks to Selected networks by push button or drag and drop, you may change NIC order by drag and drop as well. {% endblocktrans %}</p>
|
||||
|
@ -0,0 +1,37 @@
|
||||
{% load i18n %}
|
||||
|
||||
<noscript><h3>{{ step }}</h3></noscript>
|
||||
<div id="networkListSortContainer" class="sort-container">
|
||||
<div class="col-sm-6">
|
||||
<label id="selected_network_label">{% trans "Selected networks" %}</label>
|
||||
<ul id="selected_network" class="networklist box-list"></ul>
|
||||
<label>{% trans "Available networks" %}</label>
|
||||
<ul id="available_network" class="networklist box-list"></ul>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
{% include "project/databases/_launch_instances_network_help.html" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="networkListIdContainer">
|
||||
<div class="actions">
|
||||
<div id="networkListId">
|
||||
{% include "horizon/common/_form_fields.html" %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="help_text">
|
||||
{{ step.get_help_text }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
if (typeof $ !== 'undefined') {
|
||||
horizon.instances.workflow_init($(".workflow"));
|
||||
} else {
|
||||
addHorizonLoadEvent(function() {
|
||||
horizon.instances.workflow_init($(".workflow"));
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
@ -23,17 +23,57 @@ from horizon import workflows
|
||||
from openstack_dashboard import api as dash_api
|
||||
from openstack_dashboard.dashboards.project.instances \
|
||||
import utils as instance_utils
|
||||
from openstack_dashboard.dashboards.project.instances.workflows \
|
||||
import create_instance as dash_create_instance
|
||||
from oslo_log import log as logging
|
||||
|
||||
|
||||
from trove_dashboard import api
|
||||
from trove_dashboard.utils import common as common_utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# NOTE(hiwkby): SetNetworkAction is migrated from horizon for compatibiity
|
||||
class SetNetworkAction(workflows.Action):
|
||||
network = forms.MultipleChoiceField(
|
||||
label=_("Networks"),
|
||||
widget=forms.ThemableCheckboxSelectMultiple(),
|
||||
error_messages={'required': _("At least one network must be "
|
||||
"specified.")},
|
||||
help_text=_("Launch instance with these networks"))
|
||||
|
||||
def __init__(self, request, *args, **kwargs):
|
||||
super().__init__(request, *args, **kwargs)
|
||||
self.use_required_attribute = False
|
||||
|
||||
network_list = self.fields["network"].choices
|
||||
if len(network_list) == 1:
|
||||
self.fields['network'].initial = [network_list[0][0]]
|
||||
|
||||
class Meta(object):
|
||||
name = _("Networking")
|
||||
permissions = ('openstack.services.network',)
|
||||
help_text = _("Select networks for your instance.")
|
||||
|
||||
def populate_network_choices(self, request, context):
|
||||
return instance_utils.network_field_data(request, for_launch=True)
|
||||
|
||||
|
||||
# NOTE(hiwkby): SetNetwork is migrated from horizon for compatibiity
|
||||
class SetNetwork(workflows.Step):
|
||||
action_class = SetNetworkAction
|
||||
template_name = "project/databases/_update_networks.html"
|
||||
contributes = ("network_id",)
|
||||
|
||||
def contribute(self, data, context):
|
||||
if data:
|
||||
networks = self.workflow.request.POST.getlist("network")
|
||||
# If no networks are explicitly specified, network list
|
||||
# contains an empty string, so remove it.
|
||||
networks = [n for n in networks if n != '']
|
||||
if networks:
|
||||
context['network_id'] = networks
|
||||
return context
|
||||
|
||||
|
||||
def parse_datastore_and_version_text(datastore_and_version):
|
||||
if datastore_and_version:
|
||||
datastore, datastore_version = datastore_and_version.split('-', 1)
|
||||
@ -540,7 +580,7 @@ class LaunchInstance(workflows.Workflow):
|
||||
failure_message = _('Unable to launch %(count)s named "%(name)s".')
|
||||
success_url = "horizon:project:databases:index"
|
||||
default_steps = (SetInstanceDetails,
|
||||
dash_create_instance.SetNetwork,
|
||||
SetNetwork,
|
||||
DatabaseAccess,
|
||||
InitializeDatabase,
|
||||
Advanced)
|
||||
|
Loading…
Reference in New Issue
Block a user