diff options
Diffstat (limited to 'tuskar_ui/infrastructure/overview/forms.py')
-rw-r--r-- | tuskar_ui/infrastructure/overview/forms.py | 105 |
1 files changed, 52 insertions, 53 deletions
diff --git a/tuskar_ui/infrastructure/overview/forms.py b/tuskar_ui/infrastructure/overview/forms.py index 115d4064..77ff8c37 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 @@ -20,9 +22,7 @@ from django.utils.translation import ugettext_lazy as _ import horizon.exceptions import horizon.forms import horizon.messages -from neutronclient.common import exceptions as neutron_exceptions from os_cloud_config import keystone as keystone_config -from os_cloud_config import neutron as neutron_config from os_cloud_config.utils import clients from tuskar_ui import api @@ -30,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__) @@ -234,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: @@ -360,22 +403,6 @@ class PostDeployInit(horizon.forms.SelfHandlingForm): label=_("Public Host"), initial="", required=False) region = horizon.forms.CharField( label=_("Region"), initial="regionOne") - float_allocation_start = horizon.forms.CharField( - label=_("Float Allocation Start"), initial="10.0.0.2") - float_allocation_end = horizon.forms.CharField( - label=_("Float Allocation End"), initial="10.255.255.254") - float_cidr = horizon.forms.CharField( - label=_("Float CIDR"), initial="10.0.0.0/8") - overcloud_nameserver = horizon.forms.CharField( - label=_("Overcloud Nameserver"), initial="8.8.8.8") - external_allocation_start = horizon.forms.CharField( - label=_("External Allocation Start"), initial="172.17.0.45") - external_allocation_end = horizon.forms.CharField( - label=_("External Allocation End"), initial="172.17.0.64") - external_cidr = horizon.forms.CharField( - label=_("External CIDR"), initial="172.17.0.0/16") - bm_network_gateway = horizon.forms.CharField( - label=_("Network Gateway"), initial="192.0.2.1") def build_endpoints(self, plan, controller_role): return { @@ -385,6 +412,9 @@ class PostDeployInit(horizon.forms.SelfHandlingForm): "cinder": { "password": plan.parameter_value( controller_role.parameter_prefix + 'CinderPassword')}, + "cinderv2": { + "password": plan.parameter_value( + controller_role.parameter_prefix + 'CinderPassword')}, "ec2": { "password": plan.parameter_value( controller_role.parameter_prefix + 'GlancePassword')}, @@ -413,25 +443,6 @@ class PostDeployInit(horizon.forms.SelfHandlingForm): 'path': WEBROOT, 'admin_path': '%sadmin' % WEBROOT}} - def build_neutron_setup(self, data): - # TODO(lsmola) this is default devtest params, this should probably - # go from Tuskar parameters in the future. - return { - "float": { - "cidr": data['float_cidr'], - "name": "default-net", - "nameserver": data['overcloud_nameserver'], - "allocation_start": data['float_allocation_start'], - "allocation_end": data['float_allocation_end'] - }, - "external": { - "name": "ext-net", - "allocation_start": data['external_allocation_start'], - "allocation_end": data['external_allocation_end'], - "cidr": data['external_cidr'], - "gateway": data['bm_network_gateway'] - }} - def handle(self, request, data): try: plan = api.tuskar.Plan.get_the_plan(request) @@ -457,8 +468,6 @@ class PostDeployInit(horizon.forms.SelfHandlingForm): # retrieve needed Overcloud clients keystone_client = clients.get_keystone_client( auth_user, admin_password, auth_tenant, auth_url) - neutron_client = clients.get_neutron_client( - auth_user, admin_password, auth_tenant, auth_url) # do the setup endpoints keystone_config.setup_endpoints( @@ -468,16 +477,6 @@ class PostDeployInit(horizon.forms.SelfHandlingForm): os_auth_url=auth_url, client=keystone_client) - # do the neutron init - try: - neutron_config.initialize_neutron( - self.build_neutron_setup(data), - neutron_client=neutron_client, - keystone_client=keystone_client) - except neutron_exceptions.BadRequest as e: - LOG.info('Neutron has been already initialized.') - LOG.info(e.message) - except Exception as e: LOG.exception(e) horizon.exceptions.handle(request, |