示例#1
0
def test_get_pods_for_ns_in_yaml(self, namespace):
    print("started")
    ret = PodsClient().get_pods_for_all_namespaces()
    result_list = ret.items()
    with open(r'.\\test-output\pods.yml', 'w') as outfile:
        yaml.dump(result_list, outfile, default_flow_style=False)
    print("completed")
示例#2
0
 def get_pods_replicas(self, namespace):
     ret = PodsClient().get_pods_for_namespace(namespace)
     result_list = ret.items()
     with open(r'.\\test-output\pods_details.yml', 'w') as outfile:
         yaml.dump(result_list, outfile, default_flow_style=False)
     print("completed")
     return ReadYAML().read_yaml('.\\test-output\pods_details.yml',
                                 'Replicas')
示例#3
0
 def get_deployment_info(self):
     print("reading yaml file")
     inputfile = "/root/kube_client/testdata/input.yaml"
     kind = ReadYAML.read_yaml(self, inputfile, ["kind"])
     name = ReadYAML.read_yaml(self, inputfile, ["metadata", "name"])
     namespace1 = ReadYAML.read_yaml(self, inputfile,
                                     ["metadata", "namespace"])
     print("printing all returned values", kind, name, namespace1)
     response = PodsClient.list_namespaced_deployment(namespace=namespace1)
     response = PodsClient.list_namespaced_deployment(
         namespace="kube-system")
     #        response = PodsClient.get_deployments_for_namespace(namespace1)
     return (response.items)
示例#4
0
 def get_pod_replicas(self, simple_deployment):
     print("simple deployment", simple_deployment)
     response = PodsClient.get_pods_for_namespace(self, 'default')
     replicas = 0
     for res in response:
         print(res.metadata.name)
         if res.metadata.name == "coredns":
             print(res.spec.replicas)
             replicas = res.spec.replicas
         return replicas
示例#5
0
 def get_deployments_replicas_for_pod(self):
     response = PodsClient.list_namespaced_deployment(namespace="kube-system")
     #    print(model.items[0].metadata.name)
     replicas = 0
     for res in response:
         print(res.metadata.name)
         if res.metadata.name == "coredns":
             print(res.spec.replicas)
             replicas = res.spec.replicas
     return replicas
    def test_pod_replicas_deployment(self,simple_deployment):
        print("simple deployment",simple_deployment)
        key_items = ["spec","replicas"]
        for key in simple_deployment.keys():
           ret = docs
           if(key == key_items[0]):
               print("printing value for given key",key_items[0])
               for key_item in key_items:
                   ret = ret[key_item]
                   print(ret)
               return(ret)

        response = PodsClient.get_pods_for_namespace(self,'default')
        replicas = 0
        for res in response:
            print(res.metadata.name)
            if res.metadata.name == "coredns":
                print(res.spec.replicas)
                replicas = res.spec.replicas
            return replicas
示例#7
0
 def get_namespaces_pods_info(self, namespace):
     model = PodsClient.get_pods_for_namespace(namespace)
     #    print(model.items[0].metadata.name)
     return model.items