def get_config(self):
        self.session = ssh.SSHSession(ssh.gen_args(self.host, self.settings),
                                      password=self.password,
                                      prompt='\S+@\S+> ')

        with contextlib.closing(self.session):
            self.session.call("set cli screen-width 0", frame=False)
            self.session.call("set cli screen-length 0", frame=False)
            config = self.session.call("show configuration", frame=False)

        return config
Exemple #2
0
    def get_config(self):
        self.session = ssh.SSHSession(ssh.gen_args(self.host, self.settings),
                                      password=self.password)

        with contextlib.closing(self.session):
            config = self.session.call("cat /tmp/system.cfg")

        # The config is a line by line key-value store.
        # The lines change their place somewhat randomly,
        # therefore, sort the lines to make the diff smaller
        config = ''.join(sorted(config.splitlines(True)))
        return config
Exemple #3
0
    def get_config(self):
        self.session = HPSession(ssh.gen_args(self.host, self.settings),
                                 password=self.password)

        with contextlib.closing(self.session):
            config = self.session.call('show running-config')
            config_pattern = 'Running configuration:\n\n'
            offset = config.find(config_pattern)
            if offset < 0:
                raise RuntimeError(
                    "Ununderstood failure getting config. Sorry.")
            config = config[offset + len(config_pattern):]
            return config
Exemple #4
0
    def get_config(self):
        self.session = ssh.SSHSession(
                ssh.gen_args(self.host, self.settings),
                password=self.password,
                prompt='\S+@\S+> '
        )

        with contextlib.closing(self.session):
            self.session.call("set cli screen-width 0", frame=False)
            self.session.call("set cli screen-length 0", frame=False)
            config = self.session.call("show configuration", frame=False)

        return config
Exemple #5
0
    def get_config(self):
        self.session = HPSession(
                ssh.gen_args(self.host, self.settings),
                password = self.password
        )

        with contextlib.closing(self.session):
            config = self.session.call('show running-config')
            config_pattern = 'Running configuration:\n\n'
            offset = config.find(config_pattern)
            if offset < 0:
                raise RuntimeError("Ununderstood failure getting config. Sorry.")
            config = config[offset + len(config_pattern):]
            return config
Exemple #6
0
    def get_config(self):
        self.session = ssh.SSHSession(
                ssh.gen_args(self.host, self.settings),
                password=self.password
        )

        with contextlib.closing(self.session):
            config = self.session.call("cat /tmp/system.cfg")

        # The config is a line by line key-value store.
        # The lines change their place somewhat randomly,
        # therefore, sort the lines to make the diff smaller
        config = ''.join(sorted(config.splitlines(True)))
        return config
    def get_config(self):
        self.session = ssh.SSHSession(ssh.gen_args(self.host, self.settings),
                                      password=self.password)

        with contextlib.closing(self.session):
            backup_cmd = 'sysupgrade  -b -'
            backup_hex = self.session.call(backup_cmd +
                                           " | hexdump -v -e '1/1 \"%02x\"'")

            if len(backup_hex) % 2:
                raise RuntimeError("Unexpected format for hexdump")

            tarball = bytes()
            while backup_hex:
                tarball += chr(int(backup_hex[:2], 16))
                backup_hex = backup_hex[2:]
            return tarball
Exemple #8
0
    def get_config(self):
        self.session = ssh.SSHSession(
                ssh.gen_args(self.host, self.settings),
                password=self.password
        )

        with contextlib.closing(self.session):
            backup_cmd = 'sysupgrade  -b -'
            backup_hex = self.session.call(backup_cmd + " | hexdump -v -e '1/1 \"%02x\"'")

            if len(backup_hex) % 2:
                raise RuntimeError("Unexpected format for hexdump")

            tarball = bytes()
            while backup_hex:
                tarball += chr(int(backup_hex[:2],16))
                backup_hex = backup_hex[2:]
            return tarball