arista-eosplus / ztpserver

Full service ZTP Server implementation for bootstrapping Arista EOS nodes
Other
70 stars 33 forks source link

Enhance install_image to determine architecture and version from URL,… #405

Closed Trailingslashes closed 6 months ago

Trailingslashes commented 6 months ago

Images labelled with 32 or 64 should be copied on /mnt/flash with the correct name.

drwxrwx---+  2 root      eosadmin      16384 Mar 16  2022 lost+found
drwxrwxr-x+  2 root      eosadmin       4096 Mar 16  2022 Fossil
drwxrwxr-x+  2 root      eosadmin       4096 Mar 16  2022 fastpkttx.backup
drwxrwxrwx+  2 root      eosadmin       4096 Mar 16  2022 .checkpoints
-rw-rw-rw-+  1 root      eosadmin          0 Mar 16  2022 .assetTags
drwxrwxr-x+  3 root      eosadmin       4096 Mar 16  2022 schedule
-rw-rw-r--+  1 106904808 eosadmin 1117379109 Jan  5 10:22 EOS-4.27.11M.swi
drwxrwxr-x+  2 106904808 eosadmin       4096 Jan  5 11:21 .managed-config
-rwxrwxrwx+  1 root      eosadmin       2473 Apr 18 14:26 startup-config
-rwxrwxrwx+  1 root      eosadmin 1254919771 Apr 18 14:26 EOS32-4.29.7M.swi
drwxrwx---+  2 root      eosadmin       4096 Apr 18 14:26 .extensions
-rw-rw-r--+  1 root      eosadmin         29 Apr 18 14:26 boot-config
-r--r-x---+  1 root      eosadmin 1254919771 Apr 18 14:28 .boot-image.swi
drwxr-xr-x   1 root      root            140 Apr 18 14:28 ..
drwxrwxr-x+  3 root      eosadmin       4096 Apr 18 14:28 aboot
drwxrwxr-x+  2 root      eosadmin       4096 Apr 18 14:28 tpm-data
drwxrwx---+ 13 root      eosadmin       4096 Apr 18 14:28 .
-rw-rw-r--+  1 root      eosadmin       1278 Apr 18 14:28 SsuRestoreLegacy.log
-rw-rw-r--+  1 root      eosadmin       1278 Apr 18 14:28 SsuRestore.log
-rw-rw-r--+  1 root      eosadmin       2079 Apr 18 14:28 AsuFastPktTransmit.log
-rw-rw-r--+  1 root      eosadmin          0 Apr 18 14:29 zerotouch-config
drwxrwx---+  3 root      eosadmin       4096 Apr 18 14:29 debug
drwxrwxr-x+  3 root      eosadmin       4096 Apr 18 14:30 persist

show version:

Hardware version: 11.20
Serial number: JPE22042879
Hardware MAC address: c4ca.2b24.2f41
System MAC address: c4ca.2b24.2f41

Software image version: 4.29.7M
Architecture: i686
Internal build version: 4.29.7M-35658221.4297M
Internal build ID: b9978b0a-8b54-4195-9c83-99f4277ac709
Image format version: 3.0
Image optimization: Default
---
actions:
  -
    action: install_image
    always_execute: true
    attributes:
      url: files/images/EOS32-4.29.7M.swi
      version: 4.29.7M
    name: "Install 4.29.7M"

see #404

siguroot commented 6 months ago

Wouldn't it be better if the filenames were aligned with what is provided by arista. I personally think the better approach is to just parse the filename out of the provided url attribute. Thoughts?

image

Trailingslashes commented 6 months ago

I guess my thinking was to read the url in the definition and reconstruct the name of the file based on that. When I read a file on /mnt/flash, I want to know if it's a 32 or 64 bit file right away. I don't want to rely on the md5sum. But yes, you're right, following Arista's standard - if there is no 64bit in the name, we can assume it's 32 bit right away.

Trailingslashes commented 6 months ago

I suppose that's what issue #313 is trying to do. I did this to guarantee that I'm copying files correctly.

siguroot commented 6 months ago

I'm baffled by the fact, this script assembles the destination filename from the version variable. I suspect this was done from a uniformity perspective. Alternatively it was done like this before 'EOS64' images became available and it was a non-issue at the time. However in the networking world, ztp/automation aside, we almost always use the filename set by the vendor. In fact, I don't think I have ever deviated from the vendor filenames. I think parsing the url variable is the most elegant solution here. It also appeals to the intuition of most network engineers.

I'm not sure what to do here as I'm not super familiar with github etiquette. Do we collaborate or should I put in a competing pull request? Hopefully that didn't sound snarky, I assure you there is no snark present :-)

Trailingslashes commented 6 months ago

You're more than welcome to create your own pull request.

dlobato commented 6 months ago

Closing as #406 implements similar functionality