Ejemplo n.º 1
0
  def patch(self, name, tfjob, namespace=None):
    """
    Patch existing tfjob
    :param name: existing tfjob name
    :param tfjob: patched tfjob
    :param namespace: defaults to current or default namespace
    :return: patched tfjob
    """
    if namespace is None:
      namespace = utils.set_tfjob_namespace(tfjob)

    try:
      outputs = self.custom_api.patch_namespaced_custom_object(
        constants.TFJOB_GROUP,
        constants.TFJOB_VERSION,
        namespace,
        constants.TFJOB_PLURAL,
        name,
        tfjob)
    except client.rest.ApiException as e:
      raise RuntimeError(
        "Exception when calling CustomObjectsApi->patch_namespaced_custom_object:\
         %s\n" % e)

    return outputs
Ejemplo n.º 2
0
    def create(self, tfjob, namespace=None):
        """
    Create the TFJob
    :param tfjob: tfjob object
    :param namespace: defaults to current or default namespace
    :return: created tfjob
    """

        if namespace is None:
            namespace = utils.set_tfjob_namespace(tfjob)

        try:
            outputs = self.api_instance.create_namespaced_custom_object(
                constants.TFJOB_GROUP, constants.TFJOB_VERSION, namespace,
                constants.TFJOB_PLURAL, tfjob)
        except client.rest.ApiException as e:
            raise RuntimeError(
                "Exception when calling CustomObjectsApi->create_namespaced_custom_object:\
         %s\n" % e)

        return outputs