cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1151
Views
2
Helpful
4
Replies

ssh.fetch_host_keys() is this function code visible ?

kiran kotari
Cisco Employee
Cisco Employee

Wanted to know `ssh.fetch_host_keys().result.string` all possible resulting strings i.e. updated, unchanged, failed, e.t.c

if any document can you please point me where i can find.

2 Accepted Solutions

Accepted Solutions

Jan Lindblad
Cisco Employee
Cisco Employee

Have a look in <NSO installation>/src/ncs/yang/tailf-ncs-ssh.yang

View solution in original post

kiran kotari
Cisco Employee
Cisco Employee

@Jan Lindblad Thanks, Now I am able to see all the possibly in the yang, pasting here.

    grouping ssh-host-keys-result {
      leaf result {
        type enumeration {
          enum failed {
            description
              "The key retrieval failed, e.g. due to failure to connect
               to the device or cluster node.";
            tailf:code-name hostkey_failed;
          }
          enum unchanged {
            description
              "The key retrieval succeeded, and the keys were the same
               as those already known.";
          }
          enum updated {
            description
              "The key retrieval succeeded, and the keys were not the same
               as those already known - i.e. there was at least one new or
               changed key. The updated keys were committed";
          }
          enum updated-uncommitted {
            description
              "The key retrieval succeeded, and the keys were not the same
               as those already known - i.e. there was at least one new or
               changed key. The updated keys were not committed, only stored
               in the current transaction, since the device or cluster node
               entry the keys pertain to was not committed (i.e. it only
               exists in the current transaction). The keys will be
               committed when the user commits the transaction.";
          }
          enum not-available {
            description
              "Key retrieval was not attempted due to not being applicable for
               the device type or additional live-tree protocol (e.g. CLI
               access via telnet rather than SSH).";
          }
        }
      }
}

I found a better way in recent days to fetch the fingerprint value, here is the solution

dev = root.devices.device['ios-dev0']
list(dev.ssh.host_key)[0].show_fingerprint().value

Thanks,
Kiran Kumar

View solution in original post

4 Replies 4

ynagami
Cisco Employee
Cisco Employee

Hi,

You can get result as following.

---

                for dev in root.ncs__devices.device:

                    output = dev.ssh.fetch_host_keys()

                    print('[{}]fetch result: {}'.format(dev.name, output.result))

---

$ python ssh_fetch.py

[csr1kv]fetch result: unchanged

The result of tailf:action is same as the output structure.

This will give one result out of ? (updated, unchanged, failed, e.t.c) -> I want to know there i can find that list of results or the code which is sending them.

Jan Lindblad
Cisco Employee
Cisco Employee

Have a look in <NSO installation>/src/ncs/yang/tailf-ncs-ssh.yang

kiran kotari
Cisco Employee
Cisco Employee

@Jan Lindblad Thanks, Now I am able to see all the possibly in the yang, pasting here.

    grouping ssh-host-keys-result {
      leaf result {
        type enumeration {
          enum failed {
            description
              "The key retrieval failed, e.g. due to failure to connect
               to the device or cluster node.";
            tailf:code-name hostkey_failed;
          }
          enum unchanged {
            description
              "The key retrieval succeeded, and the keys were the same
               as those already known.";
          }
          enum updated {
            description
              "The key retrieval succeeded, and the keys were not the same
               as those already known - i.e. there was at least one new or
               changed key. The updated keys were committed";
          }
          enum updated-uncommitted {
            description
              "The key retrieval succeeded, and the keys were not the same
               as those already known - i.e. there was at least one new or
               changed key. The updated keys were not committed, only stored
               in the current transaction, since the device or cluster node
               entry the keys pertain to was not committed (i.e. it only
               exists in the current transaction). The keys will be
               committed when the user commits the transaction.";
          }
          enum not-available {
            description
              "Key retrieval was not attempted due to not being applicable for
               the device type or additional live-tree protocol (e.g. CLI
               access via telnet rather than SSH).";
          }
        }
      }
}

I found a better way in recent days to fetch the fingerprint value, here is the solution

dev = root.devices.device['ios-dev0']
list(dev.ssh.host_key)[0].show_fingerprint().value

Thanks,
Kiran Kumar

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: