Tuesday, September 29, 2015

Installing Dell's OpenManage Server Administrator (OMSA) so we can find info about server

We have a Dell server we need to find some info about. We could just go to the server room with a flashlight and get its Chassis Service Tag (fancy name for serial number?), model number, and so on. But, this is a proper rackmount server; we should be able to do that remotely.

And we can. Normally that is done using the iDRAC interface, which is a glorified single board computer in a card stuck on the back of the server running a little webserver we can use to configure the server, install OS, and other common housekeeping. Problem is in this particular box we never bothered to run an ethernet cable to it. But, we can ssh into the server; can we do the same from there?

Actually we can, but we need to get some Dell packages first.

NOTE: This server happens to be running a release of xenserver. Other than it tying down package versions, we should not have any other problems. But, should is a funny word...

Getting OMSA

Dell offers two websites,

If we run the bootstrap.cgi, it should add the dell repo for us:

[root@xenbox ~]# wget -q -O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    Importing key into RPM.
Downloading GPG key: http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
    Importing key into RPM.
Write repository configuration
Downloading repository RPM
[root@xenbox ~]#

Let's check:

[root@xenbox ~]# ls /etc/yum.repos.d/
CentOS-Base.repo       CentOS-Media.repo  Citrix.repo
CentOS-Debuginfo.repo  CentOS-Vault.repo  dell-omsa-repository.repo
[root@xenbox ~]#
dell-omsa-repository.repo is the repo file added when we ran bootstrap.cgi ( Citrix.repo is the xenserver repo as it is owned by Citrix).

Let's install the required package:

[root@xenbox ~]# yum install dell_ft_install
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
citrix                                                   |  951 B     00:00
http://linux.dell.com/repo/hardware/latest/platform_independent/rh50_64/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: dell-omsa-indep. Please verify its path and try again
[root@xenbox ~]#
Er, it does not look very happy. What is wrong? And why does it say rh50_64? That makes me think it wants RedHat 5.0; that is pretty old. We are in 2015 after all. Don't know. In any case, http://linux.dell.com/repo/hardware/latest/platform_independent/rh50_64/ exists. But no repodata dir. The repo config file looks like this
[root@xenbox ~]# cat /etc/yum.repos.d/dell-omsa-repository.repo
[dell-omsa-indep]
name=Dell OMSA repository - Hardware independent
type=rpm-md
mirrorlist=http://linux.dell.com/repo/hardware/latest/mirrors.cgi?osname=el$releasever&basearch=$basearch&native=1&dellsysidpluginver=$dellsysidpluginver
gpgcheck=1
gpgkey=http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
enabled=1
failover=priority
bootstrapurl=http://linux.dell.com/repo/hardware/latest/bootstrap.cgi


[dell-omsa-specific]
name=Dell OMSA repository - Hardware specific
type=rpm-md
mirrorlist=http://linux.dell.com/repo/hardware/latest/mirrors.cgi?osname=el$releasever&basearch=$basearch&native=1&sys_ven_id=$sys_ven_id&sys_dev_id=$sys_dev_id&dellsysidpluginver=$dellsysidpluginver
gpgcheck=1
gpgkey=http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-dell
    http://linux.dell.com/repo/hardware/latest/RPM-GPG-KEY-libsmbios
enabled=1
failover=priority
bootstrapurl=http://linux.dell.com/repo/hardware/latest/bootstrap.cgi
[root@xenbox ~]#
It looks like any repo config file out there. How is it guessing the OS release is 5.0-something? When I look at the release file
[root@xenbox ~]# cat /etc/redhat-release
XenServer release 6.5.0-90233c (xenenterprise)
[root@xenbox ~]#
OK, notice it says XenServer and not CentOS. It just hit me: what is the centos release associated with the XenServer release 6.5.0-90233c? Let's cheat
[root@xenbox ~]# yum provides /etc/redhat-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
10:centos-release-5-10.el5.centos.x86_64 : CentOS release file
Repo        : installed
Matched from:
Other       : Provides-match: /etc/redhat-release

[root@xenbox ~]#
Yeah... xenserver is running on centos 5.10. Lovely. At least now we know the issue. Also, according to a thread in the Dell forum, we need to go back in time we version of the bootstrap.cgi script,
wget http://linux.dell.com/repo/hardware/Linux_Repository_14.12.00/bootstrap.cgi
and try again
yum --enablerepo=base install srvadmin-all
which this time will install properly. So, let's use it.

Using OMSA

Binaries as installed in /opt/dell/srvadmin/bin/, and we want to use /opt/dell/srvadmin/bin/omreport:

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis fans
Error! No fan probes found on this system.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis temps
Error! No temperature probes found on this system.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis processors
Error! Hardware or feature not present.

[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis remoteaccess
Error! Hardware or feature not present.

[root@xenbox ~]#
Why is it not working? Let's cut this story short: we need to start the services associated with OMSA:
[root@xenbox ~]# /opt/dell/srvadmin/sbin/srvadmin-services.sh start
Starting Systems Management Device Drivers:
Starting dell_rbu:                                         [  OK  ]
Starting ipmi driver:                                      [  OK  ]
Starting snmpd:                                            [  OK  ]
Starting Systems Management Data Engine:
Starting dsm_sa_datamgrd:                                  [  OK  ]
Starting dsm_sa_eventmgrd:                                 [  OK  ]
Starting dsm_sa_snmpd:                                     [  OK  ]
Starting DSM SA Shared Services:                           [  OK  ]

Starting DSM SA Connection Service:                        [  OK  ]


[root@xenbox ~]#
And now, it works!
[root@xenbox ~]# /opt/dell/srvadmin/bin/omreport chassis info
Chassis Information

Index                                    : 0
Chassis Name                             : Main System Chassis
Host Name                                : xenbox
iDRAC7 Version                           : 1.57.57 (Build 4)
Lifecycle Controller 2 Version           : 1.4.2.12
Chassis Model                            : PowerEdge R320
Chassis Lock                             : Present
Chassis Service Tag                      : AD92C42
Express Service Code                     : 24612345426
Chassis Asset Tag                        : Unknown
Flash chassis identify LED state         : Off
Flash chassis identify LED timeout value : 300

[root@xenbox ~]#
Next step is using openmanage to create a raid; we will do that in another article.

Tuesday, September 08, 2015

md5 checksum in powershell

It seems I have been stuck in Windows recently. The main annoyance with that is it loves to fight me and hates to tell me what is going on. As a result, sometimes I need to write my own tools. And, yes, they do tend to emulate what I have used in Linux. Take for example md5sum, an example of a command that just happens to be related to the topic of this article.

Here is how md5sum works in Linux:

raub@desktop:~$ md5sum disallowedcert.sst
6e8bf95470e7f1ca0626012ea21e55f7 disallowedcert.sst
raub@desktop:~$

As the man page tells us, there are other options we can use. But, I do not use most of them. So, how about if we write a quick powershell script to emulate at least the basic usage of md5sum?

Warning

The md5 should not be used for, say, verify integrity of a file if you care about security; the MD5 algorithm can be hacked using collision attacks.

The code

Here is a first shot at the code

# emulate md5sum in powershell
foreach ($file in $args)
{
   $md5 = New-Object -typeName `
          System.Security.Cryptography.MD5CryptoServiceProvider
   $hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($file)))
   echo "$hash $file"
}
PS C:\Users\User\test> powershell -executionpolicy bypass -file .\md5.ps1 .\disallowedcert.sst
6E-8B-F9-54-70-E7-F1-CA-06-26-01-2E-A2-1E-55-F7
PS C:\Users\User\test> powershell -executionpolicy bypass -file .\md5.ps1 .\disallowedcert.sst .\e098
cf355c19953274d84772a1cec96dc3356ca.crt
6E-8B-F9-54-70-E7-F1-CA-06-26-01-2E-A2-1E-55-F7
1C-BC-A2-83-77-BA-25-04-3D-6D-42-6E-E2-11-34-55
PS C:\Users\User\test>

Let's improve on it a bit then

# emulate md5sum in powershell
foreach ($file in $args)
{
   $md5 = New-Object -typeName `
          System.Security.Cryptography.MD5CryptoServiceProvider
   $hash = [System.BitConverter]::ToString($md5.ComputeHash([System.IO.File]::ReadAllBytes($file))) `
           -replace "-",""
   echo "$hash $file"
}

Let's try it out

PS C:\Users\User\test> powershell -executionpolicy bypass -file md5.ps1 md5sum.ps1 ntpTime.ps1 
F1930269F287A434993172A362269F8E md5sum.ps1
FC6ED0787947524543D34CFBA3BE641A ntpTime.ps1

PS C:\Users\User\test> 

That's much more like it.

Other versions

If you do not like my script there are a few versions out there you can download and run instead. Pick your poison!