Ejemplo n.º 1
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        bay.uuid = uuid.uuid4()
        try:
            # Create trustee/trust and set them to bay
            trust_manager.create_trustee_and_trust(osc, bay)
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay, context=context)
            conductor_utils.notify_about_bay_operation(
                context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_PENDING)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except Exception as e:
            cert_manager.delete_certificates_from_bay(bay, context=context)
            trust_manager.delete_trustee_and_trust(osc, context, bay)
            conductor_utils.notify_about_bay_operation(
                context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_FAILURE)

            if isinstance(e, exc.HTTPBadRequest):
                e = exception.InvalidParameterValue(message=six.text_type(e))

            raise e

        bay.stack_id = created_stack['stack']['id']
        bay.status = bay_status.CREATE_IN_PROGRESS
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 2
0
    def _test_generate_certificates(self,
                                    expected_ca_name,
                                    mock_bay,
                                    mock_generate_ca_cert,
                                    mock_generate_client_cert):
        expected_ca_password = '******'
        expected_ca_cert = {
            'private_key': 'ca_private_key', 'certificate': 'ca_certificate'}
        expected_cert_ref = 'cert_ref'
        expected_ca_cert_ref = 'ca-cert-ref'

        mock_generate_ca_cert.return_value = (expected_ca_cert_ref,
                                              expected_ca_cert,
                                              expected_ca_password)
        mock_generate_client_cert.return_value = expected_cert_ref

        cert_manager.generate_certificates_to_bay(mock_bay)
        self.assertEqual(expected_ca_cert_ref, mock_bay.ca_cert_ref)
        self.assertEqual(expected_cert_ref, mock_bay.magnum_cert_ref)

        mock_generate_ca_cert.assert_called_once_with(expected_ca_name,
                                                      context=None)
        mock_generate_client_cert.assert_called_once_with(
            expected_ca_name, expected_ca_cert, expected_ca_password,
            context=None)
Ejemplo n.º 3
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        bay.uuid = uuid.uuid4()
        try:
            # Create trustee/trust and set them to bay
            trust_manager.create_trustee_and_trust(osc, bay)
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay, context=context)
            conductor_utils.notify_about_bay_operation(
                context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_PENDING)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except Exception as e:
            cert_manager.delete_certificates_from_bay(bay, context=context)
            trust_manager.delete_trustee_and_trust(osc, context, bay)
            conductor_utils.notify_about_bay_operation(
                context, taxonomy.ACTION_CREATE, taxonomy.OUTCOME_FAILURE)

            if isinstance(e, exc.HTTPBadRequest):
                e = exception.InvalidParameterValue(message=six.text_type(e))

                raise e
            raise

        bay.stack_id = created_stack['stack']['id']
        bay.status = bay_status.CREATE_IN_PROGRESS
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 4
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        bay.uuid = uuid.uuid4()
        self._create_trustee_and_trust(osc, bay)
        try:
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=six.text_type(e))
        except Exception:
            raise

        bay.stack_id = created_stack['stack']['id']
        bay.status = bay_status.CREATE_IN_PROGRESS
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 5
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        try:
            # Use Senlin to Create a Cluster
            params = {
                'master_profile_name': 'SUR_HEAT_Master_Profile',
                'minion_profile_name': 'SUR_HEAT_Minion_Profile',
                'master_profile_spec': '/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/master.yaml',
                'minion_profile_spec': '/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/minion.yaml',
                'si_policy_spec' : '/opt/stack/magnum/magnum/sur/SURspec/scaling_policy.spec',
                'so_policy_spec' : '/opt/stack/magnum/magnum/sur/SURspec/scaling_policy.spec',
                'cluster_name': 'SUR_HEAT_Cluster',
	        'node_count': 2
            }
            senlinfunc.create_cluster(osc, **params)
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay)
            #created_stack = _create_senlin_stack(context, osc, bay,
            #                                     bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=str(e))
        except Exception:
            raise

        #bay.stack_id = created_stack['stack']['id']
        bay.stack_id = 'SUR_cluster'
        bay.create()

        #self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 6
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        baymodel = objects.BayModel.get_by_uuid(context,
                                                bay.baymodel_id)
        if baymodel.registry_enabled:
            trust = osc.keystone().create_trust(
                CONF.docker_registry.trustee_user_id,
                CONF.docker_registry.trust_roles)
            bay.registry_trust_id = trust.id

        try:
            # Generate certificate and set the cert reference to bay
            bay.uuid = uuid.uuid4()
            cert_manager.generate_certificates_to_bay(bay)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=six.text_type(e))
        except Exception:
            raise

        bay.stack_id = created_stack['stack']['id']
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 7
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        baymodel = objects.BayModel.get_by_uuid(context,
                                                bay.baymodel_id)
        if baymodel.registry_enabled:
            trust = osc.keystone().create_trust(
                CONF.docker_registry.trustee_user_id,
                CONF.docker_registry.trust_roles)
            bay.registry_trust_id = trust.id

        try:
            # Generate certificate and set the cert reference to bay
            bay.uuid = uuid.uuid4()
            cert_manager.generate_certificates_to_bay(bay)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=six.text_type(e))
        except Exception:
            raise

        bay.stack_id = created_stack['stack']['id']
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 8
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug('bay_heat bay_create')

        osc = clients.OpenStackClients(context)

        try:
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay)
            created_stack = _create_stack(context, osc, bay,
                                          bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=str(e))
        except Exception:
            raise

        bay.stack_id = created_stack['stack']['id']
        bay.create()

        self._poll_and_check(osc, bay)

        return bay
Ejemplo n.º 9
0
    def bay_create(self, context, bay, bay_create_timeout):
        LOG.debug("bay_heat bay_create")

        osc = clients.OpenStackClients(context)

        try:
            # Generate certificate and set the cert reference to bay
            cert_manager.generate_certificates_to_bay(bay)
            # bay.stack_id = 'SUR_cluster'
            bay.create()
            # Use Senlin to Create a Cluster
            params = {
                "master_profile_name": "SUR_Master_Profile",
                "minion_profile_name": "SUR_Minion_Profile",
                "master_profile_spec": "/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/master.yaml",
                "minion_profile_spec": "/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/minion.yaml",
                "minion_template_spec": "/opt/stack/magnum/magnum/sur/SURspec/heat-fedora/heat-kubernetes-split/kubeminion.yaml",
                "si_policy_spec": "/opt/stack/magnum/magnum/sur/SURspec/scaling_in_policy.yaml",
                "so_policy_spec": "/opt/stack/magnum/magnum/sur/SURspec/scaling_out_policy.yaml",
                "cluster_name": "SUR_Cluster",
                "node_count": 2,
            }
            senlinfunc.create_cluster(osc, bay, **params)
            # created_stack = _create_senlin_stack(context, osc, bay,
            #                                     bay_create_timeout)
        except exc.HTTPBadRequest as e:
            cert_manager.delete_certificates_from_bay(bay)
            raise exception.InvalidParameterValue(message=str(e))
        except Exception:
            raise

        # bay.stack_id = created_stack['stack']['id']
        # bay.create()

        # self._poll_and_check(osc, bay)

        return bay