コード例 #1
0
    def test_create_with_trust_failed(self, mock_openstack_client_class,
                                      mock_cert_manager, mock_trust_manager,
                                      mock_cluster_create):
        e = exception.TrusteeOrTrustToClusterFailed(cluster_uuid='uuid')
        mock_trust_manager.create_trustee_and_trust.side_effect = e

        self._test_create_failed(mock_openstack_client_class,
                                 mock_cert_manager, mock_trust_manager,
                                 mock_cluster_create,
                                 exception.TrusteeOrTrustToClusterFailed,
                                 False)

        notifications = fake_notifier.NOTIFICATIONS
        self.assertEqual(1, len(notifications))
        self.assertEqual('magnum.cluster.create', notifications[0].event_type)
        self.assertEqual(taxonomy.OUTCOME_FAILURE,
                         notifications[0].payload['outcome'])
コード例 #2
0
def create_trustee_and_trust(osc, cluster):
    try:
        password = utils.generate_password(length=18)
        trustee = osc.keystone().create_trustee(
            cluster.uuid,
            password,
        )
        cluster.trustee_username = trustee.name
        cluster.trustee_user_id = trustee.id
        cluster.trustee_password = password
        trust = osc.keystone().create_trust(trustee.id)
        cluster.trust_id = trust.id
    except Exception:
        LOG.exception(
            _LE('Failed to create trustee and trust for Cluster: %s'),
            cluster.uuid)
        raise exception.TrusteeOrTrustToClusterFailed(
            cluster_uuid=cluster.uuid)