juin 29 2011

HPVM disk physical/virtual mapping script

Tag: Scripts,UnixUggla @ 17 h 02 min

This is a short script to create a physical (host)/virtual (guest) map.
This is a basic script written quickly, that was used to simplify data migration operations. So improvements welcomed.

    Requirements :

  • script must be run from host. (not guest)
  • ssh must be allowed using keys (no passwd) to all guests.
  • hpvmstatus command must be available from path.

#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my @hpvmstatus=`hpvmstatus`;
my @vms;
my $vm;

my %vm_data;

foreach(@hpvmstatus) {
        ($vm)=$_ =~ /^(.+)\s+[0-9]+\sHPUX\s+On/;
        if (defined($vm)){
                $vm =~ s/\s+//g;
                push (@vms,$vm);
        }
}

foreach $vm (@vms){
        my @hpvmstatus_vm=`hpvmstatus -P $vm`;

        foreach(@hpvmstatus_vm){
                #Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
                #======= ========== === === === === === ========= =========================
                #disk    avio_stor    0   2   0   0   0 disk      /dev/rdisk/disk17

                (my $ftn,my $tgt,my $lun,my $disk)=$_ =~ /^disk\s+avio_stor\s+\d+\s+\d+\s+(\d+)\s+(\d+)\s+(\d+)\s+disk\s+(.+)$/;

                if (defined($ftn)){
                $vm_data{$vm}->{$disk}->{"dev"}=$ftn;
                $vm_data{$vm}->{$disk}->{"tgt"}=$tgt;
                $vm_data{$vm}->{$disk}->{"lun"}=$lun;

                #Convert tgt to the good legacy device
                my $tgtconv=sprintf("%02X",$tgt);
                my $tgtconv_part1;
                my $tgtconv_part2;

                ($tgtconv_part1)=$tgtconv=~/(.)./;
                ($tgtconv_part2)=$tgtconv=~/.(.)/;

                $tgtconv_part1=hex($tgtconv_part1);
                $tgtconv_part2=hex($tgtconv_part2);

                #$vm_data{$vm}->{$disk}->{"legacy"}="c".$ftn."t".$tgtconv_part2."d".$tgtconv_part1;
                $vm_data{$vm}->{$disk}->{"legacy"}="c\\dt".$tgtconv_part2."d".$tgtconv_part1; # Don't know how the instance number is defined (cX) so use a more gereric regexp
                }
        }
}

foreach $vm (@vms){
        my @ioscan=`ssh -q -o stricthostkeychecking=no -o batchmode=yes root\@$vm \"ioscan -m dsf\"`;

        foreach(keys(%{$vm_data{$vm}})){
                my $regex=$vm_data{$vm}->{$_}->{"legacy"}."\$";
                my @vdisk=grep(/$regex/,@ioscan);
                my $vdisk_str=join(",",@vdisk);
                ($vdisk_str)=split(",",$vdisk_str);
                $vdisk_str=~s#\s+/dev/rdsk/.+##g;
                $vdisk_str=~s/\s//g;
                $vm_data{$vm}->{$_}->{"vdisk"}=$vdisk_str;
        }
}

# Debuging purpose
#print Dumper(\%vm_data);

foreach $vm (@vms){
        printf("VM\tPhys\t\t\tVirt\n");

        foreach(keys(%{$vm_data{$vm}})){
                printf("%s\t%s\t%s\n",$vm,$_,$vm_data{$vm}->{$_}->{"vdisk"});

        }
}


mar 16 2011

HPVM B.04.20.05 update and vlan usage

Tag: UnixUggla @ 16 h 19 min

Article en anglais pour partager à l’international.

I recently got a severe issue upgrading HPVM to B.04.20.05.
Of course the « trap » was notified into the manual, but I worked to fix another issue, missed it and ran into serious problems.

So, the idea of this article is to avoid pitfalls documenting them.

  1. Avoid vlan unsupported configuration.

    Extracted from documentation (http://bizsupport2.austin.hp.com/bc/docs/support/SupportManual/c02023903/c02023903.pdf) :

    Do not use the hpvmnet command to create a virtual switch that
    is associated with a VLAN port on the VM Host (that is, a LAN created with lanadmin -V).
    This “nested VLAN” configuration is not supported.

    In the following configuration :

    root@hx05333: /root/home/root # lanscan
    Hardware Station        Crd Hdw   Net-Interface  NM  MAC       HP-DLPI DLPI
    Path     Address        In# State NamePPA        ID  Type      Support Mjr#
    0/0/0/3/0/0/2 0x64315000A911 4   UP    lan4 snap4     3   ETHER     Yes     119
    0/0/0/3/0/0/3 0x64315000A915 5   UP    lan5 snap5     4   ETHER     Yes     119
    0/0/0/3/0/0/4 0x64315000A912 6   UP    lan6 snap6     5   ETHER     Yes     119
    0/0/0/3/0/0/5 0x64315000A916 7   UP    lan7 snap7     6   ETHER     Yes     119
    0/0/0/3/0/0/6 0x64315000A913 8   UP    lan8 snap8     7   ETHER     Yes     119
    0/0/0/3/0/0/7 0x64315000A917 9   UP    lan9 snap9     8   ETHER     Yes     119
    0/0/0/4/0/0/0 0x64315000A918 2   UP    lan2 snap2     9   ETHER     Yes     119
    0/0/0/4/0/0/1 0x64315000A91C 3   UP    lan3 snap3     10  ETHER     Yes     119
    LinkAgg0 0x0017A477FE00 900 UP    lan900 snap900 12  ETHER     Yes     119
    VLAN5001 0x0017A477FE00 5001 UP    lan5001 snap5001 63  ETHER     Yes     119
    VLAN5000 0x0017A477FE00 5000 UP    lan5000 snap5000 62  ETHER     Yes     119
    LinkAgg1 0x000000000000 901 DOWN  lan901 snap901 13  ETHER     Yes     119
    LinkAgg2 0x000000000000 902 DOWN  lan902 snap902 14  ETHER     Yes     119
    LinkAgg3 0x000000000000 903 DOWN  lan903 snap903 15  ETHER     Yes     119
    LinkAgg4 0x000000000000 904 DOWN  lan904 snap904 16  ETHER     Yes     119
    

    1. lan900 is « bonding » of interface lan0 and lan1 carrying all the vlans.
    2. lan5000 is an interface that select a vlan(113) of lan900
    3. lan5001 is an interface that select a vlan(213) of lan900

    Clearly it means that lan5000 or lan5001 must not be connected to the virtual switch.
    Lan900 (the one with all the vlans) must be connected to the switch, and it is virtual switch job to manage the vlan tagging mechanism for all our VM.

    The configuration should be done in the following way.

    1. Create virtual switch.
      hpvmnet -c -S vmlan -n 900
      
    2. Define 2 ports with vlan 113 and 213
      hpvmnet -S vmlan -u portid:1:vlanid:113
      hpvmnet -S vmlan -u portid:2:vlanid:213
      
    3. Attach VM to the ports just created.
      hpvmmodify -P hx05374 -a network:avio_lan::vswitch:vmlan:portid:1
      hpvmmodify -P hx05374 -a network:avio_lan::vswitch:vmlan:portid:2
      
    4. Check virtual switch and VM are ok.
      root@hx05333: /root/home/root # hpvmnet
      Name     Number State   Mode      NamePPA  MAC Address    IPv4 Address
      ======== ====== ======= ========= ======== ============== ===============
      localnet      1 Up      Shared             N/A            N/A
      vmlan        10 Up      Shared    lan900   0x0017a477fe00
      

      root@hx05333: /root/home/root # hpvmnet -S vmlan
      Name     Number State   Mode      NamePPA  MAC Address    IPv4 Address
      ======== ====== ======= ========= ======== ============== ===============
      vmlan        10 Up      Shared    lan900   0x0017a477fe00
      
      [Port Configuration Details]
      Port    Port         Port     Untagged Number of    Active VM    Tagged
      Number  State        Adaptor  VLANID   Reserved VMs              VLANIDs
      ======= ============ ======== ======== ============ ============ =============
      1       Active       avio_lan 113      1            hx05374      none
      2       Active       avio_lan 213      1            hx05374      none
      

      root@hx05333: /root/home/root # hpvmstatus -p1
      [Virtual Machine Details]
      Virtual Machine Name VM #  OS Type State
      ==================== ===== ======= ========
      hx05374                  1 HPUX    On (OS)
      
      [Authorized Administrators]
      Oper Groups             :
      Admin Groups            :
      Oper Users              :
      Admin Users             :
      
      [Virtual CPU Details]
      #vCPUs Entitlement Maximum
      ====== =========== =======
           4       10.0%  100.0%
      
      [Memory Details]
      Total    Reserved
      Memory   Memory
      =======  ========
      17000 MB     64 MB
      
      [Dynamic Memory Information]
      Minimum     Target      Memory      Maximum
      Memory      Memory      Entitlement Memory
      =========== =========== =========== ===========
         512 MB    17018 MB          -     17000 MB
      
      [Storage Interface Details]
      Guest                                 Physical
      Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
      ======= ========== === === === === === ========= =========================
      disk    avio_stor    0   4   0   0   0 disk      /dev/rdisk/disk11
      disk    avio_stor    0   4   0   1   0 disk      /dev/rdisk/disk3
      disk    avio_stor    0   4   0   2   0 disk      /dev/rdisk/disk8
      disk    avio_stor    0   4   0   3   0 disk      /dev/rdisk/disk17
      
      [Network Interface Details]
      Interface Adaptor    Name/Num   PortNum Bus Dev Ftn Mac Address
      ========= ========== ========== ======= === === === =================
      vswitch   avio_lan   vmlan      1         0   0   0 36-af-e6-d1-20-bc
      vswitch   avio_lan   vmlan      2         0   1   0 8e-b5-a9-a9-14-23
      
      [Misc Interface Details]
      Guest                                 Physical
      Device  Adaptor    Bus Dev Ftn Tgt Lun Storage   Device
      ======= ========== === === === === === ========= =========================
      serial  com1                           tty       console
      
  2. Update HPVM to B.04.20.05.

    1. Patch the VM with QPK bundle.
    2. Add VM patches to avoid dynamic memory issue.

      This will avoid to be in the case defined by this article :
      http://h20000.www2.hp.com/bizsupport/TechSupport/Document.jsp?objectID=c02692588&lang=en&cc=us&taskId=101&prodSeriesId=4146128&prodTypeId=18964

      Add the PHSS_41543 and PHSS_41550, this will give the following patch list due to dependencies.

      PHKL_41227 (2) clock cumulative patch
      PHSS_41191 (2) HPVM B.04.20.05 VMMIGRATE PATCH
      PHSS_41413 (2) HPVM B.04.20.05 vmGuestLib
      PHSS_41543 (2) [S] HPVM B.04.20.05 CORE PATCH
      PHSS_41550 (2) HPVM B.04.20.05 HPVM-VMSGTK
      
    3. Clean up VM.
      1. Remove HPVM product.
        swremove -x autoreboot=true T2767CC VMKernelSW
        

        Note : VMKernelSW should not be available on the VM

      2. Remove HostAVIO* product.
        swremove -p -x autoreboot=true  HostAVIOStor HostAvioLan
        swremove -x autoreboot=true  HostAVIOStor HostAvioLan
        
      3. Upgrade GuestAVIO* product.
        swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan
        swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan
        

      4. VM should now have only the following product.
        root@hx05374: /root/home/root # swlist -l bundle | egrep -i "HPVM|Integ"
          GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
          GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
          HPVM-Guest            B.04.20     Integrity VM Guest
          LDAPUX                B.04.20        LDAP-UX Integration
          VMGuestLib            B.04.20     Integrity VM Guest Support Libraries
          VMProvider            B.04.20     WBEM Provider for Integrity VM
        
    4. Install full QPK on host including FEATURE11i bundle.
      Note : FEATURE11i will be checked by HPVM product script before upgrade.
    5. Upgrade AVIO software.
      swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan HostAVIOStor HostAvioLan
      swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux GuestAVIOStor GuestAvioLan HostAVIOStor HostAvioLan
      
    6. Upgrade HPVM product.

      Do not force install, correct the dependencies issues by bringing the required bundle (VMGuestLib, VMGuestSW, AVIO* …) into the source depot.

      swinstall -p -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux T2767CC
      swinstall -x autoreboot=true -x logdetail=true -s calisson:/var/depot/hp-ux/11.31/hp-ux T2767CC
      
    7. Check host, the following command should report something like this.
      root@hx05333: /root/home/root # swlist -l bundle | egrep "Integri|HPVM"
        GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
        GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
        HostAVIOStor          B.11.31.1009   HPVM Host AVIO Storage Software
        HostAvioLan           B.11.31.1009   HPVM Host AVIO LAN Software
        T2767CC               B.04.20.05     Integrity VM
        VMGuestLib            B.04.20.05     Integrity VM Guest Support Libraries
        VMGuestSW             B.04.20.05     Integrity VM Guest Support Software
        VMKernelSW            B.04.20        Integrity VM Kernel Software
      

      Note : VMKernelSW remains at B.04.20, this is normal B.04.20.05 does not contain a new « host » kernel.

    8. Copy and register a depot from /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd on the host.
      swcopy -p -x enforce_dependencies=false -s /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd \* @ /var/depot/hpvm-guest
      swcopy -x enforce_dependencies=false -s /opt/hpvm/guest-images/hpux/11iv3/hpvm_guest_depot.11iv3.sd \* @ /var/depot/hpvm-guest
      swreg -l depot /var/depot/hpvm-guest
      
    9. Install VM tools on the VM.
      swinstall -p -x autoreboot=true -s hx05333:/var/depot/hpvm-guest HPVM-Guest vmProvider
      swinstall -x autoreboot=true -s hx05333:/var/depot/hpvm-guest HPVM-Guest vmProvider
      
    10. Check VM, the output should be similar to the following lines.
      root@hx05374: /root/home/root # swlist -l bundle | egrep -i "HPVM|Integri"
        GuestAVIOStor         B.11.31.1009   HPVM Guest AVIO Storage Software
        GuestAvioLan          B.11.31.1009   HPVM Guest AVIO LAN Software
        HPVM-Guest            B.04.20.05     Integrity VM Guest
        VMGuestLib            B.04.20.05     Integrity VM Guest Support Libraries
        VMProvider            B.04.20.05     WBEM Provider for Integrity VM
      

Now host and VM should be upgraded correctly.