KEMBAR78
[Python] Quick book for dell switch_os10 | PDF
Python Quick_book for DELL OS10 Switch
This document is the purpose of quick start for python on the DELL OS10.
Copyright <2018> Hoon_Jo@dell.com < Github : https://github.com/sysnet4admin>
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
1. Bash Shell on the DELL OS10
First of all, how could you change shell mode from OS10 Enterprise Edition OS10 EE
?
It is very easy.
Just use ‘system’ command like below:
- You could call bash shell by system command.
QA-F1-1-252-31# system bash
admin@QA-F1-1-252-31:/config/home/admin$
And you could check whatever you want inside of switch.
It is almost same of Debian linux except just some component.
DELL OS10 based on Dadian
admin@QA-F1-1-252-31:/config/home/admin$ cat /etc/debian_version
8.10
DELL OS10 Version
admin@QA-F1-1-252-31:/config/home/admin$ cat /etc/issue
Debian GNU/Linux 8 ₩n ₩l
Dell EMC Networking Operating System (OS10)
2. Glance to look into HW on the DELL OS10
Here is some command to check HW side on the DELL OS10.
fdisk -l
- It is very common command to check the disk space and patition information.
admin@QA-F1-1-252-31:/var/log$ sudo fdisk -l
Disk /dev/nullb0: 250 GiB, 268435456000 bytes, 524288000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/nullb1: 250 GiB, 268435456000 bytes, 524288000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/zram0: 793.7 MiB, 832221184 bytes, 203179 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/sda: 14.9 GiB, 16013942784 bytes, 31277232 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 2646362D-2B74-49A9-BC31-89E0A933AEE0
Device Start End Sectors Size Type
/dev/sda1 2048 6143 4096 2M BIOS boot
/dev/sda2 6144 268287 262144 128M unknown
/dev/sda3 268288 2365439 2097152 1G Linux filesystem
/dev/sda4 2365440 2381823 16384 8M Linux filesystem
/dev/sda5 2381824 31277198 28895375 13.8G Linux LVM
Disk /dev/mapper/OS10-SYSROOT1: 6.6 GiB, 7117733888 bytes, 13901824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/OS10-LICENSE: 32 MiB, 33554432 bytes, 65536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/OS10-CONFIG: 500 MiB, 524288000 bytes, 1024000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/OS10-SYSROOT2: 6.6 GiB, 7117733888 bytes, 13901824 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
And then you may consider what is bootflash on the DELL OS10?
Thus you could check to this file ( /proc/scsi/scsi )
I’ve never heard InnoDisk Corp :) haha;;;
admin@QA-F1-1-252-31:/var/log$ cat /proc/scsi/scsi
Attached devices:
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: InnoDisk Corp. - Rev: 714i
Type: Direct-Access ANSI SCSI revision: 05
df -h
- You could check actual disk space by this.
admin@QA-F1-1-252-31:/config/home/admin$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/dm-0 6.4G 1.3G 4.8G 21% /
udev 10M 0 10M 0% /dev
tmpfs 1.6G 1.8M 1.6G 1% /run
tmpfs 3.9G 24K 3.9G 1% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda4 6.8M 2.1M 4.2M 33% /mnt/boot
/dev/sda2 120M 12M 100M 11% /mnt/onie-boot
/dev/mapper/OS10-LICENSE 27M 399K 25M 2% /mnt/license
/dev/mapper/OS10-CONFIG 477M 4.7M 443M 2% /config
none 6.4G 1.3G 4.8G 21% /opt/dell/os10/cli
/dev/mapper/OS10-SYSROOT2 6.4G 1.3G 4.9G 20% /alt
Why do I mention it?
Because, I will use some file in here.
3. Log Backup
Is there anyone to bother so that configure syslog server for saving log on N series
Swtich?
Yes…you already know it is not happended DELL OS10.
However I just pick up for this topic due to it is very eady to understand the purpose &
code as well.
Here is sample code.
[code #1] log_collector.py
01. Just copy swithch’s log (eventlog, i.e. logging log) from /var/log/eventlog to home
directory.
Before I run this command like this.
QA-F1-1-252-31# dir home
Directory contents for folder: home
Date (modified) Size (bytes) Name
--------------------- ------------ -----------------------------------
-------
2018-04-05T11:27:21Z 806 sudo_cmd.py
2018-04-05T12:20:17Z 158 log_collector.py
02. And run~!!!
Note: you should use double quotation(“). Single quotation couldn’t parse properly.
QA-F1-1-252-31# system "python log_collector.py"
Succefully copy logging logfile.
03. Check home directory.
QA-F1-1-252-31# dir home
Directory contents for folder: home
Date (modified) Size (bytes) Name
--------------------- ------------ -----------------------------------
-------
2018-04-05T11:27:21Z 806 sudo_cmd.py
2018-04-05T12:20:17Z 158 log_collector.py
2018-04-05T12:26:38Z 120539 logging_logfile
04. And then you could check for validation.
QA-F1-1-252-31# system "cat logging_logfile"
<snipped>
Apr 3 08:45:26 QA-F1-1-252-31 login[11468]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(login:session): session opened for user admin by (uid=0)
Apr 3 08:45:27 QA-F1-1-252-31 sshd[11482]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(sshd:session): session opened for user admin by (uid=0)
Apr 3 10:51:42 QA-F1-1-252-31 sshd[11482]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(sshd:session): session closed for user admin
Apr 4 07:02:23 QA-F1-1-252-31 login[3482]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(login:session): session opened for user admin by (uid=0)
Apr 4 07:02:24 QA-F1-1-252-31 sshd[3487]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(sshd:session): session opened for user admin by (uid=0)
Apr 4 07:59:55 QA-F1-1-252-31 login[8420]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(login:session): session opened for user admin by (uid=0)
Apr 4 07:59:56 QA-F1-1-252-31 sshd[8424]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(sshd:session): session opened for user admin by (uid=0)
Apr 4 09:37:24 QA-F1-1-252-31 sshd[3487]: Node.1-Unit.1:PRI:info %log-info:
pam_unix(sshd:session): session closed for user admin
4. sudo_cmd
We already backup the evenlog by system command.
Every file and other command is available by system command?
See this example.
Here is ‘support_bundle’.
QA-F1-1-252-31# dir supportbundle
Directory contents for folder: supportbundle
Date (modified) Size (bytes) Name
--------------------- ------------ -----------------------------------
-------
2018-04-05T12:39:27Z 7173559 sosreport-QA-F1-1-252-31-
20180405123834.tar.gz
2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31-
20180405123834.tar.gz.md5
And it will show up this error!!! OMG!
QA-F1-1-252-31# system "python SB_collector.py"
cp: cannot create regular file '/var/opt/dell/os10/support_bundle/bundle/sosreport-QA-F1-
1-252-31-20180405123834.tar.gz': Permission denied
[Code #2] python SB_collector.py
How could it fix?
Use this code.
[Code #3] sudo_cmd.py
Run the code!!!
QA-F1-1-252-31# system "python sudo_cmd.py"
Script not started as root. Running sudo..
[sudo] password for admin: <password>
Please input command(default path is home directory): cp /var/log/eventlog
/var/opt/dell/os10/support_bundle/bundle/eventlog
[ Before run ]
QA-F1-1-252-31# dir supportbundle
Directory contents for folder: supportbundle
Date (modified) Size (bytes) Name
--------------------- ------------ -----------------------------------
-------
2018-04-05T13:20:04Z 122782 sosreport-QA-F1-1-252-31-20180405123834.tar.gz
2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31-
20180405123834.tar.gz.md5
[ After run ]
There is no limitation to run any command :D
QA-F1-1-252-31# dir supportbundle
Directory contents for folder: supportbundle
Date (modified) Size (bytes) Name
--------------------- ------------ -----------------------------------
-------
2018-04-05T13:21:55Z 122782 eventlog
2018-04-05T13:20:04Z 122782 sosreport-QA-F1-1-252-31-20180405123834.tar.gz
2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31-
20180405123834.tar.gz.md5
Done!! I hope you will enjoy DELL OS10 enviroment.
See ya!
Hoon Jo.

[Python] Quick book for dell switch_os10

  • 1.
    Python Quick_book forDELL OS10 Switch This document is the purpose of quick start for python on the DELL OS10. Copyright <2018> Hoon_Jo@dell.com < Github : https://github.com/sysnet4admin> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  • 2.
    1. Bash Shellon the DELL OS10 First of all, how could you change shell mode from OS10 Enterprise Edition OS10 EE ? It is very easy. Just use ‘system’ command like below: - You could call bash shell by system command. QA-F1-1-252-31# system bash admin@QA-F1-1-252-31:/config/home/admin$ And you could check whatever you want inside of switch. It is almost same of Debian linux except just some component. DELL OS10 based on Dadian admin@QA-F1-1-252-31:/config/home/admin$ cat /etc/debian_version 8.10 DELL OS10 Version admin@QA-F1-1-252-31:/config/home/admin$ cat /etc/issue Debian GNU/Linux 8 ₩n ₩l Dell EMC Networking Operating System (OS10)
  • 3.
    2. Glance tolook into HW on the DELL OS10 Here is some command to check HW side on the DELL OS10. fdisk -l - It is very common command to check the disk space and patition information. admin@QA-F1-1-252-31:/var/log$ sudo fdisk -l Disk /dev/nullb0: 250 GiB, 268435456000 bytes, 524288000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/nullb1: 250 GiB, 268435456000 bytes, 524288000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/zram0: 793.7 MiB, 832221184 bytes, 203179 sectors Units: sectors of 1 * 4096 = 4096 bytes Sector size (logical/physical): 4096 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disk /dev/sda: 14.9 GiB, 16013942784 bytes, 31277232 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: gpt Disk identifier: 2646362D-2B74-49A9-BC31-89E0A933AEE0 Device Start End Sectors Size Type /dev/sda1 2048 6143 4096 2M BIOS boot /dev/sda2 6144 268287 262144 128M unknown /dev/sda3 268288 2365439 2097152 1G Linux filesystem /dev/sda4 2365440 2381823 16384 8M Linux filesystem /dev/sda5 2381824 31277198 28895375 13.8G Linux LVM Disk /dev/mapper/OS10-SYSROOT1: 6.6 GiB, 7117733888 bytes, 13901824 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/OS10-LICENSE: 32 MiB, 33554432 bytes, 65536 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk /dev/mapper/OS10-CONFIG: 500 MiB, 524288000 bytes, 1024000 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
  • 4.
    Disk /dev/mapper/OS10-SYSROOT2: 6.6GiB, 7117733888 bytes, 13901824 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes And then you may consider what is bootflash on the DELL OS10? Thus you could check to this file ( /proc/scsi/scsi ) I’ve never heard InnoDisk Corp :) haha;;; admin@QA-F1-1-252-31:/var/log$ cat /proc/scsi/scsi Attached devices: Host: scsi4 Channel: 00 Id: 00 Lun: 00 Vendor: ATA Model: InnoDisk Corp. - Rev: 714i Type: Direct-Access ANSI SCSI revision: 05 df -h - You could check actual disk space by this. admin@QA-F1-1-252-31:/config/home/admin$ df -h Filesystem Size Used Avail Use% Mounted on /dev/dm-0 6.4G 1.3G 4.8G 21% / udev 10M 0 10M 0% /dev tmpfs 1.6G 1.8M 1.6G 1% /run tmpfs 3.9G 24K 3.9G 1% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda4 6.8M 2.1M 4.2M 33% /mnt/boot /dev/sda2 120M 12M 100M 11% /mnt/onie-boot /dev/mapper/OS10-LICENSE 27M 399K 25M 2% /mnt/license /dev/mapper/OS10-CONFIG 477M 4.7M 443M 2% /config none 6.4G 1.3G 4.8G 21% /opt/dell/os10/cli /dev/mapper/OS10-SYSROOT2 6.4G 1.3G 4.9G 20% /alt Why do I mention it? Because, I will use some file in here.
  • 5.
    3. Log Backup Isthere anyone to bother so that configure syslog server for saving log on N series Swtich? Yes…you already know it is not happended DELL OS10. However I just pick up for this topic due to it is very eady to understand the purpose & code as well. Here is sample code. [code #1] log_collector.py 01. Just copy swithch’s log (eventlog, i.e. logging log) from /var/log/eventlog to home directory. Before I run this command like this. QA-F1-1-252-31# dir home Directory contents for folder: home Date (modified) Size (bytes) Name --------------------- ------------ ----------------------------------- ------- 2018-04-05T11:27:21Z 806 sudo_cmd.py 2018-04-05T12:20:17Z 158 log_collector.py 02. And run~!!! Note: you should use double quotation(“). Single quotation couldn’t parse properly. QA-F1-1-252-31# system "python log_collector.py" Succefully copy logging logfile.
  • 6.
    03. Check homedirectory. QA-F1-1-252-31# dir home Directory contents for folder: home Date (modified) Size (bytes) Name --------------------- ------------ ----------------------------------- ------- 2018-04-05T11:27:21Z 806 sudo_cmd.py 2018-04-05T12:20:17Z 158 log_collector.py 2018-04-05T12:26:38Z 120539 logging_logfile 04. And then you could check for validation. QA-F1-1-252-31# system "cat logging_logfile" <snipped> Apr 3 08:45:26 QA-F1-1-252-31 login[11468]: Node.1-Unit.1:PRI:info %log-info: pam_unix(login:session): session opened for user admin by (uid=0) Apr 3 08:45:27 QA-F1-1-252-31 sshd[11482]: Node.1-Unit.1:PRI:info %log-info: pam_unix(sshd:session): session opened for user admin by (uid=0) Apr 3 10:51:42 QA-F1-1-252-31 sshd[11482]: Node.1-Unit.1:PRI:info %log-info: pam_unix(sshd:session): session closed for user admin Apr 4 07:02:23 QA-F1-1-252-31 login[3482]: Node.1-Unit.1:PRI:info %log-info: pam_unix(login:session): session opened for user admin by (uid=0) Apr 4 07:02:24 QA-F1-1-252-31 sshd[3487]: Node.1-Unit.1:PRI:info %log-info: pam_unix(sshd:session): session opened for user admin by (uid=0) Apr 4 07:59:55 QA-F1-1-252-31 login[8420]: Node.1-Unit.1:PRI:info %log-info: pam_unix(login:session): session opened for user admin by (uid=0) Apr 4 07:59:56 QA-F1-1-252-31 sshd[8424]: Node.1-Unit.1:PRI:info %log-info: pam_unix(sshd:session): session opened for user admin by (uid=0) Apr 4 09:37:24 QA-F1-1-252-31 sshd[3487]: Node.1-Unit.1:PRI:info %log-info: pam_unix(sshd:session): session closed for user admin
  • 7.
    4. sudo_cmd We alreadybackup the evenlog by system command. Every file and other command is available by system command? See this example. Here is ‘support_bundle’. QA-F1-1-252-31# dir supportbundle Directory contents for folder: supportbundle Date (modified) Size (bytes) Name --------------------- ------------ ----------------------------------- ------- 2018-04-05T12:39:27Z 7173559 sosreport-QA-F1-1-252-31- 20180405123834.tar.gz 2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31- 20180405123834.tar.gz.md5 And it will show up this error!!! OMG! QA-F1-1-252-31# system "python SB_collector.py" cp: cannot create regular file '/var/opt/dell/os10/support_bundle/bundle/sosreport-QA-F1- 1-252-31-20180405123834.tar.gz': Permission denied [Code #2] python SB_collector.py How could it fix? Use this code.
  • 8.
    [Code #3] sudo_cmd.py Runthe code!!! QA-F1-1-252-31# system "python sudo_cmd.py" Script not started as root. Running sudo.. [sudo] password for admin: <password> Please input command(default path is home directory): cp /var/log/eventlog /var/opt/dell/os10/support_bundle/bundle/eventlog [ Before run ] QA-F1-1-252-31# dir supportbundle Directory contents for folder: supportbundle Date (modified) Size (bytes) Name --------------------- ------------ ----------------------------------- ------- 2018-04-05T13:20:04Z 122782 sosreport-QA-F1-1-252-31-20180405123834.tar.gz 2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31- 20180405123834.tar.gz.md5
  • 9.
    [ After run] There is no limitation to run any command :D QA-F1-1-252-31# dir supportbundle Directory contents for folder: supportbundle Date (modified) Size (bytes) Name --------------------- ------------ ----------------------------------- ------- 2018-04-05T13:21:55Z 122782 eventlog 2018-04-05T13:20:04Z 122782 sosreport-QA-F1-1-252-31-20180405123834.tar.gz 2018-04-05T12:39:31Z 33 sosreport-QA-F1-1-252-31- 20180405123834.tar.gz.md5 Done!! I hope you will enjoy DELL OS10 enviroment. See ya! Hoon Jo.