def test__has_kuryr_crd_error(self):
        crds = [
            k_const.K8S_API_CRD_KURYRNETS, k_const.K8S_API_CRD_KURYRNETPOLICIES
        ]
        for crd_url in crds:
            kubernetes = self.useFixture(k_fix.MockK8sClient()).client
            kubernetes.get.side_effect = k_exc.K8sClientException

            resp = utils.has_kuryr_crd(crd_url)
            self.assertEqual(resp, False)

            kubernetes.get.assert_called_once()
    def test__has_kuryrnetpolicy_crd(self):
        kuryrnetpolicies_crd = {
            "apiVersion": "openstack.org/v1",
            "items": [],
            "kind": "KuryrNetPolicyList",
            "metadata": {
                "continue": "",
                "resourceVersion": "34186",
            }
        }
        kubernetes = self.useFixture(k_fix.MockK8sClient()).client
        kubernetes.get.return_value = kuryrnetpolicies_crd

        kuryrnetpolicies_url = k_const.K8S_API_CRD_KURYRNETPOLICIES
        resp = utils.has_kuryr_crd(kuryrnetpolicies_url)

        self.assertEqual(resp, True)
    def test__has_kuryrnet_crd(self):
        kuryrnet_crd = {
            "apiVersion": "openstack.org/v1",
            "items": [],
            "kind": "KuryrNetList",
            "metadata": {
                "continue": "",
                "resourceVersion": "33018",
                "selfLink": "/apis/openstack.org/v1/kuryrnets"
            }
        }

        kubernetes = self.useFixture(k_fix.MockK8sClient()).client
        kubernetes.get.return_value = kuryrnet_crd

        kuryrnets_url = k_const.K8S_API_CRD_KURYRNETS
        resp = utils.has_kuryr_crd(kuryrnets_url)

        self.assertEqual(resp, True)
Beispiel #4
0
 def is_ready(self, quota):
     if not utils.has_kuryr_crd(constants.K8S_API_CRD_KURYRNETS):
         return False
     return self._check_quota(quota)
Beispiel #5
0
 def is_ready(self, quota):
     if not (utils.has_kuryr_crd(constants.K8S_API_CRD_KURYRNETWORKS)
             and self._check_quota(quota)):
         LOG.error('Marking NamespaceHandler as not ready.')
         return False
     return True
Beispiel #6
0
 def is_ready(self, quota):
     if not utils.has_kuryr_crd(k_const.K8S_API_CRD_KURYRNETPOLICIES):
         return False
     return self._check_quota(quota)
Beispiel #7
0
 def is_ready(self, quota):
     if not (utils.has_kuryr_crd(k_const.K8S_API_CRD_KURYRNETWORKPOLICIES)
             and self._check_quota(quota)):
         LOG.error("Marking NetworkPolicyHandler as not ready.")
         return False
     return True