示例#1
0
def main():
    args = ArgParse.arg_parse()
    # args is [u, verbose, ns, l, format, silent]
    logger = Logger.get_logger(args.format, args.silent)
    if args:
        call_all(args.verbose, args.namespace, args.logging, logger)
        k8s.Output.time_taken(start_time)   
def main():
    urllib3.disable_warnings()
    args = ArgParse.arg_parse()
    # [help, action, body, format, kubeconfig, object_name, \
    # namespace, object, status, dryrun, loglevel, log_output_format]
    logger = Logger.get_logger(args.output, args.loglevel)
    k8s_config = KubeConfig.load_kube_config(args.output, \
                                logger, args.kubeconfig)
    if args.body:
        if 'json' in args.input:
            body = json.load(args.body[0])
        elif 'yaml' in args.input:
            body = yaml.load(args.body[0], yaml.Loader)
        else:
            logger.warning("Invalid format of patch body passed")
    else:
        body = ''
    call = MantaRay(logger, k8s_config, args.output)
    call.pod_crud_operations(args)
示例#3
0
import unittest
import warnings
from modules.logging import Logger

logger = Logger.get_logger('', '')


class TestK8sClusterChecker(unittest.TestCase):
    def test_cluster(self):
        import cluster as cluster
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        self.assertRaises(TypeError, cluster.call_all(True, True, logger),
                          True)
        with self.assertRaises(Exception) as x:
            print("Exception ignored: {}".format(x.exception))

    def test_nodes(self):
        import nodes as nodes
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")
        with self.assertRaises(Exception) as x:
            print("Exception ignored: {}".format(x.exception))

    def test_namespace(self):
        import namespace as namespace
        warnings.filterwarnings("ignore",
                                category=ResourceWarning,
                                message="unclosed.*<ssl.SSLSocket.*>")