Enable ExtraConfig Parameter in Tuskar UI
This patch enables the ExtraConfig parameter to be edited and its value applied to all roles. Change-Id: I90fa3a09b4bf984d2aaae0aed72648fd6695c10d
This commit is contained in:
parent
85f4ae4308
commit
fd9045c86a
@ -12,6 +12,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import django.forms
|
import django.forms
|
||||||
@ -20,6 +21,7 @@ import horizon.exceptions
|
|||||||
import horizon.forms
|
import horizon.forms
|
||||||
import horizon.messages
|
import horizon.messages
|
||||||
|
|
||||||
|
|
||||||
from tuskar_ui import api
|
from tuskar_ui import api
|
||||||
|
|
||||||
|
|
||||||
@ -80,15 +82,31 @@ class EditServiceConfig(horizon.forms.SelfHandlingForm):
|
|||||||
initial="",
|
initial="",
|
||||||
help_text=_('Address of the NTP server. If blank, public NTP servers '
|
help_text=_('Address of the NTP server. If blank, public NTP servers '
|
||||||
'will be used.'))
|
'will be used.'))
|
||||||
|
extra_config = django.forms.CharField(
|
||||||
|
label=_("Extra Config"),
|
||||||
|
required=False,
|
||||||
|
widget=django.forms.Textarea(attrs={'rows': 2}),
|
||||||
|
help_text=("Additional configuration to inject into the cluster."
|
||||||
|
"The data format of this field is JSON."
|
||||||
|
"See http://git.io/PuwLXQ for more information."))
|
||||||
|
|
||||||
|
def clean_extra_config(self):
|
||||||
|
data = self.cleaned_data['extra_config']
|
||||||
|
try:
|
||||||
|
json.loads(data)
|
||||||
|
except Exception as json_error:
|
||||||
|
raise django.forms.ValidationError(
|
||||||
|
_("%(err_msg)s"), params={'err_msg': json_error.message})
|
||||||
|
return data
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _load_snmp_parameters(plan, data):
|
def _load_additional_parameters(plan, data, form_key, param_name):
|
||||||
params = {}
|
params = {}
|
||||||
password = data.get('snmp_password')
|
param_value = data.get(form_key)
|
||||||
# Set the same SNMPd password in all roles.
|
# Set the same parameter and value in all roles.
|
||||||
for role in plan.role_list:
|
for role in plan.role_list:
|
||||||
key = role.parameter_prefix + 'SnmpdReadonlyUserPassword'
|
key = role.parameter_prefix + param_name
|
||||||
params[key] = password
|
params[key] = param_value
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|
||||||
@ -122,7 +140,12 @@ class EditServiceConfig(horizon.forms.SelfHandlingForm):
|
|||||||
compute_prefix + 'NtpServer':
|
compute_prefix + 'NtpServer':
|
||||||
ntp_server,
|
ntp_server,
|
||||||
}
|
}
|
||||||
parameters.update(self._load_snmp_parameters(plan, data))
|
parameters.update(self._load_additional_parameters(
|
||||||
|
plan, data,
|
||||||
|
'snmp_password', 'SnmpdReadonlyUserPassword'))
|
||||||
|
parameters.update(self._load_additional_parameters(
|
||||||
|
plan, data,
|
||||||
|
'extra_config', 'ExtraConfig'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
plan.patch(request, plan.uuid, parameters)
|
plan.patch(request, plan.uuid, parameters)
|
||||||
|
@ -74,7 +74,8 @@ class ParametersTest(test.BaseAdminViewTests):
|
|||||||
'snmp_password': 'password',
|
'snmp_password': 'password',
|
||||||
'cinder_iscsi_helper': 'lioadm',
|
'cinder_iscsi_helper': 'lioadm',
|
||||||
'cloud_name': 'cloud_name',
|
'cloud_name': 'cloud_name',
|
||||||
'neutron_public_interface': 'eth0'
|
'neutron_public_interface': 'eth0',
|
||||||
|
'extra_config': '{}'
|
||||||
}
|
}
|
||||||
with contextlib.nested(
|
with contextlib.nested(
|
||||||
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
|
patch('tuskar_ui.api.tuskar.Plan.get_the_plan',
|
||||||
@ -97,4 +98,8 @@ class ParametersTest(test.BaseAdminViewTests):
|
|||||||
'Compute-1::SnmpdReadonlyUserPassword': u'password',
|
'Compute-1::SnmpdReadonlyUserPassword': u'password',
|
||||||
'Block Storage-1::SnmpdReadonlyUserPassword': u'password',
|
'Block Storage-1::SnmpdReadonlyUserPassword': u'password',
|
||||||
'Object Storage-1::SnmpdReadonlyUserPassword': u'password',
|
'Object Storage-1::SnmpdReadonlyUserPassword': u'password',
|
||||||
'Controller-1::NtpServer': u''})
|
'Controller-1::NtpServer': u'',
|
||||||
|
'Controller-1::ExtraConfig': u'{}',
|
||||||
|
'Compute-1::ExtraConfig': u'{}',
|
||||||
|
'Block Storage-1::ExtraConfig': u'{}',
|
||||||
|
'Object Storage-1::ExtraConfig': u'{}'})
|
||||||
|
@ -23,10 +23,10 @@ from tuskar_ui.infrastructure.parameters import tabs
|
|||||||
|
|
||||||
|
|
||||||
class ServiceConfigView(horizon.forms.ModalFormView):
|
class ServiceConfigView(horizon.forms.ModalFormView):
|
||||||
template_name = "infrastructure/parameters/service_config.html"
|
|
||||||
form_class = forms.EditServiceConfig
|
form_class = forms.EditServiceConfig
|
||||||
success_url = reverse_lazy('horizon:infrastructure:parameters:index')
|
success_url = reverse_lazy('horizon:infrastructure:parameters:index')
|
||||||
submit_label = _("Save Configuration")
|
submit_label = _("Save Configuration")
|
||||||
|
template_name = "infrastructure/parameters/service_config.html"
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
plan = api.tuskar.Plan.get_the_plan(self.request)
|
plan = api.tuskar.Plan.get_the_plan(self.request)
|
||||||
@ -34,26 +34,29 @@ class ServiceConfigView(horizon.forms.ModalFormView):
|
|||||||
controller_prefix = plan.get_role_by_name(
|
controller_prefix = plan.get_role_by_name(
|
||||||
'controller').parameter_prefix
|
'controller').parameter_prefix
|
||||||
|
|
||||||
virt_type = plan.parameter_value(
|
|
||||||
compute_prefix + 'NovaComputeLibvirtType')
|
|
||||||
snmp_password = plan.parameter_value(
|
|
||||||
controller_prefix + 'SnmpdReadonlyUserPassword')
|
|
||||||
cinder_iscsi_helper = plan.parameter_value(
|
cinder_iscsi_helper = plan.parameter_value(
|
||||||
controller_prefix + 'CinderISCSIHelper')
|
controller_prefix + 'CinderISCSIHelper')
|
||||||
cloud_name = plan.parameter_value(
|
cloud_name = plan.parameter_value(
|
||||||
controller_prefix + 'CloudName')
|
controller_prefix + 'CloudName')
|
||||||
|
extra_config = plan.parameter_value(
|
||||||
|
controller_prefix + 'ExtraConfig')
|
||||||
neutron_public_interface = plan.parameter_value(
|
neutron_public_interface = plan.parameter_value(
|
||||||
controller_prefix + 'NeutronPublicInterface')
|
controller_prefix + 'NeutronPublicInterface')
|
||||||
ntp_server = plan.parameter_value(
|
ntp_server = plan.parameter_value(
|
||||||
controller_prefix + 'NtpServer')
|
controller_prefix + 'NtpServer')
|
||||||
|
snmp_password = plan.parameter_value(
|
||||||
|
controller_prefix + 'SnmpdReadonlyUserPassword')
|
||||||
|
virt_type = plan.parameter_value(
|
||||||
|
compute_prefix + 'NovaComputeLibvirtType')
|
||||||
return {
|
return {
|
||||||
'virt_type': virt_type,
|
|
||||||
'snmp_password': snmp_password,
|
|
||||||
'cinder_iscsi_helper': cinder_iscsi_helper,
|
'cinder_iscsi_helper': cinder_iscsi_helper,
|
||||||
'cloud_name': cloud_name,
|
'cloud_name': cloud_name,
|
||||||
'neutron_public_interface': neutron_public_interface,
|
'neutron_public_interface': neutron_public_interface,
|
||||||
'ntp_server': ntp_server}
|
'ntp_server': ntp_server,
|
||||||
|
'extra_config': extra_config,
|
||||||
|
'neutron_public_interface': neutron_public_interface,
|
||||||
|
'snmp_password': snmp_password,
|
||||||
|
'virt_type': virt_type}
|
||||||
|
|
||||||
|
|
||||||
class IndexView(horizon_tabs.TabbedTableView):
|
class IndexView(horizon_tabs.TabbedTableView):
|
||||||
|
@ -133,6 +133,30 @@ def data(TEST):
|
|||||||
'description': 'Snmpd password',
|
'description': 'Snmpd password',
|
||||||
'hidden': True,
|
'hidden': True,
|
||||||
'value': 'unset',
|
'value': 'unset',
|
||||||
|
}, {
|
||||||
|
'name': 'Controller-1::ExtraConfig',
|
||||||
|
'label': 'Extra Config',
|
||||||
|
'description': 'Extra Config',
|
||||||
|
'hidden': False,
|
||||||
|
'value': '{}',
|
||||||
|
}, {
|
||||||
|
'name': 'Compute-1::ExtraConfig',
|
||||||
|
'label': 'Extra Config',
|
||||||
|
'description': 'Extra Config',
|
||||||
|
'hidden': False,
|
||||||
|
'value': '{}',
|
||||||
|
}, {
|
||||||
|
'name': 'Block Storage-1::ExtraConfig',
|
||||||
|
'label': 'Extra Config',
|
||||||
|
'description': 'Extra Config',
|
||||||
|
'hidden': False,
|
||||||
|
'value': '{}',
|
||||||
|
}, {
|
||||||
|
'name': 'Object Storage-1::ExtraConfig',
|
||||||
|
'label': 'Extra Config',
|
||||||
|
'description': 'Extra Config',
|
||||||
|
'hidden': False,
|
||||||
|
'value': '{}',
|
||||||
}],
|
}],
|
||||||
})
|
})
|
||||||
TEST.tuskarclient_plans.add(plan_1)
|
TEST.tuskarclient_plans.add(plan_1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user