2017/02/06

IOS.shの実行中断

前回紹介したIOS.shの実行中断に関する補足。
前回は、以下のように紹介した:
他のコマンド(ping等)と同様、[Ctrl]+[Alt]+[6] (HEX 1E。MacのTerminalからだと[Ctrl]+[^]らしい)で実行を中断することができる。
しかし、実際には止まらない場合がある。例えば:
Switch#while true; do echo "#### `show clock`"; ping 10.0.0.3 repeat 1; sleep 1; done
#### 04:26:14.555 JST Tue Feb 7 2017
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 7/7/7 ms
#### 04:26:15.569 JST Tue Feb 7 2017
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:
!
Success rate is 100 percent (1/1), round-trip min/avg/max = 1/1/1 ms
#### 04:26:16.576 JST Tue Feb 7 2017
Type escape sequence to abort.
Sending 1, 100-byte ICMP Echos to 10.0.0.3, timeout is 2 seconds:
!
これを実行しているときに[Ctrl]+[Alt]+[6]を入力しても、実行中断することができない。

この場合、他のセッションを開いて、上のコマンドを実行中のセッションごと強制終了する。
例えば、上のコマンドを、シリアルコンソール(console 0)から実行している場合、SSHで新しいセッションを開いておいて、以下の通り実行する。
Switch#clear line console 0
[confirm]y [OK]
Switch#
もとのシリアルコンソールは、強制的にログアウトされ、ログインプロンプトが表示される。
Switch con0 is now available





Press RETURN to get started.









User Access Verification

Username:

2017/02/05

Cisco IOSでshell: IOS.sh

Cisco IOS (Apple iOSではない)は、CatalystやCiscoルータと言ったCiscoのネットワーク機器のOS。

コの業界、特にインフラ系では、Ciscoがデファクトスタンダードで、避けては通れない。

で、このIOSは主にCLIで操作するのだが、独自のコマンド体系で、UNIX/Linux系のシェルに慣れている技術者には、少々とっつきにくい。
例えば、パイプ(|)はサポートされているが、grepコマンドではなくincludeコマンドを使う、などなど。

これを少しだけ解決するのが、今回紹介するIOS.sh
IOS上でUNIX系のコマンドの一部と、Bourne Shell系の制御構造が使える。
バッチファイルを使うこともできる(エディタは無いが…)

IOS.shは、IOS 15.1(4)M、15.1(2)S以降のバージョンでサポートされている。
サポートしているIOS上で「cat ?」と入力すると、
Switch>cat ?
The command you have entered is available in the IOS.sh.
However, the shell is currently disabled. You can enable
it on this terminal by typing
   'term shell'
You can also enable it for all terminals by configuring the
   'shell processing full'
command. There is additional information in the man command.
For more information, enable shell, and then enter:
'man IOS.sh'
Switch>cat
と表示されることが確認できる。

起動と停止

IOSにログインして、「terminal shell」あるは短縮形で「term shell」と入力して起動する。
Switch>terminal shell
Switch>
停止は、「terminal no shell」もしくは「term no shell(「no term shell」じゃないんだな、これが)
Switch>terminal no shell
Switch>
または、ログアウトしても停止する。

現在状態の確認

「show terminal」コマンドで調べる。
Switch>show terminal | include Shell
Shell: enabled
Shell trace: off
Switch>

実行中断

他のコマンド(ping等)と同様、[Ctrl]+[Alt]+[6] (HEX 1E。MacのTerminalからだと[Ctrl]+[^]らしい)で実行を中断することができる。
Switch>i=0; while true; do echo $i; ((i=i+1)); done
0
1
2
<<略>>
[Shift]+[Ctrl]+[6]
105
106
107       ^
% Invalid input detected at '^' marker.

Switch>
ちょっとゴミが出てるが気にしない。
追記: [Shift]+[Ctrl]+[6]で実行停止できない場合について、補足した。

マニュアル

Linux/Unix同様、manコマンドが使える。
まずは、「man IOS.sh」を見よ。
Switch>man IOS.sh
NAME
    IOS.sh - process shell input

DESCRIPTION
The IOS.sh is a set of add-on features to the IOS
CLI. These features enables users to write scripts,
execute functions, evaluate numeric and logical expressions,
and perform loops over data using a standard, easy to learn
syntax.

In addition, the IOS.sh offers variable substitution, enhanced
quoting, and a series of builtin functions that are designed to
simplify the job of interacting with an IOS router.

In order to learn about the IOS.sh, a set of man pages such as
this one have been prepared to describe the various new features.
The following man pages may be used learn about the shell.

 man compatibility   -  gives a quick overview of compatibility between
                        shell and traditional IOS CLI
 man variables       -  describes the usage of variables
 man scripting       -  gives a quick overview of the scripting
                        capabilities of IOS.sh
 man expressions     -  describes the expression syntax built into the IOS.sh
 man loops           -  describes loop structures built into IOS.sh
 man functions       -  describes how to use and write functions
 man quoting         -  describes the new quoting facility
Switch>
ちなみに、上の「man .*」の内、手元の環境15.2(2)E5では、「man loops」のみエラーとなった。

なお、単に「man」だけ入力すると、manコマンドで調査可能な項目の一覧が表示される。
Switch>man
((              evaluate a numeric test expression
IOS.sh          The IOS shell
[[              evaluate a logical test expression
cat             output data from a pipe or file to the terminal
compatibility   compatibility information on IOS.sh
control         control constructs in IOS.sh
<<略>>
variables       usage of variables in IOS.sh
wc              count lines, words, and chars
while           iterate while an expression is TRUE

Switch>

2015/11/26

Dell PowerEdge上のVMware ESXi 5.5を6.0 U1に更新する・その7・ライセンスの入力

メジャーバージョンが変わったので、ライセンスを入力しなおす必要がある。
まず、現状を確認する。
[root@esxi03:~] vim-cmd vimsvc/license --show
[200] Sending request for installed licenses...[200] Complete, result is:
   serial: 00000-00000-00000-00000-00000
   vmodl key: eval
   name: Evaluation Mode
   total: 1
   used:  1
   unit: host
   Properties:
     [ProductName] = VMware ESX Server
     [ProductVersion] = 6.0
     [evaluation] = License has not been set, evaluation Period in effect.
     [expirationHours] = 1439
     [expirationMinutes] = 45
     [expirationDate] = 2016-01-25T06:21:17.894699Z
     [system_time] = 2015-11-26T06:36:17.899722Z
     [feature] = vsmp:0 ("Unlimited virtual SMP")
     [feature] = h264remote ("H.264 for Remote Console Connections")
<<略>>
     [feature] = vgpu ("vGPU")
     [FileVersion] = 6.0.1.2
     [LicenseFilePath] = /usr/lib/vmware/licenses/site/license-esx-60-e16-suite-vsom-c1-201306
     [LicenseFilePath] = /usr/lib/vmware/licenses/site/license-esx-60-e18-robo-c3-201306
<<略>>
     [LicenseFilePath] = /usr/lib/vmware/licenses/site/license-esx-60-e9-sub-c1-201306
     [Localized] = 

[200] End of report.
[root@esxi03:~]
現在は、ライセンスキー(serial)が入力されておらず、評価モード(Evaluation Mode)であることが判る。

Dell PowerEdge上のVMware ESXi 5.5を6.0 U1に更新する・その6・再起動と確認

Message:」行に、再起動が必要とあるので、再起動する。
~ # esxcli system shutdown reboot --reason="ESXi Upgrade from 5.5 to 6.0u1"
~ #

起動されるまで待ち、SSHで接続する。
バージョンを確認する。
[root@esxi03:~] esxcli system version get
   Product: VMware ESXi
   Version: 6.0.0
   Build: Releasebuild-3029758
   Update: 1
   Patch: 17
[root@esxi03:~]
バージョン6.0.0、ビルド3029758(ESXi 6.0 Update 1)に更新されたことが判る。
また、ESXi 5.5の時とはプロンプトが変わっていることも確認できる。

[root@esxi03:~] esxcli software vib list
Name                           Version                              Vendor  Acceptance Level  Install Date
-----------------------------  -----------------------------------  ------  ----------------  ------------
lsi-mr3                        6.606.12.00-1OEM.600.0.0.2159203     Avago   VMwareCertified   2015-11-26  
scsi-megaraid-sas              6.804.60.00-1OEM.600.0.0.2159203     Avago   VMwareCertified   2015-11-26  
net-tg3                        3.137l.v60.1-1OEM.600.0.0.2494585    BRCM    VMwareCertified   2015-11-26  
OpenManage                     7.4.0.1-0000                         Dell    PartnerSupported  2014-08-21  
elxnet                         10.6.126.0-1OEM.600.0.0.2159203      EMU     VMwareCertified   2015-11-26  
lpfc                           10.6.126.0-1OEM.600.0.0.2159203      EMU     VMwareCertified   2015-11-26  
net-ixgbe                      3.21.6-1OEM.600.0.0.2159203          INT     VMwareCertified   2015-11-26  
net-igb                        5.3.0-1OEM.550.0.0.1331820           Intel   VMwareCertified   2015-11-26  
ima-qla4xxx                    500.2.01.31-1vmw.0.3.100400          QLogic  VMwareCertified   2015-11-26  
<<略>>
ehci-ehci-hcd                  1.0-3vmw.600.0.0.2494585             VMware  VMwareCertified   2015-11-26  
esx-base                       6.0.0-1.17.3029758                   VMware  VMwareCertified   2015-11-26  
esx-dvfilter-generic-fastpath  6.0.0-0.0.2494585                    VMware  VMwareCertified   2015-11-26  
<<略>>
uhci-usb-uhci                  1.0-3vmw.600.0.0.2494585             VMware  VMwareCertified   2015-11-26  
tools-light                    6.0.0-1.17.3029758                   VMware  VMwareCertified   2015-11-26  
[root@esxi03:~]
更新されたことが判る。

メンテナンスモードを解除する。
[root@esxi03:~] esxcli system maintenanceMode get
Enabled
[root@esxi03:~] esxcli system maintenanceMode set --enable false
[root@esxi03:~] esxcli system maintenanceMode get
Disabled
[root@esxi03:~]


その0・概要
その1・アップロード
その2・現状の確認
その3・RBSDファイルの内容の確認
その4・メンテナンスモードへの切替
その5・ESXiの更新
その6・再起動と確認
その7・ライセンスの入力

Dell PowerEdge上のVMware ESXi 5.5を6.0 U1に更新する・その5・ESXiの更新

更新する。
~ # time esxcli software vib update --depot=/vmfs/volumes/datastore1/Patch/VMware-VMvisor-Installer-6.0.0-3029758.x86_64-Dell_Customized-A00.zip
Installation Result
   Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.
   Reboot Required: true
   VIBs Installed: Avago_bootbank_lsi-mr3_6.606.12.00-1OEM.600.0.0.2159203, Avago_bootbank_scsi-megaraid-sas_6.804.60.00-1OEM.600.0.0.2159203, BRCM_bootbank_net-tg3_3.137l.v60.1-1OEM.600.0.0.2494585, <<略>>
   VIBs Removed: VMware_bootbank_ata-pata-amd_0.3.10-3vmw.550.0.0.1331820, VMware_bootbank_ata-pata-atiixp_0.4.6-4vmw.550.0.0.1331820, VMware_bootbank_ata-pata-cmd64x_0.2.5-3vmw.550.0.0.1331820, <<略>>
   VIBs Skipped: Dell_bootbank_dell-configuration-vib_6.0-1A00, EMU_bootbank_ima-be2iscsi_10.6.150.3-1OEM.600.0.0.2159203, EMU_bootbank_scsi-be2iscsi_10.6.150.3-1OEM.600.0.0.2159203, <<略>>
real 0m 46.53s
user 0m 0.30s
sys 0m 0.00s
~ #
数十秒で完了する。


その0・概要
その1・アップロード
その2・現状の確認
その3・RBSDファイルの内容の確認
その4・メンテナンスモードへの切替
その5・ESXiの更新
その6・再起動と確認
その7・ライセンスの入力