示例#1
0
    def match_expressions(self, me=None):
        if not is_valid_list(me, LabelSelectorRequirement):
            raise SyntaxError(
                'LabelSelector: match_expressions: [ {} ] is invalid.'.format(
                    me))

        self._match_expressions = me
示例#2
0
 def required_during_scheduling_ignored_during_execution(self, pats=None):
     # raise NotImplementedError('Not yet implemented in Kubernetes 1.6')
     if not is_valid_list(pats, PodAffinityTerm):
         raise SyntaxError(
             'PodAffinity: required_during_scheduling_ignored_during_execution: [ {} ] is invald.'
             .format(pats))
     self._required_during_scheduling_ignored_during_execution = pats
示例#3
0
 def access_modes(self, modes=None):
     if not is_valid_list(modes, str):
         raise SyntaxError(
             'PersistentVolumeClaimStatus: access_modes: [ {} ] is invalid.'
             .format(modes))
     filtered = filter(
         lambda x: x in PersistentVolumeSpec.VALID_ACCESS_MODES, modes)
     self._access_modes = filtered
 def http_headers(self, headers=None):
     msg = 'HTTPGetAction: headers: [ {0} ] is invalid.'.format(headers)
     if not is_valid_list(headers, dict):
         raise SyntaxError(msg)
     for x in headers:
         if not is_valid_dict(x, ['name', 'value']):
             raise SyntaxError(msg)
     self._http_headers = headers
示例#5
0
 def external_ips(self, ips=None):
     msg = 'ServiceSpec: external_ips: [ {0} ] is invalid.'.format(ips)
     if not is_valid_list(ips, str):
         raise SyntaxError(msg)
     for ip in ips:
         if not is_reachable(ip):
             raise SyntaxError(msg)
     self._external_ips = ips
示例#6
0
    def containers(self, containers=None):
        if not is_valid_list(containers, K8sContainer):
            raise SyntaxError(
                'K8sCronJob: containers: [ {} ] is invalid.'.format(containers))

        models = []
        for obj in containers:
            models.append(obj.model)
        self.model.spec.job_template.spec.template.spec.containers = models
示例#7
0
 def add_image_pull_secrets(self, secrets=None):
     if not is_valid_list(secrets, dict):
         raise SyntaxError('PodSpec.add_image_pull_secrets() secrets : [ {0} ] is invalid.'.format(secrets))
     s = self.image_pull_secrets
     if s is None:
         combined = secrets
     else:
         combined = s + secrets
     filtered = filter(lambda x: isinstance(x, dict), combined)
     self.image_pull_secrets = filtered
     return self
示例#8
0
    def add_image_pull_secrets(self, secrets=None):
        if not is_valid_list(secrets, dict):
            raise SyntaxError('PodSpec.add_image_pull_secrets() secrets : [ {0} ] is invalid.'.format(secrets))

        s = self.image_pull_secrets
        if s is None:
            l = secrets
        else:
            l = s + secrets

        self.image_pull_secrets = [dict(t) for t in set([tuple(d.items()) for d in l])]
        return self
示例#9
0
    def add_image_pull_secrets(self, secrets=None):
        if not is_valid_list(secrets, dict):
            raise SyntaxError('PodSpec.add_image_pull_secrets() secrets : [ {0} ] is invalid.'.format(secrets))

        s = self.image_pull_secrets
        if s is None:
            l = secrets
        else:
            l = s + secrets

        self.image_pull_secrets = [dict(t) for t in set([tuple(d.items()) for d in l])]
        return self
示例#10
0
 def values(self, v=None):
     if not is_valid_list(convert(v), str):
         raise SyntaxError(
             'NodeSelectorRequirement: values: [ {} ] is invalid.'.format(v))
     if self.operator in ['In, NotIn'] and v == []:
         raise SyntaxError(
             'NodeSelectorRequirement: values: [ {} ] cannot be empty, if operator in [ "In", "NotIn" ]'.format(v))
     if self.operator in ['Exists', 'NotExists'] and v != []:
         raise SyntaxError(
             'NodeSelectorRequirement: values: [ {} ] must be empty, if operator in [ "Exists", "NotExists" ]'.format(v))
     if self.operator in ['Gt', 'Lt']:
         if len(v) != 1:
             raise SyntaxError(
                 'NodeSelectorRequirement: values: [ {} ] must be an array of length 1, if operator in [ "Gt", "Lt" ]'.format(v))
         if not isinstance(v[0], int):
             raise SyntaxError(
                 'NodeSelectorRequirement: values: [ {} ] must contain a single integer, if operator in [ "Gt", "Lt" ]'.format(v))
     self._values = v
 def access_modes(self, modes=None):
     if not is_valid_list(modes, str):
         raise SyntaxError('PersistentVolumeClaimStatus: access_modes: [ {} ] is invalid.'.format(modes))
     filtered = list(filter(lambda x: x in PersistentVolumeSpec.VALID_ACCESS_MODES, modes))
     self._access_modes = filtered
示例#12
0
 def namespaces(self, n=None):
     if not is_valid_list(convert(n), str):
         raise SyntaxError(
             'PodAffinityTerm: namespaces: [ {} ] is invalid.'.format(n))
     self._namespaces = n
示例#13
0
 def items(self, items=None):
     if not is_valid_list(items, KeyToPath):
         raise SyntaxError('SecretVolumeSource: items: [ {0} ] is invalid.'.format(items))
     self._items = items
示例#14
0
 def ingress(self, ingress=None):
     if not is_valid_list(ingress, LoadBalancerIngress):
         raise SyntaxError('LoadBalancerStatus: ingress: [ {0} ] is invalid.'.format(ingress))
     self._ingress = ingress
示例#15
0
 def volume_mounts(self, mounts=None):
     if not is_valid_list(mounts, VolumeMount):
         raise SyntaxError('Container: volume_mounts: [ {0} ] is invalid.'.format(mounts))
     self._volume_mounts = mounts
示例#16
0
 def args(self, args=None):
     if not is_valid_list(args, str):
         raise SyntaxError('Container: args: [ {0} ] is invalid.'.format(args))
     self._args = args
示例#17
0
 def tolerations(self, t=None):
     if not is_valid_list(t, Toleration):
         raise SyntaxError('PodSpec: tolerations: [ {} ] is invalid.'.format(t))
     self._tolerations = t
示例#18
0
 def image_pull_secrets(self, secrets=None):
     if not is_valid_list(secrets, dict):
         raise SyntaxError('PodSpec: image_pull_secrets: [ {0} ] is invalid.'.format(secrets))
     self._image_pull_secrets = secrets
示例#19
0
 def containers(self, containers=None):
     if not is_valid_list(containers, Container):
         raise SyntaxError('PodSpec: containers: [ {0} ] is invalid.'.format(containers))
     self._containers = containers
示例#20
0
 def volume_claim_templates(self, vcts=None):
     if not is_valid_list(vcts, PersistentVolumeClaim):
         raise SyntaxError('StatefulSetSpec: volume_claim_templates: [ {} ] is invalid.'.format(vcts))
     self._volume_claim_templates = vcts
示例#21
0
 def ports(self, ports=None):
     if not is_valid_list(ports, ServicePort):
         raise SyntaxError(
             'ServiceSpec: ports: [ {0} ] is invalid.'.format(ports))
     self._ports = ports
示例#22
0
 def env(self, env=None):
     if not is_valid_list(env, EnvVar):
         raise SyntaxError(
             "Container: env: [ {0} ] is invalid.".format(env))
     self._env = env
示例#23
0
 def volumes(self, volumes=None):
     if not is_valid_list(volumes, Volume):
         raise SyntaxError('PodSpec: volumes: [ {0} ] is invalid.'.format(volumes))
     self._volumes = volumes
示例#24
0
 def volume_mounts(self, mounts=None):
     if not is_valid_list(mounts, VolumeMount):
         raise SyntaxError(
             'Container: volume_mounts: [ {0} ] is invalid.'.format(mounts))
     self._volume_mounts = mounts
示例#25
0
 def tolerations(self, t=None):
     if not is_valid_list(t, Toleration):
         raise SyntaxError(
             'PodSpec: tolerations: [ {} ] is invalid.'.format(t))
     self._tolerations = t
示例#26
0
 def env(self, env=None):
     if not is_valid_list(env, EnvVar):
         raise SyntaxError("Container: env: [ {0} ] is invalid.".format(env))
     self._env = env
示例#27
0
 def secrets(self, s=None):
     if not is_valid_list(s, ObjectReference):
         raise SyntaxError(
             'ServiceAccount: secrets: [ {} ] is invalid.'.format(s))
     self._secrets = s
示例#28
0
 def preferred_during_scheduling_ignored_during_execution(self, p=None):
     if not is_valid_list(p, PreferredSchedulingTerm):
         raise SyntaxError(
             'NodeAffinity: preferred_during_scheduling_ignored_during_execution: [ {} ] is invalid.'.format(p))
     self._preferred_during_scheduling_ignored_during_execution = p
示例#29
0
 def image_pull_secrets(self, s=None):
     if not is_valid_list(s, LocalObjectReference):
         raise SyntaxError(
             'ServiceAccount: image_pull_secrets: [ {} ] is invalid.'.
             format(s))
     self._image_pull_secrets = s
示例#30
0
 def conditions(self, conds=None):
     if not is_valid_list(conds, JobCondition):
         raise SyntaxError('JobStatus: conditions: [ {} ] is invalid.'.format(conds))
     self._conditions = conds
示例#31
0
 def taints(self, t=None):
     if not is_valid_list(t, Taint):
         raise SyntaxError('NodeSpec: taints: [ {} ] is invalid.'.format(t))
     self._taints = t
示例#32
0
 def conditions(self, conds=None):
     if not is_valid_list(conds, JobCondition):
         raise SyntaxError('JobStatus: conditions: [ {} ] is invalid.'.format(conds))
     self._conditions = conds
示例#33
0
 def items(self, i=None):
     if not is_valid_list(target=i, element_class=Node):
         raise SyntaxError('NodeList: items: [ {0} ] is invalid.'.format(i))
     self._items = i
示例#34
0
 def taints(self, t=None):
     if not is_valid_list(t, Taint):
         raise SyntaxError('K8sNode: taints: [ {} ] is invalid.'.format(t))
     self.model.spec.taints = t
示例#35
0
 def args(self, args=None):
     if not is_valid_list(args, str):
         raise SyntaxError(
             'Container: args: [ {0} ] is invalid.'.format(args))
     self._args = args
示例#36
0
 def add(self, a=None):
     if not is_valid_list(a, str):
         raise SyntaxError('Capabilities: add: [ {} ] is invalid.'.format(a))
     self._add = a
示例#37
0
 def volumes(self, v=None):
     if not is_valid_list(v, K8sVolume):
         self.model.spec.template.spec.volumes = v
示例#38
0
 def namespaces(self, n=None):
     if not is_valid_list(convert(n), str):
         raise SyntaxError('PodAffinityTerm: namespaces: [ {} ] is invalid.'.format(n))
     self._namespaces = n
示例#39
0
 def drop(self, d=None):
     if not is_valid_list(d, str):
         raise SyntaxError('Capabilities: add: [ {} ] is invalid.'.format(d))
     self._drop = d
示例#40
0
 def containers(self, containers=None):
     if not is_valid_list(containers, K8sContainer):
         self.model.spec.containers = [x.model for x in containers]
示例#41
0
 def items(self, i=None):
     if not is_valid_list(target=i, element_class=Node):
         raise SyntaxError('NodeList: items: [ {0} ] is invalid.'.format(i))
     self._items = i
示例#42
0
 def command(self, command=None):
     if not is_valid_list(command, str):
         raise SyntaxError(
             'Container: command: [ {0} ] is invalid.'.format(command))
     self._command = command
示例#43
0
 def containers(self, containers=None):
     if not is_valid_list(containers, Container):
         raise SyntaxError('PodSpec: containers: [ {0} ] is invalid.'.format(containers))
     self._containers = containers
示例#44
0
 def ports(self, ports=None):
     if not is_valid_list(ports, ContainerPort):
         raise SyntaxError(
             'Container: ports: [ {0} ] is invalid.'.format(ports))
     self._ports = ports
示例#45
0
 def image_pull_secrets(self, secrets=None):
     if not is_valid_list(secrets, dict):
         raise SyntaxError('PodSpec: image_pull_secrets: [ {0} ] is invalid.'.format(secrets))
     self._image_pull_secrets = secrets
示例#46
0
 def containers(self, containers=None):
     if not is_valid_list(containers, K8sContainer):
         self.model.spec.containers = [x.model for x in containers]
示例#47
0
 def volumes(self, volumes=None):
     if not is_valid_list(volumes, Volume):
         raise SyntaxError('PodSpec: volumes: [ {0} ] is invalid.'.format(volumes))
     self._volumes = volumes
示例#48
0
 def command(self, command=None):
     if not is_valid_list(command, str):
         raise SyntaxError('Container: command: [ {0} ] is invalid.'.format(command))
     self._command = command
示例#49
0
 def volume_claim_templates(self, t=None):
     if not is_valid_list(t, PersistentVolumeClaim):
         raise SyntaxError('PetSetSpec: volume_claim_templates: [ {} ] is invalid.'.format(t))
     self._volume_claim_templates = t
示例#50
0
 def ports(self, ports=None):
     if not is_valid_list(ports, ContainerPort):
         raise SyntaxError('Container: ports: [ {0} ] is invalid.'.format(ports))
     self._ports = ports
 def volume_claim_templates(self, vcts=None):
     if not is_valid_list(vcts, PersistentVolumeClaim):
         raise SyntaxError(
             'StatefulSetSpec: volume_claim_templates: [ {} ] is invalid.'.
             format(vcts))
     self._volume_claim_templates = vcts
示例#52
0
 def supplemental_groups(self, gids=None):
     if not is_valid_list(gids, int):
         raise SyntaxError(
             'PodSecurityContext: supplemental_groups: [ {0} ] is invalid.'.
             format(gids))
     self._supplemental_groups = gids
示例#53
0
 def volumes(self, v=None):
     if not is_valid_list(v, K8sVolume):
         self.model.spec.template.spec.volumes = v
示例#54
0
 def supplemental_groups(self, gids=None):
     if not is_valid_list(gids, int):
         raise SyntaxError('PodSecurityContext: supplemental_groups: [ {0} ] is invalid.'.format(gids))
     self._supplemental_groups = gids
 def values(self, v=None):
     if not is_valid_list(v, str):
         raise SyntaxError('LabelSelectorRequirements: values: [ {} ] is invalid.'.format(v))
     self._values = v