From 6bec389675d7717e9507dd9bf74a0f881c0b5675 Mon Sep 17 00:00:00 2001 From: "Brad P. Crochet" Date: Thu, 16 Jul 2015 14:38:13 -0400 Subject: Add missing params for Ceph and scaling Some parameters were missing when controllers > 1 and when Ceph nodes are in play. This adds those missing params when the plan is edited. Change-Id: Ieefd9b901f6332be5fff70a349b06d6a2e0d2e2b --- tuskar_ui/infrastructure/overview/forms.py | 53 +++++++++++++++++++++++++++--- tuskar_ui/utils/utils.py | 12 +++++++ 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/tuskar_ui/infrastructure/overview/forms.py b/tuskar_ui/infrastructure/overview/forms.py index 17f45d69..ff78123e 100644 --- a/tuskar_ui/infrastructure/overview/forms.py +++ b/tuskar_ui/infrastructure/overview/forms.py @@ -13,6 +13,8 @@ # under the License. import logging +import six +import uuid from django.conf import settings import django.forms @@ -28,6 +30,7 @@ import tuskar_ui.api.heat import tuskar_ui.api.tuskar import tuskar_ui.forms import tuskar_ui.infrastructure.flavors.utils as flavors_utils +import tuskar_ui.utils.utils as tuskar_utils MATCHING_DEPLOYMENT_MODE = flavors_utils.matching_deployment_mode() LOG = logging.getLogger(__name__) @@ -232,12 +235,54 @@ class EditPlan(horizon.forms.SelfHandlingForm): # Controllers is > 1 try: controller_role = self.plan.get_role_by_name('Controller') + compute_role = self.plan.get_role_by_name('Compute') except Exception as e: - LOG.warning('Unable to find role: %s', 'Controller') + LOG.warning('Unable to find a required role: %s', e.message) else: - if parameters[controller_role.node_count_parameter_name] > 1: - l3ha_param = controller_role.parameter_prefix + 'NeutronL3HA' - parameters[l3ha_param] = 'True' + number_controllers = parameters[ + controller_role.node_count_parameter_name] + if number_controllers > 1: + for role in [controller_role, compute_role]: + l3ha_param = role.parameter_prefix + 'NeutronL3HA' + parameters[l3ha_param] = 'True' + l3agent_param = (role.parameter_prefix + + 'NeutronAllowL3AgentFailover') + parameters[l3agent_param] = 'True' + dhcp_agents_per_net = (number_controllers if number_controllers and + number_controllers > 3 else 3) + dhcp_agents_param = (controller_role.parameter_prefix + + 'NeutronDhcpAgentsPerNetwork') + parameters[dhcp_agents_param] = dhcp_agents_per_net + + try: + ceph_storage_role = self.plan.get_role_by_name('Ceph-Storage') + except Exception as e: + LOG.warning('Unable to find role: %s', 'Ceph-Storage') + else: + if parameters[ceph_storage_role.node_count_parameter_name] > 0: + parameters.update({ + 'CephClusterFSID': six.text_type(uuid.uuid4()), + 'CephMonKey': tuskar_utils.create_cephx_key(), + 'CephAdminKey': tuskar_utils.create_cephx_key() + }) + + cinder_enable_rbd_param = (controller_role.parameter_prefix + + 'CinderEnableRbdBackend') + glance_backend_param = (controller_role.parameter_prefix + + 'GlanceBackend') + nova_enable_rbd_param = (compute_role.parameter_prefix + + 'NovaEnableRbdBackend') + cinder_enable_iscsi_param = ( + controller_role.parameter_prefix + + 'CinderEnableIscsiBackend') + + parameters.update({ + cinder_enable_rbd_param: True, + glance_backend_param: 'rbd', + nova_enable_rbd_param: True, + cinder_enable_iscsi_param: False + }) + try: self.plan = self.plan.patch(request, self.plan.uuid, parameters) except Exception as e: diff --git a/tuskar_ui/utils/utils.py b/tuskar_ui/utils/utils.py index f99d9fda..8921d09b 100644 --- a/tuskar_ui/utils/utils.py +++ b/tuskar_ui/utils/utils.py @@ -11,9 +11,13 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import base64 import csv from itertools import izip +import os import re +import struct +import time from django.utils.translation import ugettext_lazy as _ @@ -138,3 +142,11 @@ def parse_csv_file(csv_file): raise ValueError(_("Unknown driver: %s.") % driver) return parsed_data + + +def create_cephx_key(): + # NOTE(gfidente): Taken from + # https://github.com/ceph/ceph-deploy/blob/master/ceph_deploy/new.py#L21 + key = os.urandom(16) + header = struct.pack("