def run(self, name, namespace, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('readAppsV1beta1NamespacedStatefulSetStatus',
                               **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #2
0
    def run(self, body, name, namespace, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'patchPolicyV1beta1NamespacedPodDisruptionBudget', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #3
0
    def run(self,
            config_override=None,
            fieldSelector=None,
            labelSelector=None,
            resourceVersion=None,
            timeoutSeconds=None,
            watch=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if config_override is not None:
            args['config_override'] = config_override
        if fieldSelector is not None:
            args['fieldSelector'] = fieldSelector
        if labelSelector is not None:
            args['labelSelector'] = labelSelector
        if resourceVersion is not None:
            args['resourceVersion'] = resourceVersion
        if timeoutSeconds is not None:
            args['timeoutSeconds'] = timeoutSeconds
        if watch is not None:
            args['watch'] = watch
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'deleteExtensionsV1beta1CollectionThirdPartyResource', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #4
0
    def run(self, body, name, namespace, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'createExtensionsV1beta1NamespacedDeploymentRollbackRollback',
            **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #5
0
    def run(self, body, name, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('patchCoreV1PersistentVolumeStatus', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #6
0
    def run(self, body, name, namespace, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('replaceCoreV1NamespacedReplicationController',
                               **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self, body, name, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'patchRbacAuthorizationV1alpha1ClusterRoleBinding', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self, body, namespace, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'createAuthorizationV1beta1NamespacedLocalSubjectAccessReview',
            **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #9
0
    def run(
            self,
            name,
            config_override=None,
            exact=None,
            export=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if exact is not None:
            args['exact'] = exact
        if export is not None:
            args['export'] = export
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'readCertificatesV1alpha1CertificateSigningRequest',
            **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self,
            config_override=None,
            fieldSelector=None,
            labelSelector=None,
            resourceVersion=None,
            timeoutSeconds=None,
            watch=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if config_override is not None:
            args['config_override'] = config_override
        if fieldSelector is not None:
            args['fieldSelector'] = fieldSelector
        if labelSelector is not None:
            args['labelSelector'] = labelSelector
        if resourceVersion is not None:
            args['resourceVersion'] = resourceVersion
        if timeoutSeconds is not None:
            args['timeoutSeconds'] = timeoutSeconds
        if watch is not None:
            args['watch'] = watch
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'listRbacAuthorizationV1alpha1ClusterRoleBinding', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self,
            body,
            name,
            config_override=None,
            gracePeriodSeconds=None,
            orphanDependents=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if gracePeriodSeconds is not None:
            args['gracePeriodSeconds'] = gracePeriodSeconds
        if orphanDependents is not None:
            args['orphanDependents'] = orphanDependents
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('deleteCoreV1PersistentVolume', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self,
            name,
            namespace,
            config_override=None,
            exact=None,
            export=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if exact is not None:
            args['exact'] = exact
        if export is not None:
            args['export'] = export
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('readCoreV1NamespacedResourceQuota', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(self,
            config_override=None,
            fieldSelector=None,
            labelSelector=None,
            pretty=None,
            resourceVersion=None,
            timeoutSeconds=None,
            watch=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if config_override is not None:
            args['config_override'] = config_override
        if fieldSelector is not None:
            args['fieldSelector'] = fieldSelector
        if labelSelector is not None:
            args['labelSelector'] = labelSelector
        if pretty is not None:
            args['pretty'] = pretty
        if resourceVersion is not None:
            args['resourceVersion'] = resourceVersion
        if timeoutSeconds is not None:
            args['timeoutSeconds'] = timeoutSeconds
        if watch is not None:
            args['watch'] = watch
        resp = myk8s.runAction('listCoreV1EndpointsForAllNamespaces', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
    def run(
            self,
            name,
            namespace,
            config_override=None,
            container=None,
            follow=None,
            limitBytes=None,
            pretty=None,
            previous=None,
            sinceSeconds=None,
            sinceTime=None,
            tailLines=None,
            timestamps=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if name is not None:
            args['name'] = name
        else:
            return (False, "name is a required parameter")
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if container is not None:
            args['container'] = container
        if follow is not None:
            args['follow'] = follow
        if limitBytes is not None:
            args['limitBytes'] = limitBytes
        if pretty is not None:
            args['pretty'] = pretty
        if previous is not None:
            args['previous'] = previous
        if sinceSeconds is not None:
            args['sinceSeconds'] = sinceSeconds
        if sinceTime is not None:
            args['sinceTime'] = sinceTime
        if tailLines is not None:
            args['tailLines'] = tailLines
        if timestamps is not None:
            args['timestamps'] = timestamps
        resp = myk8s.runAction(
            'readCoreV1NamespacedPodLog',
            **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #15
0
    def run(self, ns, name):

        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl  = self.config.get('kubernetes_api_url')

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        resp = self.k8s.k8s[0].delete_namespaced_secret(deleteoptions, ns, name).to_dict()
        print json.dumps(resp, sort_keys=True, indent=2, default=self._json_serial)
Пример #16
0
    def run(self):

        self.env = self.config.get('environment')
        region = self.config.get('region')
        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl = self.config.get('kubernetes_api_url')

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)
        print json.dumps(self.k8s.k8s[0].list_namespace().to_dict(),
                         sort_keys=True,
                         indent=2,
                         default=self.json_serial)
Пример #17
0
    def run(self, config_override=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if config_override is not None:
            args['config_override'] = config_override
        resp = myk8s.runAction('getRbacAuthorizationAPIGroup', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #18
0
    def run(self, config_override=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if config_override is not None:
            args['config_override'] = config_override
        resp = myk8s.runAction('getBatchV1APIResources', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #19
0
    def run(self, ns, name):

        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl = self.config.get('kubernetes_api_url')

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        resp = self.k8s.k8s[0].read_namespaced_secret(ns, name).to_dict()
        datastr = json.dumps(resp,
                             sort_keys=True,
                             indent=2,
                             default=self._json_serial)
        data = json.loads(datastr)
        secret = data['data']

        print base64.decodestring(secret[name])
Пример #20
0
    def run(self, ns, name, value):

        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl = self.config.get('kubernetes_api_url')

        b64value = base64.encodestring(value)
        secretdata = {name: b64value}

        mysecret = secrettemplate
        mysecret['metadata']['name'] = name
        mysecret['metadata']['namespace'] = ns
        mysecret['data'] = secretdata

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        resp = self.k8s.k8s[0].create_namespaced_secret(mysecret, ns).to_dict()
Пример #21
0
    def run(
            self,
            namespace,
            config_override=None,
            fieldSelector=None,
            labelSelector=None,
            resourceVersion=None,
            timeoutSeconds=None,
            watch=None,
            pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if namespace is not None:
            args['namespace'] = namespace
        else:
            return (False, "namespace is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if fieldSelector is not None:
            args['fieldSelector'] = fieldSelector
        if labelSelector is not None:
            args['labelSelector'] = labelSelector
        if resourceVersion is not None:
            args['resourceVersion'] = resourceVersion
        if timeoutSeconds is not None:
            args['timeoutSeconds'] = timeoutSeconds
        if watch is not None:
            args['watch'] = watch
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction(
            'deleteCoreV1CollectionNamespacedPersistentVolumeClaim',
            **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #22
0
    def run(self, ns, **kwargs):

        self.env = self.config.get('environment')
        region = self.config.get('region')
        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl = self.config.get('kubernetes_api_url')

        myquotas = quotatemplate
        myspec = spectemplate

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        data = self.k8s.k8s[0].list_namespaced_resource_quota(ns).to_dict()
        quotacount = len(data['items'])

        if quotacount == 0:

            for key in myspec['spec']['hard']:
                if key in kwargs and kwargs[key] != None:
                    myspec['spec']['hard'][key] = kwargs[key]

            myquotas['metadata']['namespace'] = ns
            myquotas['spec'] = myspec['spec']

            print json.dumps(self.k8s.k8s[0].create_namespaced_resource_quota(
                myquotas, ns).to_dict(),
                             sort_keys=True,
                             indent=2,
                             default=self.json_serial)

        else:
            myspec = {'spec': {'hard': {}}}
            for key in kwargs:
                if kwargs[key] != None:
                    myspec['spec']['hard'][key] = kwargs[key]

            print json.dumps(self.k8s.k8s[0].patch_namespaced_resource_quota(
                myspec, ns, "quota").to_dict(),
                             sort_keys=True,
                             indent=2,
                             default=self.json_serial)
    def run(self, body, config_override=None, pretty=None):

        myk8s = k8s.K8sClient(self.config)

        rc = False

        args = {}
        if body is not None:
            args['body'] = body
        else:
            return (False, "body is a required parameter")
        if config_override is not None:
            args['config_override'] = config_override
        if pretty is not None:
            args['pretty'] = pretty
        resp = myk8s.runAction('createStorageV1beta1StorageClass', **args)

        if resp['status'] >= 200 and resp['status'] <= 299:
            rc = True

        return (rc, resp)
Пример #24
0
    def run(self, ns, label, action, **kwargs):
        """
        Entry into the action script

        """

        self.env = self.config.get('environment')
        region = self.config.get('region')
        k8suser = self.config.get('user')
        k8spass = self.config.get('password')
        k8surl = self.config.get('kubernetes_api_url')

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        if action == "remove":
            patch = {"metadata": {"labels": {label: None}}}
        elif action == "add":
            value = kwargs['data']
            patch = {"metadata": {"labels": {label: value}}}

        print json.dumps(self.k8s.k8s[0].patch_namespace(patch, ns).to_dict(),
                         sort_keys=True,
                         indent=2,
                         default=self.json_serial)
Пример #25
0
    def run(self, ns, suffix):
        """
        Entry into the action script

        :param str environment: bitesize cluster environment name
        :param str cluster: cluster to migrate to live (a or b)
        :param str region: aws region

        """

        self.env = self.config.get('environment')
        region   = self.config.get('region')
        k8suser  = self.config.get('user')
        k8spass  = self.config.get('password')
        k8surl   = self.config.get('kubernetes_api_url')

        self.ns = ns
        self.the_ns = "%s-%s" % (ns, suffix)

        self.createNSConfig()

        self.k8s = k8s.K8sClient(k8surl, k8suser, k8spass)

        print json.dumps(self.k8s.k8s[0].create_namespace(self.myconf).to_dict(), sort_keys=True, indent=2, default=self.json_serial)