Ejemplo n.º 1
0
 def create(self, environment, target_name):
     """
     Sends "create project" command to the remote server
     """
     remote_server_command(
         ["ssh", environment.deploy_target, "create", target_name],
         environment, self,
         clean_up=True,
         )
Ejemplo n.º 2
0
 def create(self, environment, target_name):
     """
     Sends "create project" command to the remote server
     """
     remote_server_command(
         ["ssh", environment.deploy_target, "create", target_name],
         environment,
         self,
         clean_up=True,
     )
Ejemplo n.º 3
0
 def admin_password(self, environment, target_name, password):
     """
     Return True if password was set successfully
     """
     try:
         remote_server_command(
             ["ssh", environment.deploy_target,
                 "admin_password", target_name, password],
             environment, self,
             clean_up=True
             )
         return True
     except WebCommandError:
         return False
Ejemplo n.º 4
0
 def admin_password(self, environment, target_name, password):
     """
     Return True if password was set successfully
     """
     try:
         remote_server_command([
             "ssh", environment.deploy_target, "admin_password",
             target_name, password
         ],
                               environment,
                               self,
                               clean_up=True)
         return True
     except WebCommandError:
         return False
Ejemplo n.º 5
0
    def deploy(self, environment, target_name, stream_output=None):
        """
        Return True if deployment was successful
        """
        try:
            remote_server_command(
                [
                    "rsync", "-lrv", "--safe-links", "--munge-links",
                    "--delete", "--inplace", "--chmod=ugo=rwX",
                    "--exclude=.datacats-environment", "--exclude=.git",
                    "/project/.", environment.deploy_target + ':' + target_name
                ],
                environment,
                self,
                include_project_dir=True,
                stream_output=stream_output,
                clean_up=True,
            )
        except WebCommandError as e:
            raise DatacatsError(
                "Unable to deploy `{0}` to remote server for some reason:\n"
                " datacats was not able to copy data to the remote server".
                format((target_name, )),
                parent_exception=e)

        try:
            remote_server_command(
                [
                    "ssh",
                    environment.deploy_target,
                    "install",
                    target_name,
                ],
                environment,
                self,
                clean_up=True,
            )
            return True
        except WebCommandError as e:
            raise DatacatsError(
                "Unable to deploy `{0}` to remote server for some reason:\n"
                "datacats copied data to the server but failed to register\n"
                "(or `install`) the new catalog".format((target_name, )),
                parent_exception=e)
Ejemplo n.º 6
0
    def deploy(self, environment, target_name, stream_output=None):
        """
        Return True if deployment was successful
        """
        try:
            remote_server_command(
                [
                    "rsync", "-lrv", "--safe-links", "--munge-links",
                    "--delete", "--inplace", "--chmod=ugo=rwX",
                    "--exclude=.datacats-environment",
                    "--exclude=.git",
                    "/project/.",
                    environment.deploy_target + ':' + target_name
                ],
                environment, self,
                include_project_dir=True,
                stream_output=stream_output,
                clean_up=True,
                )
        except WebCommandError as e:
            raise DatacatsError(
                "Unable to deploy `{0}` to remote server for some reason:\n"
                " datacats was not able to copy data to the remote server"
                .format((target_name,)),
                parent_exception=e
                )

        try:
            remote_server_command(
                [
                    "ssh", environment.deploy_target, "install", target_name,
                    ],
                environment, self,
                clean_up=True,
                )
            return True
        except WebCommandError as e:
            raise DatacatsError(
                "Unable to deploy `{0}` to remote server for some reason:\n"
                "datacats copied data to the server but failed to register\n"
                "(or `install`) the new catalog"
                .format((target_name,)),
                parent_exception=e
                )
Ejemplo n.º 7
0
    def test_ssh_key(self, environment):
        """
        Return True if this key is accepted by DataCats.com
        """
        try:
            remote_server_command(["ssh", environment.deploy_target, 'test'],
                                  environment,
                                  self,
                                  clean_up=True)

        except WebCommandError as e:

            user_unrecognized_error_message = (
                "Your ssh key "
                "(which is an equivalent of your password so"
                " that datacats.io could recognize you) "
                "does not seem to be recognized by the datacats.io server. \n \n"
                "Most likely it is because you need to go to"
                " www.datacats.com/account/key"
                " and add the following public key: \n \n {public_key} \n \n"
                "to your profile so that datacat's server could recognize you."
                " So maybe try that?\n"
                "If the problem persists, please contact the developer team."
            ).format(public_key=self.read_public_key())

            network_unreachable_error_message = (
                "Unable to connect to the hosting server: {0} \n"
                "Some of the reasons for that may be: \n"
                "  1) the internet connection is down,\n"
                "  2) the server is not up or functioning properly,\n"
                "  3) there is a firewall block for the datacats application\n"
                " or something of this sort.").format(
                    environment.deploy_target)

            user_error_message = network_unreachable_error_message \
                if "Network is unreachable" in e.logs \
                else user_unrecognized_error_message
            raise DatacatsError(user_error_message, parent_exception=e)
Ejemplo n.º 8
0
    def test_ssh_key(self, environment):
        """
        Return True if this key is accepted by DataCats.com
        """
        try:
            remote_server_command(
                ["ssh", environment.deploy_target, 'test'],
                environment, self, clean_up=True)

        except WebCommandError as e:

            user_unrecognized_error_message = (
                "Your ssh key "
                "(which is an equivalent of your password so"
                " that datacats.io could recognize you) "
                "does not seem to be recognized by the datacats.io server. \n \n"
                "Most likely it is because you need to go to"
                " www.datacats.com/account/key"
                " and add the following public key: \n \n {public_key} \n \n"
                "to your profile so that datacat's server could recognize you."
                " So maybe try that?\n"
                "If the problem persists, please contact the developer team."
                ).format(public_key=self.read_public_key())

            network_unreachable_error_message = (
                "Unable to connect to the hosting server: {0} \n"
                "Some of the reasons for that may be: \n"
                "  1) the internet connection is down,\n"
                "  2) the server is not up or functioning properly,\n"
                "  3) there is a firewall block for the datacats application\n"
                " or something of this sort."
                ).format(environment.deploy_target)

            user_error_message = network_unreachable_error_message \
                if "Network is unreachable" in e.logs \
                else user_unrecognized_error_message
            raise DatacatsError(user_error_message, parent_exception=e)