Esempio n. 1
0
    def open_iptables_port(self, command, expected):
        PrintMessage('Attempt to modify ip tables on {0}'.format(self.host))
        self.send_cmd('iptables -S')

        if self.cli.expect([expected, pexpect.TIMEOUT]) == 0:
            PrintMessage('IPTables already enabled - skipping')
            return

        if PExpectWrapper.execute_shell_command(self.cli, command) != 0:
            raise Exception('Failed opening ip tables!')

        if PExpectWrapper.execute_shell_command(
                self.cli, 'service iptables save',
                expected_value='[  OK  ]') != 0:
            raise Exception('Failed opening ip tables!')
Esempio n. 2
0
 def save_all_profile(self, destination_file):
     save_dump = SAVE_PROFILE.format('', destination_file)
     status_code = PExpectWrapper.execute_shell_command(self.cli, save_dump)
     if status_code == 0:
         PrintMessage('Defense profile saved')
     else:
         PrintMessage(
             'Failed to save Defense profile, status code: {0}'.format(
                 status_code))
Esempio n. 3
0
    def update_sxos_version(self, new_version):
        assert type(new_version) is Version
        new_version.verify()

        new_version_as_string = new_version.get_as_string(fill_with_zeros=0)

        linux_command = "echo '{0}' > {1}".format(new_version_as_string,
                                                  SXOS_FILE)
        PrintMessage('Updating sxos version to {0}, with command: {1}'.format(
            new_version_as_string, linux_command))

        status_code = PExpectWrapper.execute_shell_command(
            self.cli, linux_command)

        if status_code == 0:
            PrintMessage('SXOS version was updated!')
        else:
            PrintMessage('Failed to update {0}, status code: {1}'.format(
                SXOS_FILE, status_code))

        # verify file is updated
        self.send_cmd('cat ' + SXOS_FILE)
        self.cli.expect(SXOS_FILE)
        self.cli.expect(new_version_as_string)