def dependencies(self, project, auth):
     dependencies = []
     for dependency in self.tasks.get('dependencies', []):
         resource_name, params = list(dependency.items())[0]
         api, api_version, kind = resource_name.split('_')
         if api == 'k8s':
             ansible_helper = KubernetesAnsibleModuleHelper(
                 api_version, kind, debug=True, reset_logfile=False, **auth)
         else:
             ansible_helper = OpenShiftAnsibleModuleHelper(
                 api_version, kind, debug=True, reset_logfile=False, **auth)
         if params.get('namespace'):
             params['namespace'] = project
         name = params.get('name')
         request_body = ansible_helper.request_body_from_params(params)
         dependencies.append(
             (name, project,
              ansible_helper.create_object(project, body=request_body)))
     try:
         yield dependencies
     finally:
         for name, namespace, dependency in dependencies:
             try:
                 ansible_helper.delete_object(name, namespace)
             except KubernetesException:
                 pass
def namespace(auth):
    name = "test-{}".format(uuid.uuid4())

    helper = KubernetesAnsibleModuleHelper('v1', 'namespace', debug=True, reset_logfile=False, **auth)

    k8s_obj = helper.create_object(V1Namespace(metadata=V1ObjectMeta(name=name)))
    assert k8s_obj is not None

    yield name

    helper.delete_object(name, None)
def namespace(kubeconfig):
    name = "test-{}".format(uuid.uuid4())

    auth = {}
    if kubeconfig is not None:
        auth = {
            'kubeconfig': str(kubeconfig),
            'host': 'https://localhost:8443',
            'verify_ssl': False
        }
    helper = KubernetesAnsibleModuleHelper('v1', 'namespace', debug=True, reset_logfile=False, **auth)

    k8s_obj = helper.create_object(V1Namespace(metadata=V1ObjectMeta(name=name)))
    assert k8s_obj is not None

    yield name

    helper.delete_object(name, None)