Created
April 14, 2018 00:05
-
-
Save StephanX/40db23418a3c43e58f00de815c992c42 to your computer and use it in GitHub Desktop.
kubernetes python blocking list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
box ~> ipython | |
Python 3.6.5 (default, Mar 30 2018, 06:41:53) | |
Type 'copyright', 'credits' or 'license' for more information | |
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help. | |
In [1]: from kubernetes import client, config | |
In [2]: config.load_kube_config(context="dev.k8s.mycompany.io") | |
In [3]: api_instance = client.RbacAuthorizationV1beta1Api(client.ApiClient()) | |
In [4]: api_instance.list_cluster_role_binding() | |
--------------------------------------------------------------------------- | |
ValueError Traceback (most recent call last) | |
~/ubin/ipython in <module>() | |
----> 1 api_instance.list_cluster_role_binding() | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/rbac_authorization_v1beta1_api.py in list_cluster_role_binding(self, **kwargs) | |
1693 return self.list_cluster_role_binding_with_http_info(**kwargs) | |
1694 else: | |
-> 1695 (data) = self.list_cluster_role_binding_with_http_info(**kwargs) | |
1696 return data | |
1697 | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/apis/rbac_authorization_v1beta1_api.py in list_cluster_role_binding_with_http_info(self, **kwargs) | |
1790 _preload_content=params.get('_preload_content', True), | |
1791 _request_timeout=params.get('_request_timeout'), | |
-> 1792 collection_formats=collection_formats) | |
1793 | |
1794 def list_namespaced_role(self, namespace, **kwargs): | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async, _return_http_data_only, collection_formats, _preload_content, _request_timeout) | |
319 body, post_params, files, | |
320 response_type, auth_settings, | |
--> 321 _return_http_data_only, collection_formats, _preload_content, _request_timeout) | |
322 else: | |
323 thread = self.pool.apply_async(self.__call_api, (resource_path, method, | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout) | |
161 # deserialize response data | |
162 if response_type: | |
--> 163 return_data = self.deserialize(response_data, response_type) | |
164 else: | |
165 return_data = None | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in deserialize(self, response, response_type) | |
234 data = response.data | |
235 | |
--> 236 return self.__deserialize(data, response_type) | |
237 | |
238 def __deserialize(self, data, klass): | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __deserialize(self, data, klass) | |
274 return self.__deserialize_datatime(data) | |
275 else: | |
--> 276 return self.__deserialize_model(data, klass) | |
277 | |
278 def call_api(self, resource_path, method, | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __deserialize_model(self, data, klass) | |
618 and isinstance(data, (list, dict)): | |
619 value = data[klass.attribute_map[attr]] | |
--> 620 kwargs[attr] = self.__deserialize(value, attr_type) | |
621 | |
622 instance = klass(**kwargs) | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __deserialize(self, data, klass) | |
252 sub_kls = re.match('list\[(.*)\]', klass).group(1) | |
253 return [self.__deserialize(sub_data, sub_kls) | |
--> 254 for sub_data in data] | |
255 | |
256 if klass.startswith('dict('): | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in <listcomp>(.0) | |
252 sub_kls = re.match('list\[(.*)\]', klass).group(1) | |
253 return [self.__deserialize(sub_data, sub_kls) | |
--> 254 for sub_data in data] | |
255 | |
256 if klass.startswith('dict('): | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __deserialize(self, data, klass) | |
274 return self.__deserialize_datatime(data) | |
275 else: | |
--> 276 return self.__deserialize_model(data, klass) | |
277 | |
278 def call_api(self, resource_path, method, | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/api_client.py in __deserialize_model(self, data, klass) | |
620 kwargs[attr] = self.__deserialize(value, attr_type) | |
621 | |
--> 622 instance = klass(**kwargs) | |
623 | |
624 if hasattr(instance, 'get_real_child_model'): | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_cluster_role_binding.py in __init__(self, api_version, kind, metadata, role_ref, subjects) | |
66 self.metadata = metadata | |
67 self.role_ref = role_ref | |
---> 68 self.subjects = subjects | |
69 | |
70 @property | |
/usr/local/lib/python3.6/site-packages/kubernetes/client/models/v1beta1_cluster_role_binding.py in subjects(self, subjects) | |
183 """ | |
184 if subjects is None: | |
--> 185 raise ValueError("Invalid value for `subjects`, must not be `None`") | |
186 | |
187 self._subjects = subjects | |
ValueError: Invalid value for `subjects`, must not be `None` | |
============================= | |
@subjects.setter | |
def subjects(self, subjects): | |
""" | |
Sets the subjects of this V1beta1ClusterRoleBinding. | |
Subjects holds references to the objects the role applies to. | |
:param subjects: The subjects of this V1beta1ClusterRoleBinding. | |
:type: list[V1beta1Subject] | |
""" | |
if subjects is None: | |
raise ValueError("Invalid value for `subjects`, must not be `None`") | |
self._subjects = subjects |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment