Example #1
0
    def _create_node(
            self,
            name,
    ):
        utils.execute_command(
            command=DOCKER_MACHINE_CREATE_NODE.format(
                name_=name,
            ),
            working_directory=None,
            environment_variables=None,
            executor=name,
            logger=self._logger,
        )

        return self.get_node_ip(name)
Example #2
0
    def destroy_nodes(
            self,
            name,
    ):
        super().destroy_nodes(name)

        nodes = self._get_nodes(name)
        for node in nodes:
            utils.execute_command(
                command=DOCKER_MACHINE_REMOVE_NODE.format(
                    name_=node,
                ),
                working_directory=None,
                environment_variables=None,
                executor=name,
                logger=self._logger,
            )
Example #3
0
 def get_ssh_private_key_file(self, node_name):
     stdout, return_code = utils.execute_command(
         command=DOCKER_MACHINE_SSH_PRIVATE_KEY_FILE_NODE.format(
             name_=node_name,
         ),
         working_directory=None,
         environment_variables=None,
         executor=node_name,
         logger=self._logger,
     )
     return stdout
Example #4
0
 def get_ssh_username(self, node_name):
     stdout, return_code = utils.execute_command(
         command=DOCKER_MACHINE_SSH_USERNAME_NODE.format(
             name_=node_name,
         ),
         working_directory=None,
         environment_variables=None,
         executor=node_name,
         logger=self._logger,
     )
     return stdout
Example #5
0
    def get_node_ip(
            self,
            name,
    ):
        stdout, return_code = utils.execute_command(
            command=DOCKER_MACHINE_IP_NODE.format(
                name_=name,
            ),
            working_directory=None,
            environment_variables=None,
            executor=name,
            logger=self._logger,
        )

        return stdout
Example #6
0
    def _get_nodes(
            self,
            name_prefix,
    ):
        """
        Retrieves the list of nodes starting with a given prefix.

        :param name_prefix: the prefix of the name
        :type name_prefix: str

        :return: the list of node names
        :rtype: list
        """
        stdout, return_code = utils.execute_command(
            command=DOCKER_MACHINE_LIST_NODES.format(
                name_=name_prefix,
            ),
            working_directory=None,
            environment_variables=None,
            executor=name_prefix,
            logger=self._logger,
        )

        return stdout.split() if stdout != '' else []