Browse Source

Use k8sclient library

In Ia400b5b6919753d6241233a6666a2c30c7618bc9, we are
adding a new library to global requirements. This
python-k8sclient library essentially has the same
code that was in Magnum so it's a straight replace.

Change-Id: Ib85bcf532e4163d5c1ac95ef701a1ec3133b69eb
changes/05/301305/10
Davanum Srinivas 6 years ago committed by Eli Qiao
parent
commit
a6650650f0
  1. 52
      magnum/common/pythonk8sclient/README.rst
  2. 0
      magnum/common/pythonk8sclient/__init__.py
  3. 121
      magnum/common/pythonk8sclient/swagger_client/__init__.py
  4. 562
      magnum/common/pythonk8sclient/swagger_client/api_client.py
  5. 4
      magnum/common/pythonk8sclient/swagger_client/apis/__init__.py
  6. 16248
      magnum/common/pythonk8sclient/swagger_client/apis/apiv_api.py
  7. 169
      magnum/common/pythonk8sclient/swagger_client/configuration.py
  8. 111
      magnum/common/pythonk8sclient/swagger_client/models/__init__.py
  9. 76
      magnum/common/pythonk8sclient/swagger_client/models/api_patch.py
  10. 124
      magnum/common/pythonk8sclient/swagger_client/models/json_watch_event.py
  11. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_aws_elastic_block_store_volume_source.py
  12. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_binding.py
  13. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_capabilities.py
  14. 76
      magnum/common/pythonk8sclient/swagger_client/models/v1_capability.py
  15. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_component_condition.py
  16. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_component_status.py
  17. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_component_status_list.py
  18. 449
      magnum/common/pythonk8sclient/swagger_client/models/v1_container.py
  19. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_port.py
  20. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_state.py
  21. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_state_running.py
  22. 249
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_state_terminated.py
  23. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_state_waiting.py
  24. 274
      magnum/common/pythonk8sclient/swagger_client/models/v1_container_status.py
  25. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_delete_options.py
  26. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_empty_dir_volume_source.py
  27. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_endpoint_address.py
  28. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_endpoint_port.py
  29. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_endpoint_subset.py
  30. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_endpoints.py
  31. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_endpoints_list.py
  32. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_env_var.py
  33. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_env_var_source.py
  34. 324
      magnum/common/pythonk8sclient/swagger_client/models/v1_event.py
  35. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_event_list.py
  36. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_event_source.py
  37. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_exec_action.py
  38. 76
      magnum/common/pythonk8sclient/swagger_client/models/v1_finalizer_name.py
  39. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_gce_persistent_disk_volume_source.py
  40. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_git_repo_volume_source.py
  41. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_glusterfs_volume_source.py
  42. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_handler.py
  43. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_host_path_volume_source.py
  44. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_http_get_action.py
  45. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_iscsi_volume_source.py
  46. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_lifecycle.py
  47. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_limit_range.py
  48. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_limit_range_item.py
  49. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_limit_range_list.py
  50. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_limit_range_spec.py
  51. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_list_meta.py
  52. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_load_balancer_ingress.py
  53. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_load_balancer_status.py
  54. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_local_object_reference.py
  55. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_namespace.py
  56. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_namespace_list.py
  57. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_namespace_spec.py
  58. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_namespace_status.py
  59. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_nfs_volume_source.py
  60. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_node.py
  61. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_address.py
  62. 224
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_condition.py
  63. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_list.py
  64. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_spec.py
  65. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_status.py
  66. 274
      magnum/common/pythonk8sclient/swagger_client/models/v1_node_system_info.py
  67. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_object_field_selector.py
  68. 349
      magnum/common/pythonk8sclient/swagger_client/models/v1_object_meta.py
  69. 249
      magnum/common/pythonk8sclient/swagger_client/models/v1_object_reference.py
  70. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume.py
  71. 76
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_access_mode.py
  72. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_claim.py
  73. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_claim_list.py
  74. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_claim_spec.py
  75. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_claim_status.py
  76. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_claim_volume_source.py
  77. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_list.py
  78. 349
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_spec.py
  79. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_persistent_volume_status.py
  80. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod.py
  81. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_condition.py
  82. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_list.py
  83. 374
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_spec.py
  84. 274
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_status.py
  85. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_template.py
  86. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_template_list.py
  87. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_pod_template_spec.py
  88. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_probe.py
  89. 274
      magnum/common/pythonk8sclient/swagger_client/models/v1_rbd_volume_source.py
  90. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_replication_controller.py
  91. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_replication_controller_list.py
  92. 149
      magnum/common/pythonk8sclient/swagger_client/models/v1_replication_controller_spec.py
  93. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_replication_controller_status.py
  94. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_resource_quota.py
  95. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_resource_quota_list.py
  96. 99
      magnum/common/pythonk8sclient/swagger_client/models/v1_resource_quota_spec.py
  97. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_resource_quota_status.py
  98. 124
      magnum/common/pythonk8sclient/swagger_client/models/v1_resource_requirements.py
  99. 174
      magnum/common/pythonk8sclient/swagger_client/models/v1_se_linux_options.py
  100. 199
      magnum/common/pythonk8sclient/swagger_client/models/v1_secret.py
  101. Some files were not shown because too many files have changed in this diff Show More

52
magnum/common/pythonk8sclient/README.rst

@ -1,52 +0,0 @@
==========================
Kubernetes API client code
==========================
Overview
--------
This is Kubernetes API python client code. This code is generated by
swagger-codegen. Kubernetes provide swagger-spec to generate client code
for different versions. The specs live in Kubernetes repo.
See also
--------
* swagger-codegen: https://github.com/swagger-api/swagger-codegen
* Kubernetes swagger-spec: https://github.com/GoogleCloudPlatform/kubernetes/tree/master/api/swagger-spec
Prerequisites
-------------
You need to install required packages for swagger codegen. Please refer to
`<https://github.com/swagger-api/swagger-codegen#prerequisites>`_
Steps to generate API client code
---------------------------------
Steps to generate Kubernetes client code for v1:
* Clone the Magnum repo::
git clone https://github.com/openstack/magnum.git
* Clone the swagger-codegen repo. It is recommended to checkout a release
(e.g. v2.1.3) instead of using the master branch::
git clone https://github.com/swagger-api/swagger-codegen.git
cd swagger-codegen/
git checkout tags/v2.1.3
* Build swagger-codegen::
mvn package
* Run below command to generate the API client code for Kubernetes::
cd ..
java -jar ./swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
generate \
-i ./magnum/magnum/common/pythonk8sclient/templates/v1.json \
-l python -o ./KubernetesClientCode
Now you can check the code at location ./KubernetesClientCode.

0
magnum/common/pythonk8sclient/__init__.py

121
magnum/common/pythonk8sclient/swagger_client/__init__.py

@ -1,121 +0,0 @@
from __future__ import absolute_import
# import models into sdk package
from .models.v1_node import V1Node
from .models.v1_persistent_volume_claim_list import V1PersistentVolumeClaimList
from .models.v1_object_field_selector import V1ObjectFieldSelector
from .models.v1_se_linux_options import V1SELinuxOptions
from .models.v1_container_state_running import V1ContainerStateRunning
from .models.v1_volume_mount import V1VolumeMount
from .models.v1_persistent_volume_claim_spec import V1PersistentVolumeClaimSpec
from .models.v1_gce_persistent_disk_volume_source import V1GCEPersistentDiskVolumeSource
from .models.v1_namespace_status import V1NamespaceStatus
from .models.v1_resource_quota_spec import V1ResourceQuotaSpec
from .models.v1_namespace_spec import V1NamespaceSpec
from .models.v1_persistent_volume import V1PersistentVolume
from .models.v1_persistent_volume_status import V1PersistentVolumeStatus
from .models.v1_endpoints_list import V1EndpointsList
from .models.v1_git_repo_volume_source import V1GitRepoVolumeSource
from .models.v1_capabilities import V1Capabilities
from .models.v1_node_condition import V1NodeCondition
from .models.v1_pod_template_list import V1PodTemplateList
from .models.v1_local_object_reference import V1LocalObjectReference
from .models.v1_resource_quota_status import V1ResourceQuotaStatus
from .models.v1_exec_action import V1ExecAction
from .models.v1_object_meta import V1ObjectMeta
from .models.api_patch import ApiPatch
from .models.v1_limit_range_spec import V1LimitRangeSpec
from .models.v1_iscsi_volume_source import V1ISCSIVolumeSource
from .models.v1_empty_dir_volume_source import V1EmptyDirVolumeSource
from .models.v1_node_list import V1NodeList
from .models.v1_persistent_volume_claim import V1PersistentVolumeClaim
from .models.v1_namespace_list import V1NamespaceList
from .models.v1_service_account import V1ServiceAccount
from .models.v1_node_address import V1NodeAddress
from .models.v1_namespace import V1Namespace
from .models.v1_list_meta import V1ListMeta
from .models.v1_persistent_volume_claim_volume_source import V1PersistentVolumeClaimVolumeSource
from .models.v1_persistent_volume_claim_status import V1PersistentVolumeClaimStatus
from .models.v1_resource_quota_list import V1ResourceQuotaList
from .models.v1_endpoint_subset import V1EndpointSubset
from .models.v1_secret_volume_source import V1SecretVolumeSource
from .models.v1_env_var_source import V1EnvVarSource
from .models.v1_load_balancer_ingress import V1LoadBalancerIngress
from .models.v1_service import V1Service
from .models.v1_service_account_list import V1ServiceAccountList
from .models.v1_limit_range_list import V1LimitRangeList
from .models.v1_endpoints import V1Endpoints
from .models.v1_delete_options import V1DeleteOptions
from .models.v1_volume import V1Volume
from .models.v1_probe import V1Probe
from .models.v1_capability import V1Capability
from .models.v1_replication_controller import V1ReplicationController
from .models.v1_limit_range import V1LimitRange
from .models.v1_pod_status import V1PodStatus
from .models.v1_pod_spec import V1PodSpec
from .models.v1_container_port import V1ContainerPort
from .models.v1_event_list import V1EventList
from .models.v1_resource_quota import V1ResourceQuota
from .models.v1_lifecycle import V1Lifecycle
from .models.v1_node_status import V1NodeStatus
from .models.v1_glusterfs_volume_source import V1GlusterfsVolumeSource
from .models.v1_handler import V1Handler
from .models.v1_replication_controller_spec import V1ReplicationControllerSpec
from .models.v1_event_source import V1EventSource
from .models.v1_status_cause import V1StatusCause
from .models.v1_pod_condition import V1PodCondition
from .models.v1_rbd_volume_source import V1RBDVolumeSource
from .models.v1_status import V1Status
from .models.v1_pod_template import V1PodTemplate
from .models.v1_service_status import V1ServiceStatus
from .models.v1_nfs_volume_source import V1NFSVolumeSource
from .models.v1_endpoint_port import V1EndpointPort
from .models.v1_tcp_socket_action import V1TCPSocketAction
from .models.v1_http_get_action import V1HTTPGetAction
from .models.v1_status_details import V1StatusDetails
from .models.v1_load_balancer_status import V1LoadBalancerStatus
from .models.v1_secret_list import V1SecretList
from .models.v1_container import V1Container
from .models.v1_persistent_volume_spec import V1PersistentVolumeSpec
from .models.v1_replication_controller_status import V1ReplicationControllerStatus
from .models.v1_finalizer_name import V1FinalizerName
from .models.v1_service_port import V1ServicePort
from .models.v1_component_condition import V1ComponentCondition
from .models.v1_component_status_list import V1ComponentStatusList
from .models.v1_host_path_volume_source import V1HostPathVolumeSource
from .models.json_watch_event import JsonWatchEvent
from .models.v1_binding import V1Binding
from .models.v1_container_state_terminated import V1ContainerStateTerminated
from .models.v1_security_context import V1SecurityContext
from .models.v1_container_state import V1ContainerState
from .models.v1_aws_elastic_block_store_volume_source import V1AWSElasticBlockStoreVolumeSource
from .models.v1_container_status import V1ContainerStatus
from .models.v1_replication_controller_list import V1ReplicationControllerList
from .models.v1_secret import V1Secret
from .models.v1_event import V1Event
from .models.v1_env_var import V1EnvVar
from .models.v1_resource_requirements import V1ResourceRequirements
from .models.v1_persistent_volume_access_mode import V1PersistentVolumeAccessMode
from .models.v1_component_status import V1ComponentStatus
from .models.v1_limit_range_item import V1LimitRangeItem
from .models.v1_pod_template_spec import V1PodTemplateSpec
from .models.v1_pod_list import V1PodList
from .models.v1_service_list import V1ServiceList
from .models.v1_persistent_volume_list import V1PersistentVolumeList
from .models.v1_object_reference import V1ObjectReference
from .models.v1_container_state_waiting import V1ContainerStateWaiting
from .models.v1_node_system_info import V1NodeSystemInfo
from .models.v1_service_spec import V1ServiceSpec
from .models.v1_pod import V1Pod
from .models.v1_node_spec import V1NodeSpec
from .models.v1_endpoint_address import V1EndpointAddress
# import apis into sdk package
from .apis.apiv_api import ApivApi
# import ApiClient
from .api_client import ApiClient
from .configuration import Configuration
configuration = Configuration()

562
magnum/common/pythonk8sclient/swagger_client/api_client.py

@ -1,562 +0,0 @@
# coding: utf-8
"""
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import absolute_import
from . import models
from .rest import RESTClient
from .rest import ApiException
import os
import re
import json
import mimetypes
import random
import tempfile
import threading
from datetime import datetime
from datetime import date
# python 2 and python 3 compatibility library
import six
from six import iteritems
import six.moves.builtins as __builtin__
from six.moves.urllib import parse as urlparse
from .configuration import Configuration
class ApiClient(object):
"""
Generic API client for Swagger client library builds.
Swagger generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
the methods and models for each application are generated from the Swagger
templates.
NOTE: This class is auto generated by the swagger code generator program.
https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.
:param host: The base path for the server to call.
:param header_name: a header to pass when making calls to the API.
:param header_value: a header value to pass when making calls to the API.
"""
def __init__(self, host=Configuration().host,
header_name=None, header_value=None, cookie=None,
key_file=None, cert_file=None, ca_certs=None):
"""
Constructor of the class.
"""
self.default_headers = {}
if header_name is not None:
self.default_headers[header_name] = header_value
self.host = host
self.cookie = cookie
# Set default User-Agent.
self.user_agent = 'Python-Swagger'
self.RESTClient = RESTClient(key_file=key_file,
cert_file=cert_file,
ca_certs=ca_certs)
@property
def user_agent(self):
"""
Gets user agent.
"""
return self.default_headers['User-Agent']
@user_agent.setter
def user_agent(self, value):
"""
Sets user agent.
"""
self.default_headers['User-Agent'] = value
def set_default_header(self, header_name, header_value):
self.default_headers[header_name] = header_value
def __call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, callback=None):
# headers parameters
header_params = header_params or {}
header_params.update(self.default_headers)
if self.cookie:
header_params['Cookie'] = self.cookie
if header_params:
header_params = self.sanitize_for_serialization(header_params)
# path parameters
if path_params:
path_params = self.sanitize_for_serialization(path_params)
for k, v in iteritems(path_params):
replacement = urlparse.quote(str(self.to_path_value(v)))
resource_path = resource_path.\
replace('{' + k + '}', replacement)
# query parameters
if query_params:
query_params = self.sanitize_for_serialization(query_params)
query_params = {k: self.to_path_value(v)
for k, v in iteritems(query_params)}
# post parameters
if post_params:
post_params = self.prepare_post_parameters(post_params, files)
post_params = self.sanitize_for_serialization(post_params)
# auth setting
self.update_params_for_auth(header_params, query_params, auth_settings)
# body
if body:
body = self.sanitize_for_serialization(body)
# request url
url = self.host + resource_path
# perform request and return response
response_data = self.request(method, url,
query_params=query_params,
headers=header_params,
post_params=post_params, body=body)
self.last_response = response_data
# deserialize response data
if response_type:
deserialized_data = self.deserialize(response_data, response_type)
else:
deserialized_data = None
if callback:
callback(deserialized_data)
else:
return deserialized_data
def to_path_value(self, obj):
"""
Takes value and turn it into a string suitable for inclusion in
the path, by url-encoding.
:param obj: object or string value.
:return string: quoted value.
"""
if type(obj) == list:
return ','.join(obj)
else:
return str(obj)
def sanitize_for_serialization(self, obj):
"""
Builds a JSON POST object.
If obj is None, return None.
If obj is str, int, float, bool, return directly.
If obj is datetime.datetime, datetime.date
convert to string in iso8601 format.
If obj is list, santize each element in the list.
If obj is dict, return the dict.
If obj is swagger model, return the properties dict.
:param obj: The data to serialize.
:return: The serialized form of data.
"""
if isinstance(obj, type(None)):
return None
elif isinstance(obj, (six.text_type, str, int, float, bool, tuple, file)):
return obj
elif isinstance(obj, list):
return [self.sanitize_for_serialization(sub_obj)
for sub_obj in obj]
elif isinstance(obj, (datetime, date)):
return obj.isoformat()
else:
if isinstance(obj, dict):
obj_dict = obj
else:
# Convert model obj to dict except
# attributes `swagger_types`, `attribute_map`
# and attributes which value is not None.
# Convert attribute name to json key in
# model definition for request.
obj_dict = {obj.attribute_map[attr]: getattr(obj, attr)
for attr, _ in iteritems(obj.swagger_types)
if getattr(obj, attr) is not None}
return {key: self.sanitize_for_serialization(val)
for key, val in iteritems(obj_dict)}
def deserialize(self, response, response_type):
"""
Deserializes response into an object.
:param response: RESTResponse object to be deserialized.
:param response_type: class literal for
deserialzied object, or string of class name.
:return: deserialized object.
"""
# handle file downloading
# save response body into a tmp file and return the instance
if "file" == response_type:
return self.__deserialize_file(response)
# fetch data from response object
try:
data = json.loads(response.data)
except ValueError:
data = response.data
return self.__deserialize(data, response_type)
def __deserialize(self, data, klass):
"""
Deserializes dict, list, str into an object.
:param data: dict, list or str.
:param klass: class literal, or string of class name.
:return: object.
"""
if data is None:
return None
if type(klass) == str:
if klass.startswith('list['):
sub_kls = re.match('list\[(.*)\]', klass).group(1)
return [self.__deserialize(sub_data, sub_kls)
for sub_data in data]
if klass.startswith('dict('):
sub_kls = re.match('dict\(([^,]*), (.*)\)', klass).group(2)
return {k: self.__deserialize(v, sub_kls)
for k, v in iteritems(data)}
# convert str to class
# for native types
if klass in ['int', 'float', 'str', 'bool', 'object']:
klass = getattr(__builtin__, klass)
elif klass == 'date':
klass = date
elif klass == 'datetime':
klass = datetime
# for model types
else:
klass = getattr(models, klass)
if klass in [int, float, str, bool]:
return self.__deserialize_primitive(data, klass)
elif klass == object:
return self.__deserialize_object()
elif klass == date:
return self.__deserialize_date(data)
elif klass == datetime:
return self.__deserialize_datatime(data)
else:
return self.__deserialize_model(data, klass)
def call_api(self, resource_path, method,
path_params=None, query_params=None, header_params=None,
body=None, post_params=None, files=None,
response_type=None, auth_settings=None, callback=None):
"""
Makes the HTTP request and return the deserialized data.
:param resource_path: Path to method endpoint.
:param method: Method to call.
:param path_params: Path parameters in the url.
:param query_params: Query parameters in the url.
:param header_params: Header parameters to be
placed in the request header.
:param body: Request body.
:param post_params dict: Request post form parameters,
for `application/x-www-form-urlencoded`, `multipart/form-data`.
:param auth_settings list: Auth Settings names for the request.
:param response: Response data type.
:param files dict: key -> filename, value -> filepath,
for `multipart/form-data`.
:param callback function: Callback function for asynchronous request.
If provide this parameter,
the request will be called asynchronously.
:return:
If provide parameter callback,
the request will be called asynchronously.
The method will return the request thread.
If parameter callback is None,
then the method will return the response directly.
"""
if callback is None:
return self.__call_api(resource_path, method,
path_params, query_params, header_params,
body, post_params, files,
response_type, auth_settings, callback)
else:
thread = threading.Thread(target=self.__call_api,
args=(resource_path, method,
path_params, query_params,
header_params, body,
post_params, files,
response_type, auth_settings,
callback))
thread.start()
return thread
def request(self, method, url, query_params=None, headers=None,
post_params=None, body=None):
"""
Makes the HTTP request using instance of rest client.
"""
if method == "GET":
return self.RESTClient.GET(url,
query_params=query_params,
headers=headers)
elif method == "HEAD":
return self.RESTClient.HEAD(url,
query_params=query_params,
headers=headers)
elif method == "POST":
return self.RESTClient.POST(url,
query_params=query_params,
headers=headers,
post_params=post_params,
body=body)
elif method == "PUT":
return self.RESTClient.PUT(url,
query_params=query_params,
headers=headers,
post_params=post_params,
body=body)
elif method == "PATCH":
return self.RESTClient.PATCH(url,
query_params=query_params,
headers=headers,
post_params=post_params,
body=body)
elif method == "DELETE":
return self.RESTClient.DELETE(url,
query_params=query_params,
headers=headers)
else:
raise ValueError(
"http method must be `GET`, `HEAD`,"
" `POST`, `PATCH`, `PUT` or `DELETE`."
)
def prepare_post_parameters(self, post_params=None, files=None):
"""
Builds form parameters.
:param post_params: Normal form parameters.
:param files: File parameters.
:return: Form parameters with files.
"""
params = {}
if post_params:
params.update(post_params)
if files:
for k, v in iteritems(files):
if not v:
continue
with open(v, 'rb') as f:
filename = os.path.basename(f.name)
filedata = f.read()
mimetype = mimetypes.\
guess_type(filename)[0] or 'application/octet-stream'
params[k] = tuple([filename, filedata, mimetype])
return params
def select_header_accept(self, accepts):
"""
Returns `Accept` based on an array of accepts provided.
:param accepts: List of headers.
:return: Accept (e.g. application/json).
"""
if not accepts:
return
accepts = list(map(lambda x: x.lower(), accepts))
if 'application/json' in accepts:
return 'application/json'
else:
return ', '.join(accepts)
def select_header_content_type(self, content_types):
"""
Returns `Content-Type` based on an array of content_types provided.
:param content_types: List of content-types.
:return: Content-Type (e.g. application/json).
"""
if not content_types:
return 'application/json'
content_types = list(map(lambda x: x.lower(), content_types))
if 'application/json' in content_types:
return 'application/json'
else:
return content_types[0]
def update_params_for_auth(self, headers, querys, auth_settings):
"""
Updates header and query params based on authentication setting.
:param headers: Header parameters dict to be updated.
:param querys: Query parameters dict to be updated.
:param auth_settings: Authentication setting identifiers list.
"""
config = Configuration()
if not auth_settings:
return
for auth in auth_settings:
auth_setting = config.auth_settings().get(auth)
if auth_setting:
if auth_setting['in'] == 'header':
headers[auth_setting['key']] = auth_setting['value']
elif auth_setting['in'] == 'query':
querys[auth_setting['key']] = auth_setting['value']
else:
raise ValueError(
'Authentication token must be in `query` or `header`'
)
def __deserialize_file(self, response):
"""
Saves response body into a file in (the defined) temporary folder,
using the filename from the `Content-Disposition` header if provided,
otherwise a random filename.
:param response: RESTResponse.
:return: file path.
"""
config = Configuration()
fd, path = tempfile.mkstemp(dir=config.temp_folder_path)
os.close(fd)
os.remove(path)
content_disposition = response.getheader("Content-Disposition")
if content_disposition:
filename = re.\
search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).\
group(1)
path = os.path.join(os.path.dirname(path), filename)
with open(path, "w") as f:
f.write(response.data)
return path
def __deserialize_primitive(self, data, klass):
"""
Deserializes string to primitive type.
:param data: str.
:param klass: class literal.
:return: int, float, str, bool.
"""
try:
value = klass(data)
except UnicodeEncodeError:
value = six.text_type(data)
except TypeError:
value = data
return value
def __deserialize_object(self):
"""
Deserializes empty object.
:return: object.
"""
return object()
def __deserialize_date(self, string):
"""
Deserializes string to date.
:param string: str.
:return: date.
"""
try:
from dateutil.parser import parse
return parse(string).date()
except ImportError:
return string
except ValueError:
raise ApiException(
status=0,
reason="Failed to parse `{0}` into a date object"
.format(string)
)
def __deserialize_datatime(self, string):
"""
Deserializes string to datetime.
The string should be in iso8601 datetime format.
:param string: str.
:return: datetime.
"""
try:
from dateutil.parser import parse
return parse(string)
except ImportError:
return string
except ValueError:
raise ApiException(
status=0,
reason="Failed to parse `{0}` into a datetime object".
format(string)
)
def __deserialize_model(self, data, klass):
"""
Deserializes list or dict to model.
:param data: dict, list.
:param klass: class literal.
:return: model object.
"""
instance = klass()
for attr, attr_type in iteritems(instance.swagger_types):
if data is not None \
and instance.attribute_map[attr] in data\
and isinstance(data, (list, dict)):
value = data[instance.attribute_map[attr]]
setattr(instance, attr, self.__deserialize(value, attr_type))
return instance

4
magnum/common/pythonk8sclient/swagger_client/apis/__init__.py

@ -1,4 +0,0 @@
from __future__ import absolute_import
# import apis into api package
from .apiv_api import ApivApi

16248
magnum/common/pythonk8sclient/swagger_client/apis/apiv_api.py

File diff suppressed because it is too large Load Diff

169
magnum/common/pythonk8sclient/swagger_client/configuration.py

@ -1,169 +0,0 @@
# coding: utf-8
"""
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from __future__ import absolute_import
import base64
import urllib3
try:
import httplib
except ImportError:
# for python3
import http.client as httplib
import sys
import logging
def singleton(cls, *args, **kw):
instances = {}
def _singleton():
if cls not in instances:
instances[cls] = cls(*args, **kw)
return instances[cls]
return _singleton
@singleton
class Configuration(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
https://github.com/swagger-api/swagger-codegen
Do not edit the class manually.
"""
def __init__(self):
"""
Constructor
"""
# Default Base url
self.host = "https://127.0.0.1:6443/"
# Default api client
self.api_client = None
# Temp file folder for download
self.temp_folder_path = None
# Authentication Settings
# dict to store API key(s)
self.api_key = {}
# dict to store API prefix (e.g. Bearer)
self.api_key_prefix = {}
# Username for HTTP basic authentication
self.username = ""
# Password for HTTP basic authentication
self.password = ""
# Logging Settings
self.logging_format = '%(asctime)s %(levelname)s %(message)s'
# Debug file location
self.__logging_file = None
# Debug switch
self.__debug = False
self.init_logger()
def init_logger(self):
"""
Initializes logger settings.
"""
self.logger = logging.getLogger()
formatter = logging.Formatter(self.logging_format)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
self.logger.addHandler(stream_handler)
if self.__debug:
self.logger.setLevel(logging.DEBUG)
else:
self.logger.setLevel(logging.WARNING)
if self.__logging_file:
file_handler = logging.FileHandler(self.__logging_file)
file_handler.setFormatter(formatter)
self.logger.addFilter(file_handler)
@property
def logging_file(self):
return self.__logging_file
@logging_file.setter
def logging_file(self, value):
self.__logging_file = value
if self.__logging_file:
formater = logging.Formatter(self.logging_format)
file_handler = logging.FileHandler(self.__logging_file)
file_handler.setFormatter(formater)
self.logger.addHandler(file_handler)
@property
def debug(self):
return self.__debug
@debug.setter
def debug(self, value):
self.__debug = value
if self.__debug:
# if debug status is True, turn on debug logging
self.logger.setLevel(logging.DEBUG)
# turn on httplib debug
httplib.HTTPConnection.debuglevel = 1
else:
# if debug status is False, turn off debug logging,
# setting log level to default `logging.WARNING`
self.logger.setLevel(logging.WARNING)
def get_api_key_with_prefix(self, identifier):
"""
Gets API key (with prefix if set).
:param identifier: The identifier of apiKey.
:return: The token for api key authentication.
"""
if self.api_key.get(identifier) and self.api_key_prefix.get(identifier):
return self.api_key_prefix[identifier] + ' ' + self.api_key[identifier]
elif self.api_key.get(identifier):
return self.api_key[identifier]
def get_basic_auth_token(self):
"""
Gets basic auth header string.
:return: The token for basic HTTP authentication.
"""
return urllib3.util.make_headers(basic_auth=self.username + ':' + self.password)\
.get('authorization')
def auth_settings(self):
"""
Gets Auth Settings dict for api client.
:return: The Auth Settings information dict.
"""
return {
}
def to_debug_report(self):
"""
Gets the essential information for debugging.
:return: The report for debugging.
"""
return "Python SDK Debug Report:\n"\
"OS: {env}\n"\
"Python Version: {pyversion}\n"\
"Version of the API: v1\n"\
"SDK Package Version: 1.0.0".\
format(env=sys.platform, pyversion=sys.version)

111
magnum/common/pythonk8sclient/swagger_client/models/__init__.py

@ -1,111 +0,0 @@
from __future__ import absolute_import
# import models into model package
from .v1_node import V1Node
from .v1_persistent_volume_claim_list import V1PersistentVolumeClaimList
from .v1_object_field_selector import V1ObjectFieldSelector
from .v1_se_linux_options import V1SELinuxOptions
from .v1_container_state_running import V1ContainerStateRunning
from .v1_volume_mount import V1VolumeMount
from .v1_persistent_volume_claim_spec import V1PersistentVolumeClaimSpec
from .v1_gce_persistent_disk_volume_source import V1GCEPersistentDiskVolumeSource
from .v1_namespace_status import V1NamespaceStatus
from .v1_resource_quota_spec import V1ResourceQuotaSpec
from .v1_namespace_spec import V1NamespaceSpec
from .v1_persistent_volume import V1PersistentVolume
from .v1_persistent_volume_status import V1PersistentVolumeStatus
from .v1_endpoints_list import V1EndpointsList
from .v1_git_repo_volume_source import V1GitRepoVolumeSource
from .v1_capabilities import V1Capabilities
from .v1_node_condition import V1NodeCondition
from .v1_pod_template_list import V1PodTemplateList
from .v1_local_object_reference import V1LocalObjectReference
from .v1_resource_quota_status import V1ResourceQuotaStatus
from .v1_exec_action import V1ExecAction
from .v1_object_meta import V1ObjectMeta
from .api_patch import ApiPatch
from .v1_limit_range_spec import V1LimitRangeSpec
from .v1_iscsi_volume_source import V1ISCSIVolumeSource
from .v1_empty_dir_volume_source import V1EmptyDirVolumeSource
from .v1_node_list import V1NodeList
from .v1_persistent_volume_claim import V1PersistentVolumeClaim
from .v1_namespace_list import V1NamespaceList
from .v1_service_account import V1ServiceAccount
from .v1_node_address import V1NodeAddress
from .v1_namespace import V1Namespace
from .v1_list_meta import V1ListMeta
from .v1_persistent_volume_claim_volume_source import V1PersistentVolumeClaimVolumeSource
from .v1_persistent_volume_claim_status import V1PersistentVolumeClaimStatus
from .v1_resource_quota_list import V1ResourceQuotaList
from .v1_endpoint_subset import V1EndpointSubset
from .v1_secret_volume_source import V1SecretVolumeSource
from .v1_env_var_source import V1EnvVarSource
from .v1_load_balancer_ingress import V1LoadBalancerIngress
from .v1_service import V1Service
from .v1_service_account_list import V1ServiceAccountList
from .v1_limit_range_list import V1LimitRangeList
from .v1_endpoints import V1Endpoints
from .v1_delete_options import V1DeleteOptions
from .v1_volume import V1Volume
from .v1_probe import V1Probe
from .v1_capability import V1Capability
from .v1_replication_controller import V1ReplicationController
from .v1_limit_range import V1LimitRange
from .v1_pod_status import V1PodStatus
from .v1_pod_spec import V1PodSpec
from .v1_container_port import V1ContainerPort
from .v1_event_list import V1EventList
from .v1_resource_quota import V1ResourceQuota
from .v1_lifecycle import V1Lifecycle
from .v1_node_status import V1NodeStatus
from .v1_glusterfs_volume_source import V1GlusterfsVolumeSource
from .v1_handler import V1Handler
from .v1_replication_controller_spec import V1ReplicationControllerSpec
from .v1_event_source import V1EventSource
from .v1_status_cause import V1StatusCause
from .v1_pod_condition import V1PodCondition
from .v1_rbd_volume_source import V1RBDVolumeSource
from .v1_status import V1Status
from .v1_pod_template import V1PodTemplate
from .v1_service_status import V1ServiceStatus
from .v1_nfs_volume_source import V1NFSVolumeSource
from .v1_endpoint_port import V1EndpointPort
from .v1_tcp_socket_action import V1TCPSocketAction
from .v1_http_get_action import V1HTTPGetAction
from .v1_status_details import V1StatusDetails
from .v1_load_balancer_status import V1LoadBalancerStatus
from .v1_secret_list import V1SecretList
from .v1_container import V1Container
from .v1_persistent_volume_spec import V1PersistentVolumeSpec
from .v1_replication_controller_status import V1ReplicationControllerStatus
from .v1_finalizer_name import V1FinalizerName
from .v1_service_port import V1ServicePort
from .v1_component_condition import V1ComponentCondition
from .v1_component_status_list import V1ComponentStatusList
from .v1_host_path_volume_source import V1HostPathVolumeSource
from .json_watch_event import JsonWatchEvent
from .v1_binding import V1Binding
from .v1_container_state_terminated import V1ContainerStateTerminated
from .v1_security_context import V1SecurityContext
from .v1_container_state import V1ContainerState
from .v1_aws_elastic_block_store_volume_source import V1AWSElasticBlockStoreVolumeSource
from .v1_container_status import V1ContainerStatus
from .v1_replication_controller_list import V1ReplicationControllerList
from .v1_secret import V1Secret
from .v1_event import V1Event
from .v1_env_var import V1EnvVar
from .v1_resource_requirements import V1ResourceRequirements
from .v1_persistent_volume_access_mode import V1PersistentVolumeAccessMode
from .v1_component_status import V1ComponentStatus
from .v1_limit_range_item import V1LimitRangeItem
from .v1_pod_template_spec import V1PodTemplateSpec
from .v1_pod_list import V1PodList
from .v1_service_list import V1ServiceList
from .v1_persistent_volume_list import V1PersistentVolumeList
from .v1_object_reference import V1ObjectReference
from .v1_container_state_waiting import V1ContainerStateWaiting
from .v1_node_system_info import V1NodeSystemInfo
from .v1_service_spec import V1ServiceSpec
from .v1_pod import V1Pod
from .v1_node_spec import V1NodeSpec
from .v1_endpoint_address import V1EndpointAddress

76
magnum/common/pythonk8sclient/swagger_client/models/api_patch.py

@ -1,76 +0,0 @@
# coding: utf-8
"""
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from pprint import pformat
from six import iteritems
class ApiPatch(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self):
"""
Swagger model
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
}
self.attribute_map = {
}
def to_dict(self):
"""
Return model properties dict
"""
result = {}
for attr, _ in iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
else:
result[attr] = value
return result
def to_str(self):
"""
Return model properties str
"""
return pformat(self.to_dict())
def __repr__(self):
"""
For `print` and `pprint`
"""
return self.to_str()

124
magnum/common/pythonk8sclient/swagger_client/models/json_watch_event.py

@ -1,124 +0,0 @@
# coding: utf-8
"""
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from pprint import pformat
from six import iteritems
class JsonWatchEvent(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self):
"""
Swagger model
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
'type': 'str',
'object': 'str'
}
self.attribute_map = {
'type': 'type',
'object': 'object'
}
self._type = None
self._object = None
@property
def type(self):
"""
Gets the type of this JsonWatchEvent.
the type of watch event; may be ADDED, MODIFIED, DELETED, or ERROR
:return: The type of this JsonWatchEvent.
:rtype: str
"""
return self._type
@type.setter
def type(self, type):
"""
Sets the type of this JsonWatchEvent.
the type of watch event; may be ADDED, MODIFIED, DELETED, or ERROR
:param type: The type of this JsonWatchEvent.
:type: str
"""
self._type = type
@property
def object(self):
"""
Gets the object of this JsonWatchEvent.
the object being watched; will match the type of the resource endpoint or be a Status object if the type is ERROR
:return: The object of this JsonWatchEvent.
:rtype: str
"""
return self._object
@object.setter
def object(self, object):
"""
Sets the object of this JsonWatchEvent.
the object being watched; will match the type of the resource endpoint or be a Status object if the type is ERROR
:param object: The object of this JsonWatchEvent.
:type: str
"""
self._object = object
def to_dict(self):
"""
Return model properties dict
"""
result = {}
for attr, _ in iteritems(self.swagger_types):
value = getattr(self, attr)
if isinstance(value, list):
result[attr] = list(map(
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
value
))
elif hasattr(value, "to_dict"):
result[attr] = value.to_dict()
else:
result[attr] = value
return result
def to_str(self):
"""
Return model properties str
"""
return pformat(self.to_dict())
def __repr__(self):
"""
For `print` and `pprint`
"""
return self.to_str()

174
magnum/common/pythonk8sclient/swagger_client/models/v1_aws_elastic_block_store_volume_source.py

@ -1,174 +0,0 @@
# coding: utf-8
"""
Copyright 2015 SmartBear Software
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from pprint import pformat
from six import iteritems
class V1AWSElasticBlockStoreVolumeSource(object):
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually.
"""
def __init__(self):
"""
Swagger model
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
:param dict attributeMap: The key is attribute name
and the value is json key in definition.
"""
self.swagger_types = {
'volume_id': 'str',
'fs_type': 'str',
'partition': 'int',
'read_only': 'bool'
}
self.attribute_map = {
'volume_id': 'volumeID',
'fs_type': 'fsType',
'partition': 'partition',
'read_only': 'readOnly'
}
self._volume_id = None
self._fs_type = None
self._partition = None
self._read_only = None
@property
def volume_id(self):
"""
Gets the volume_id of this V1AWSElasticBlockStoreVolumeSource.
unique id of the PD resource in AWS; see http://releases.k8s.io/v1.0.4/docs/volumes.md#awselasticblockstore
:return: The volume_id of this V1AWSElasticBlockStoreVolumeSource.
:rtype: str
"""
return self._volume_id
@volume_id.setter
def volume_id(self, volume_id):
"""
Sets the volume_id of this V1AWSElasticBlockStoreVolumeSource.
unique id of the PD resource in AWS; see http://releases.k8s.io/v1.0.4/docs/volumes.md#awselasticblockstore
:param volume_id: The volume_id of this V1AWSElasticBlockStoreVolumeSource.
:type: str
"""
self._volume_id = volume_id
@property
def fs_type(self):
"""
Gets the fs_type of this V1AWSElasticBlockStoreVolumeSource.
file system type to mount, such as ext4, xfs, ntfs; see http://releases.k8s.io/v1.0.4/docs/volumes.md#awselasticblockstore
:return: The fs_type of this V1AWSElasticBlockStoreVolumeSource.
:rtype: str
"""
return self._fs_type
@fs_type.setter
def fs_type(self, fs_type):
"""
Sets the fs_type of this V1AWSElasticBlockStoreVolumeSource.