diff options
author | Miroslav Los <miroslav.los@pantheon.tech> | 2019-11-26 14:20:36 +0100 |
---|---|---|
committer | Miroslav Los <miroslav.los@pantheon.tech> | 2019-11-26 19:24:24 +0100 |
commit | 01a60ff23b979eb676658713748598ba4892163a (patch) | |
tree | 1fb1b260c3723ddc42f047796db6b1928171b48c /k8s/k8sclient | |
parent | 77e27adeab5ff155b690f2e058c06f0a7812e225 (diff) |
Support python3 in all plugins
Unify tox/requirements/setup.py requirement specifications.
Do not set upper version limits if possible.
Drop uuid as dependency included with standard library.
Drop import of unmaintained cloudify_importer without python3 version.
Use PEP 508 URLs in requirements for non-PyPI (github) releases.
Use cloudify-common 5 release; pre-release package for python3.
Rewrite uses of map with loops/comprehensions.
Signed-off-by: Miroslav Los <miroslav.los@pantheon.tech>
Issue-ID: DCAEGEN2-1956
Change-Id: I7b3ceb97a628e3af5bda3178d182f4207069e86d
Diffstat (limited to 'k8s/k8sclient')
-rw-r--r-- | k8s/k8sclient/k8sclient.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/k8s/k8sclient/k8sclient.py b/k8s/k8sclient/k8sclient.py index 9a01536..323a208 100644 --- a/k8s/k8sclient/k8sclient.py +++ b/k8s/k8sclient/k8sclient.py @@ -2,6 +2,7 @@ # org.onap.dcae # ================================================================================ # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2019 Pantheon.tech. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -136,7 +137,7 @@ def _create_resources(resources=None): def _create_container_object(name, image, always_pull, env={}, container_ports=[], volume_mounts = [], resources = None, readiness = None, liveness = None): # Set up environment variables # Copy any passed in environment variables - env_vars = [client.V1EnvVar(name=k, value=env[k]) for k in env.keys()] + env_vars = [client.V1EnvVar(name=k, value=env[k]) for k in env] # Add POD_IP with the IP address of the pod running the container pod_ip = client.V1EnvVarSource(field_ref = client.V1ObjectFieldSelector(field_path="status.podIP")) env_vars.append(client.V1EnvVar(name="POD_IP",value_from=pod_ip)) @@ -517,7 +518,7 @@ def deploy(namespace, component_name, image, replicas, always_pull, k8sconfig, r if port_map: service_ports = [] # Ports exposed internally on the k8s network exposed_ports = [] # Ports to be mapped to ports on the k8s nodes via NodePort - for (cport, proto), hport in port_map.iteritems(): + for (cport, proto), hport in port_map.items(): service_ports.append(client.V1ServicePort(port=int(cport),protocol=proto,name="port-{0}-{1}".format(proto[0].lower(), cport))) if int(hport) != 0: exposed_ports.append(client.V1ServicePort(port=int(cport),protocol=proto,node_port=int(hport),name="xport-{0}-{1}".format(proto[0].lower(),cport))) @@ -660,8 +661,6 @@ def execute_command_in_deployment(deployment_description, command): field_selector = "status.phase=Running" ).items] - def do_execute(pod_name): - return _execute_command_in_pod(location, namespace, pod_name, command) - # Execute command in the running pods - return map(do_execute, pod_names) + return [_execute_command_in_pod(location, namespace, pod_name, command) + for pod_name in pod_names] |