Пример #1
0
    def write_kubeconfig(self, config):
        """
        Write config to disk.
        OK if the file doesn't exist.

        :param config: The kubeconfig to write
        :type config: Kubeconfig

        :raises KubeconfigInaccessableError: if the kubeconfig
        can't be opened for writing
        """
        directory = os.path.dirname(config.path)

        try:
            os.makedirs(directory)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise KubeconfigInaccessableError(
                    "Can't create directory for writing: {0}".format(e))
        try:
            with open(config.path, "w+") as stream:
                ordered_yaml_dump(config.content, stream)
        except IOError as e:
            raise KubeconfigInaccessableError(
                "Can't open kubeconfig for writing: {0}".format(e))
Пример #2
0
    def write_kubeconfig(self, config):
        """
        Write config to disk.
        OK if the file doesn't exist.

        :param config: The kubeconfig to write
        :type config: Kubeconfig

        :raises KubeconfigInaccessableError: if the kubeconfig
        can't be opened for writing
        """
        directory = os.path.dirname(config.path)

        try:
            os.makedirs(directory)
        except OSError as e:
            if e.errno != errno.EEXIST:
                raise KubeconfigInaccessableError(
                        "Can't create directory for writing: {0}".format(e))
        try:
            with open(config.path, "w+") as stream:
                ordered_yaml_dump(config.content, stream)
        except IOError as e:
            raise KubeconfigInaccessableError(
                "Can't open kubeconfig for writing: {0}".format(e))
Пример #3
0
    def _display_entries(self, entries):
        """ 
        Display entries in yaml format

        :param entries: a list of OrderedDicts to be printed
        :type entries: list
        """
        uni_print("Entries:\n\n")
        for entry in entries:
            uni_print(ordered_yaml_dump(entry))
            uni_print("\n")
Пример #4
0
    def _display_entries(self, entries):
        """
        Display entries in yaml format

        :param entries: a list of OrderedDicts to be printed
        :type entries: list
        """
        uni_print("Entries:\n\n")
        for entry in entries:
            uni_print(ordered_yaml_dump(entry))
            uni_print("\n")
Пример #5
0
 def dump_content(self):
     """ Return the stored content in yaml format. """
     return ordered_yaml_dump(self.content)
Пример #6
0
 def dump_content(self):
     """ Return the stored content in yaml format. """
     return ordered_yaml_dump(self.content)