3 Replies Latest reply: Jul 31, 2015 8:15 AM by Wenxuan Guo RSS

Download Sysdump from SteelHead via SteelScript

Andre Dieball

Hi

 

I know it's possible to use the SteelScript SteelHead Extension to create a SysDump via CLI commands, but my issue is on how to get hold of them.

 

The only thing I have seen which seems to be possible right now is to start an "upload" from the SteelHead via CLI commands to a host, but I'd prefer to "download", i.e. initiate the copy process from the host operating the scripts.

 

The issue is:

 

- I have not found anything that this is possible via the API

- Using a local SCP command logging into the SteelHead in question doesn't work because of the CLI Shell restrictions (no OS commands, ssh, etc)

 

I have seen something in the past where this was possible with Java requesting some kind of virtual PTY but I struggle to get this to work from within python.

 

Anyone with any ideas on this?

 

thanks

  • Re: Download Sysdump from SteelHead via SteelScript
    Wenxuan Guo

    Hi,

    the steelscript-steelhead package currently does not have the feature to download sysdump from a steelhead.

    We might be able to add the feature in the next release.

     

    But you can probably try to write up a python script to do the job after you have a sysdump on the steelhead,

    something as below:

     

    import os

    import paramiko

     

    localpath = '~/localpath/'

    os.system('mkdir ' + localpath)

    ssh = paramiko.SSHClient()

    ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))

    ssh.connect(steelhead_ip, username=username, password=password)

    sftp = ssh.open_sftp()

    sftp.get('file_name_with_absolute_path_on_remote', localpath + 'file_name')

    sftp.close()

    ssh.close()

     

    hope it helps.

     

    P.S. you need to have paramiko installed. if not, do "pip install paramiko"

    • Re: Download Sysdump from SteelHead via SteelScript
      Andre Dieball

      Hi wenxuan guo

       

      I tried something similar already without luck.

       

      I tried it again with your code:

      ---cut---

      localpath = '~/Desktop/Test/'
      os.system('mkdir ' + localpath)

      ssh = paramiko.SSHClient()

      ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

      ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))

      ssh.connect(appliance, username=args.username, password=args.password)

      sftp = ssh.open_sftp()

      #sftp.get('file_name_with_absolute_path_on_remote', localpath + 'file_name')
      sftp.get("/var/opt/tms/" + "sysdump-appliance1-20150727-161036.tgz", localpath + "sysdump-appliance1-20150727-161036.tgz")

      sftp.close()

      ssh.close()

      ---cut---

       

      but this just returns:

       

      ---cut--

      Traceback (most recent call last):

        File "sysdump_createanddownload.py", line 79, in <module>

          main()

        File "sysdump_createanddownload.py", line 69, in main

          sftp = ssh.open_sftp()

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/client.py", line 379, in open_sftp

          return self._transport.open_sftp_client()

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/transport.py", line 811, in open_sftp_client

          return SFTPClient.from_transport(self)

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/sftp_client.py", line 131, in from_transport

          chan.invoke_subsystem('sftp')

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/channel.py", line 60, in _check

          return func(self, *args, **kwds)

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/channel.py", line 254, in invoke_subsystem

          self._wait_for_event()

        File "/Users/adieball/.virtualenvs/steelscript/lib/python2.7/site-packages/paramiko/channel.py", line 1086, in _wait_for_event

          raise e

      paramiko.ssh_exception.SSHException: Channel closed.

      ---cut---

       

      Are you sure the steelheads lets me open a "plain" ssh session? As far as I remember one needs to request a pty first, but I never managed to get that working.

       

      a paramico log shows me:

       

      INF [20150727-16:38:45.849] thr=1   paramiko.transport: Authentication (publickey) failed.

      DEB [20150727-16:38:45.877] thr=1   paramiko.transport: userauth is OK

      INF [20150727-16:38:46.039] thr=1   paramiko.transport: Authentication (password) successful!

      DEB [20150727-16:38:46.050] thr=2   paramiko.transport: [chan 0] Max packet in: 32768 bytes

      DEB [20150727-16:38:46.052] thr=1   paramiko.transport: [chan 0] Max packet out: 32768 bytes

      DEB [20150727-16:38:46.052] thr=1   paramiko.transport: Secsh channel 0 opened.

      DEB [20150727-16:38:46.055] thr=1   paramiko.transport: [chan 0] EOF sent (0)

      DEB [20150727-16:38:46.098] thr=1   paramiko.transport: EOF in transport thread

       

      unfortunately not that much information ....

       

      and when I try to do a sftp outside of python, i.e. in a terminal, I get:

      subsystem request failed on channel 0

      Connection closed

       

       

       

      Andre