Automation

 View Only
Expand all | Collapse all

Help with few steps in Post configuration of esx4i server

  • 1.  Help with few steps in Post configuration of esx4i server

    Posted Nov 19, 2009 09:10 PM

    Hello,

    I'm currently in the process of finishing up my post config powershell script but i do have 2 questions/issues that i'm trying to resolve.

    First one is:

    Is it possible to restart the host in the middle of a configuration script and have the script wait until host is restarted? I would like to set up all my networking, restart the host to make sure everything saves correctly. then finish the rest of my script.

    My second quesiton/issue is how do I run vCLI commands from powerCLI? We have HP Blades so after esx4i setup we need to install HP CIM stuff. this is fairly easy to do and we handle it via vihostupdate.pl script in vCLI. my quesiton is how can I run it and call vihostupdate.pl from powershell script?

    thanks

    alex



  • 2.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 19, 2009 10:08 PM

    The first question depends if you are connected to vCenter or the ESXi host.

    See for further info.

    You could use something like plink.exe from the PuTTY suite to execute commands.

    But since you're working with an ESXi server (no COS) I'm not 100% sure this will work for the vCLI script.

    See for a sample.



  • 3.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 19, 2009 11:24 PM

    Thanks for the links. I will go through them.

    I think i might have worded my second question wrong.

    let me try to explain it. My current post config script does everything that is needed to be configured. the only thing that I run manually after its done is the following command by launching vCLI:

    vihostupdate.pl --server hostname --username root --password 12345 --install -b c:\hp-esxi4.0uX-bundle-1.1.zip which is basically HP Offline Bundle for VMware ESXi Server.

    My question is: is it possible to execute that line from within PowerCLI console that is running my configure script? so that i don't have to run it manually

    thanks

    alex



  • 4.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 19, 2009 11:47 PM

    You can run the plink.exe command from a PS script.

    Have a look at the example in the link.



  • 5.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 05:14 AM

    Thanks LucD. I just looked at the example that you linked to. Is my understanding correct that plink.exe would launch putty and ssh to the esx4i host and execute the remote command? or can plink.exe execute vcli console on my workstation where i run my powershell script from and run the vihostupdate.pl command with needed parameters? I'm a bit confused.

    thanks

    alex



  • 6.  RE: Help with few steps in Post configuration of esx4i server
    Best Answer

    Posted Nov 20, 2009 09:38 AM

    Carter is too modest, the new PowerCLI build also contains a Restart-VMHost cmdlet.

    That simplifies part of your first question.



  • 7.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 01:48 PM

    Oh this is awesome. Carter, Luc - thank you for your help



  • 8.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 03:58 PM

    so i hit a little snag while trying to use set-nicteamingpolicy cmdlet.

    I'm sure its my lack of knowledge, but I'm learing as I go along.

    When i try to run the following:

    $policy = Get-VirtualSwitch -VMHost (Get-VMHost *) -Name vSwitch2 | Get-NicTeamingPolicy

    $policy

    | Set-NicTeamingPolicy -LoadBalancingPolicy LoadBalanceSrcId

    -NetworkFailoverDetectionPolicy LinkStatus -NotifySwitches $true

    -FailbackEnabled $true -MakeNicActive "vmnic4" -MakeNicStandby "vmnic10"

    I get the following error:

    The method or operation is not implemented.

    At :line:3 char:30

    +

    $policy | Set-NicTeamingPolicy <<<< -LoadBalancingPolicy

    LoadBalanceSrcId -NetworkFailoverDetectionPolicy LinkStatus

    -NotifySwitches $true -FailbackEnabled $true -MakeNicActive "vmnic1"

    -MakeNicStandby "vmnic2"

    I know it has something to do with -makenicactive and standby because if i remove that from the code it works fine. I'm just not sure what those options require as a parameter. any help is greatly appreciated.

    Alex



  • 9.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 05:24 PM

    Do you have more than one VMHost when you run Get-VMHost? If so I would expect you'd need to use a foreach loop since $policy would be an array.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]



  • 10.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 05:28 PM

    Nope. line that i didn't paste above was connect-viserver hostname

    so I only connect to one host



  • 11.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 05:47 PM

    Are you sure those NICs belong to the switch you're updating?

    I don't think it will make a difference but can you try without the quotes? If it still doesn't work you may need to try piping in objects produced by Get-VMHostNetworkAdapter, maybe the automatic string translation is broken, though I've seen it work before so I sort of doubt it.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]



  • 12.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 05:53 PM

    Yep I'm sure that those nics are part of the vsiwtch i'm updating. Just tried it without quotes and i get same error as with quotes.



  • 13.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 06:26 PM

    Have you tried splitting it into multiple commands, I'm thinking most specifically about the makeactive and makestandby being in separate commands.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]



  • 14.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 08:01 PM

    just added this code:

    $policy | set-nicteamingpolicy -MakeNicActive "vmnic1" -makenicstandby "vmnic0"

    and same error occured as when its on same line

    "The Method or operation is not implemented"



  • 15.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 21, 2009 03:14 AM

    So for some reason you have to make the active/standby/unused changes all in different calls. This is odd, but maybe the logic was too complex to do multiple updates.

    See the transcript below:

    [vSphere PowerCLI] C:\> get-virtualswitch -name Internal | Get-NicTeamingPolicy
    VirtualSwitchId                : key-vim.host.VirtualSwitch-Internal
    BeaconInterval                 :
    LoadBalancingPolicy            : LoadBalanceSrcId
    NetworkFailoverDetectionPolicy : LinkStatus
    NotifySwitches                 : True
    FailbackEnabled                : True
    ActiveNic                      : {vmnic1, vmnic2, vmnic3}
    StandbyNic                     :
    UnusedNic                      :
    CheckBeacon                    : False
    VmHostId                       : HostSystem-ha-host
    
    [vSphere PowerCLI] C:\> get-virtualswitch -name Internal | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicStandby vmnic2 -MakeNicUnused vmnic3
    Set-NicTeamingPolicy : The method or operation is not implemented.
    At line:1 char:79
    + get-virtualswitch -name Internal | Get-NicTeamingPolicy | Set-NicTeamingP
    olicy  <<<< -MakeNicStandby vmnic2 -MakeNicUnused vmnic3
    
    [vSphere PowerCLI] C:\> get-virtualswitch -name Internal | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicStandby vmnic2
    VirtualSwitchId                : key-vim.host.VirtualSwitch-Internal
    BeaconInterval                 :
    LoadBalancingPolicy            : LoadBalanceSrcId
    NetworkFailoverDetectionPolicy : LinkStatus
    NotifySwitches                 : True
    FailbackEnabled                : True
    ActiveNic                      : {vmnic1, vmnic3}
    StandbyNic                     : {vmnic2}
    UnusedNic                      :
    CheckBeacon                    : False
    VmHostId                       : HostSystem-ha-host
    
    [vSphere PowerCLI] C:\> get-virtualswitch -name Internal | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicUnused vmnic3
    VirtualSwitchId                : key-vim.host.VirtualSwitch-Internal
    BeaconInterval                 :
    LoadBalancingPolicy            : LoadBalanceSrcId
    NetworkFailoverDetectionPolicy : LinkStatus
    NotifySwitches                 : True
    FailbackEnabled                : True
    ActiveNic                      : {vmnic1}
    StandbyNic                     : {vmnic2}
    UnusedNic                      : {vmnic3}
    CheckBeacon                    : False
    VmHostId                       : HostSystem-ha-host
    

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]



  • 16.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 21, 2009 06:46 AM

    Yep. that was it. thanks for investigating it for me.

    quick question for you. i noticed in your transcript that you run the command without get-vmhost parameter like here:

    get-virtualswitch -name Internal | Get-NicTeamingPolicy  
    

    when i try to run this i get an error about "Missing an argument for parameter 'vmhost'. How do you not get the same error with your script?



  • 17.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 21, 2009 03:32 PM

    I was connected directly to ESX, in which case you don't need to specify a VMhost parameter. If you connect to vCenter you always do, even if you only have one ESX host.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]



  • 18.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 24, 2009 03:51 PM

    thanks for the tip. THat worked



  • 19.  RE: Help with few steps in Post configuration of esx4i server

    Posted Nov 20, 2009 06:30 AM

    With PowerCLI 4.0 U1 (just released) we have added Install-VMHostPatch. You might try that as an alternative to vihostupdate.

    =====

    Carter Shanklin

    Read the PowerCLI Blog
    [Follow me on Twitter|http://twitter.com/cshanklin]