Exemplo n.º 1
0
 def cluster_update(nodes):
     cluster.set_cluster_nodes(nodes)
     factory = DaemonFactory()
     daemon = factory.load(daemon_name)
     network_name = daemon.network
     daemon.cluster = [n['networks'][network_name] for n in nodes]
     factory.save(daemon)
Exemplo n.º 2
0
    def save(self, daemon):
        """
        Saves a daemon to the local storage. The daemon is stored in json
        format and contains all daemon properties.

        :param daemon: The daemon instance to save.
        :type daemon: cloudify_agent.api.daemon.base.Daemon

        """
        if not os.path.exists(self.storage):
            os.makedirs(self.storage)
        daemon_path = os.path.join(self.storage,
                                   '{0}.json'.format(daemon.name))
        cluster_path = os.path.join(self.storage,
                                    'cluster-{0}.json'.format(daemon.name))
        daemon.cluster_settings_path = cluster_path

        if getattr(daemon, 'cluster', None):
            # .set_cluster_nodes will normalize the nodes representation,
            # so let's store the normalized version
            nodes = cluster_settings.set_cluster_nodes(daemon.cluster,
                                                       filename=cluster_path)
            daemon.cluster = nodes

        self.logger.debug(
            'Saving daemon configuration at: {0}'.format(daemon_path))
        with open(daemon_path, 'w') as f:
            props = utils.internal.daemon_to_dict(daemon)
            json.dump(props, f, indent=2)
            f.write(os.linesep)
Exemplo n.º 3
0
    def save(self, daemon):

        """
        Saves a daemon to the local storage. The daemon is stored in json
        format and contains all daemon properties.

        :param daemon: The daemon instance to save.
        :type daemon: cloudify_agent.api.daemon.base.Daemon

        """
        if not os.path.exists(self.storage):
            os.makedirs(self.storage)
        daemon_path = os.path.join(
            self.storage, '{0}.json'.format(
                daemon.name)
        )
        cluster_path = os.path.join(
            self.storage, 'cluster-{0}.json'.format(
                daemon.name)
        )
        daemon.cluster_settings_path = cluster_path

        if getattr(daemon, 'cluster', None):
            # .set_cluster_nodes will normalize the nodes representation,
            # so let's store the normalized version
            nodes = cluster_settings.set_cluster_nodes(daemon.cluster,
                                                       filename=cluster_path)
            daemon.cluster = nodes

        self.logger.debug('Saving daemon configuration at: {0}'
                          .format(daemon_path))
        with open(daemon_path, 'w') as f:
            props = utils.internal.daemon_to_dict(daemon)
            json.dump(props, f, indent=2)
            f.write(os.linesep)
Exemplo n.º 4
0
 def cluster_update(nodes):
     cluster.set_cluster_nodes(nodes)
     factory = DaemonFactory()
     daemon = factory.load(daemon_name)
     daemon.cluster = nodes
     factory.save(daemon)