Upgrade VMstores in Parallel

Greetings,

I just added some PowerShell code that upgrades VMstores in parallel to our GitHub site.  A JSON configuration file is used to configure the VMstores.  For example:

[
    {
        "VmstoreDnsName": "vmstore1",
        "Username": "username",
        "Password": "password",
        "UpgradePathToFile": "C:\Users\TestUser\upgrade_file.rpm"
    },
    {
        "VmstoreDnsName": "vmstore2",
        "Username": "username",
        "Password": "password",
        "UpgradePathToFile": "C:\Users\TestUser\upgrade_file.rpm"
    }
]

The only required attribute is the VmstoreDnsName. All the other attributes are optional and can be from the command line.  Here is a JSON configuration with only the VMstore names:

[
    {
        "VmstoreDnsName": "vmstore1"
    },
    {
        "VmstoreDnsName": "vmstore2"
    }
]

The following code can uses the above file.

Import-Module -Name .\VmstoreUpgrade.psm1
Import-Module -Name .\Parallel-Upgrade.psm1

# Set the user, VMstore configuration file, and upgrade file.
$user = "admin"
$vmstore_list_file = ".\vmstore_upgrade_list.json"
$upgradeFile = "C:\tmp\txos-4.3.1.5-8520.45801.20652.x86_64.rpm"

# Do the parallel upgrade.
Write-Host "Parallel updating VMstores with $upgradeFile"

# Get credentials that will work for all VMstores.
$cred = Get-Credential -Username $Username -Message "Enter valid password for all servers"
$pass = $cred.GetNetworkCredential().Password

# Start the parallel upgrade using a JSON file containing the VMstores, and
# the same username and password for all VMstores. 
Parallel-Upgrade -Verbose -UserName $user -UseSameUserName -Password $pass -UseSamePassword -UpgradeFile $upgradeFile -UseSameUpgradeFile -UseJsonFile $vmstore_list_file

Write-Host "Done Updating"
Write-Host ""

The above code gets a credential that is valid for all VMstores in the configuration file. Then the command line specifies the user name, password, and two options, -UseSameUserName, and -UseSamePassword.

Parallel-Upgrade logs to a dated log file: YYYY-MM-dd-HH-mm-ss_parallel_upgrade.log. The Verbose option will produce extra verbiage to follow along in the process and assist in debugging problems.  Unfortunately, you have to read the Parallel-Upgrade.psm1 module for help.

Until next time,

– Rick –

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s