Merge pull request #85 from iamshital/master
VM diagnostic test case + Extension Tests Improvments + ARM single VM improvements.
This commit is contained in:
Коммит
83a35cb732
|
@ -98,6 +98,10 @@ Function RunTestsOnCycle ($cycleName , $xmlConfig, $Distro )
|
|||
LogMsg "Base VHD name - $BaseOsVHD"
|
||||
}
|
||||
}
|
||||
if (!$BaseOsImage -and !$BaseOSVHD)
|
||||
{
|
||||
Throw "Please give ImageName or OsVHD for deployment."
|
||||
}
|
||||
LogMsg "Loading the cycle Data..."
|
||||
$currentCycleData = GetCurrentCycleData -xmlConfig $xmlConfig -cycleName $cycleName
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -167,7 +167,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1050,7 +1050,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1078,7 +1078,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1154,7 +1154,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1230,7 +1230,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1306,7 +1306,7 @@
|
|||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -1330,8 +1330,8 @@
|
|||
<HostedService>
|
||||
<VirtualMachine>
|
||||
<state></state>
|
||||
<InstanceSize>Basic_A1</InstanceSize>
|
||||
<ARMInstanceSize>Standard_A1</ARMInstanceSize>
|
||||
<InstanceSize>Small</InstanceSize>
|
||||
<ARMInstanceSize>Basic_A1</ARMInstanceSize>
|
||||
<EndPoints>
|
||||
<Name>SSH</Name>
|
||||
<Protocol>tcp</Protocol>
|
||||
|
@ -3696,14 +3696,29 @@
|
|||
<testScriptps1>ICA-CUSTOM-SCRIPT-EXTENSION-TEST.ps1</testScriptps1>
|
||||
<setupType>ExtensionTest</setupType>
|
||||
<ProvisionTimeExtensions>CustomScriptTouchCommand</ProvisionTimeExtensions>
|
||||
<PostProvisionExtensions>TO_BE_DONE</PostProvisionExtensions>
|
||||
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
|
||||
<Priority>P0</Priority>
|
||||
</test>
|
||||
<test>
|
||||
<testName>ICA-OS-PATCHING-EXTENSION-TEST</testName>
|
||||
<testScript></testScript>
|
||||
<testScriptps1>ICA-OS-PATCHING-EXTENSION-TEST.ps1</testScriptps1>
|
||||
<ProvisionTimeExtensions>OsPatching</ProvisionTimeExtensions>
|
||||
<setupType>ExtensionTest</setupType>
|
||||
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
|
||||
<Priority>P0</Priority>
|
||||
</test>
|
||||
<test>
|
||||
<testName>ICA-VM-DIAGNOSTIC-EXTENSION-TEST</testName>
|
||||
<testScript></testScript>
|
||||
<testScriptps1>ICA-VM-DIAGNOSTIC-EXTENSION-TEST.ps1</testScriptps1>
|
||||
<ProvisionTimeExtensions>LinuxDiagnosticDefaultDataSet</ProvisionTimeExtensions>
|
||||
<setupType>ExtensionTest</setupType>
|
||||
<SupportedExecutionModes>AzureServiceManagement</SupportedExecutionModes>
|
||||
<Priority>P0</Priority>
|
||||
</test>
|
||||
</testsDefinition>
|
||||
|
||||
|
||||
|
||||
<testCycles>
|
||||
<!-- Setup related tests -->
|
||||
<Cycle>
|
||||
|
@ -4285,6 +4300,12 @@
|
|||
<test>
|
||||
<Name>ICA-CUSTOM-SCRIPT-EXTENSION-TEST</Name>
|
||||
</test>
|
||||
<test>
|
||||
<Name>ICA-OS-PATCHING-EXTENSION-TEST</Name>
|
||||
</test>
|
||||
<test>
|
||||
<Name>ICA-VM-DIAGNOSTIC-EXTENSION-TEST</Name>
|
||||
</test>
|
||||
</Cycle>
|
||||
<Cycle>
|
||||
<cycleName>DEBUG</cycleName>
|
||||
|
|
|
@ -233,6 +233,51 @@ for ($i =0; $i -lt 30; $i++)
|
|||
}
|
||||
|
||||
|
||||
#Check if the deployment Type is single VM deployment or multiple VM deployment
|
||||
$numberOfVMs = 0
|
||||
foreach ( $newVM in $RGXMLData.VirtualMachine)
|
||||
{
|
||||
$numberOfVMs += 1
|
||||
}
|
||||
|
||||
$StorageProfileScriptBlock = {
|
||||
Add-Content -Value "$($indents[4])^storageProfile^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^osDisk^ : " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5]){" -Path $jsonFile
|
||||
if ( $osVHD )
|
||||
{
|
||||
if ( $osImage)
|
||||
{
|
||||
LogMsg "Overriding ImageName with user provided VHD."
|
||||
}
|
||||
LogMsg "Using VHD : $osVHD"
|
||||
Add-Content -Value "$($indents[6])^image^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^uri^: ^[concat('http://',variables('StorageAccountName'),'.blob.core.windows.net/vhds/','$osVHD')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^osType^: ^Linux^," -Path $jsonFile
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMsg "Using ImageName : $osImage"
|
||||
Add-Content -Value "$($indents[6])^sourceImage^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^id^: ^[variables('CompliedSourceImageName')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
}
|
||||
Add-Content -Value "$($indents[6])^name^: ^$vmName-OSDisk^," -Path $jsonFile
|
||||
#Add-Content -Value "$($indents[6])^osType^: ^Linux^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^vhd^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^uri^: ^[concat('http://',variables('StorageAccountName'),'.blob.core.windows.net/vhds/','$vmName-$RGrandomWord-osdisk.vhd')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^caching^: ^ReadWrite^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^createOption^: ^FromImage^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])}" -Path $jsonFile
|
||||
}
|
||||
|
||||
LogMsg "Generating Template : $azuredeployJSONFilePath"
|
||||
#region Generate JSON file
|
||||
Set-Content -Value "$($indents[0]){" -Path $jsonFile -Force
|
||||
|
@ -302,19 +347,6 @@ Set-Content -Value "$($indents[0]){" -Path $jsonFile -Force
|
|||
LogMsg "Added Public IP Address $PublicIPName.."
|
||||
#endregion
|
||||
|
||||
#region availabilitySets
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^$apiVersion^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^type^: ^Microsoft.Compute/availabilitySets^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^name^: ^[variables('availabilitySetName')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^location^: ^[variables('location')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^properties^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[2])}," -Path $jsonFile
|
||||
LogMsg "Added availabilitySet $availibilitySetName.."
|
||||
#endregion
|
||||
|
||||
#region virtualNetworks
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^$apiVersion^," -Path $jsonFile
|
||||
|
@ -353,7 +385,26 @@ Set-Content -Value "$($indents[0]){" -Path $jsonFile -Force
|
|||
Add-Content -Value "$($indents[2])}," -Path $jsonFile
|
||||
LogMsg "Added Virtual Network $virtualNetworkName.."
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Multiple VM Deployment
|
||||
|
||||
if ( $numberOfVMs -gt 1 )
|
||||
{
|
||||
#region availabilitySets
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^$apiVersion^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^type^: ^Microsoft.Compute/availabilitySets^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^name^: ^[variables('availabilitySetName')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^location^: ^[variables('location')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^properties^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[2])}," -Path $jsonFile
|
||||
LogMsg "Added availabilitySet $availibilitySetName.."
|
||||
#endregion
|
||||
|
||||
#region LoadBalancer
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^$apiVersion^," -Path $jsonFile
|
||||
|
@ -579,8 +630,6 @@ foreach ( $newVM in $RGXMLData.VirtualMachine)
|
|||
Add-Content -Value "$($indents[3])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[2])}," -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
$vmAdded = $false
|
||||
$role = 0
|
||||
|
@ -724,43 +773,11 @@ foreach ( $newVM in $RGXMLData.VirtualMachine)
|
|||
#endregion
|
||||
|
||||
#region Storage Profile
|
||||
Add-Content -Value "$($indents[4])^storageProfile^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^osDisk^ : " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5]){" -Path $jsonFile
|
||||
if ( $osVHD )
|
||||
{
|
||||
if ( $osImage)
|
||||
{
|
||||
LogMsg "Overriding ImageName with user provided VHD."
|
||||
}
|
||||
LogMsg "Using VHD : $osVHD"
|
||||
Add-Content -Value "$($indents[6])^image^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^uri^: ^[concat('http://',variables('StorageAccountName'),'.blob.core.windows.net/vhds/','$osVHD')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^osType^: ^Linux^," -Path $jsonFile
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMsg "Using ImageName : $osImage"
|
||||
Add-Content -Value "$($indents[6])^sourceImage^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^id^: ^[variables('CompliedSourceImageName')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
}
|
||||
Add-Content -Value "$($indents[6])^name^: ^$vmName-OSDisk^," -Path $jsonFile
|
||||
#Add-Content -Value "$($indents[6])^osType^: ^Linux^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^vhd^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^uri^: ^[concat('http://',variables('StorageAccountName'),'.blob.core.windows.net/vhds/','$vmName-$RGrandomWord-osdisk.vhd')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^caching^: ^ReadWrite^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^createOption^: ^FromImage^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])}," -Path $jsonFile
|
||||
LogMsg "Added Virtual Machine $vmName"
|
||||
Invoke-Command -ScriptBlock $StorageProfileScriptBlock
|
||||
Add-Content -Value "$($indents[4])," -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
LogMsg "Added Virtual Machine $vmName"
|
||||
|
||||
#region Network Profile
|
||||
Add-Content -Value "$($indents[4])^networkProfile^: " -Path $jsonFile
|
||||
|
@ -786,6 +803,146 @@ foreach ( $newVM in $RGXMLData.VirtualMachine)
|
|||
$vmCount = $role
|
||||
}
|
||||
Add-Content -Value "$($indents[1])]" -Path $jsonFile
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Single VM Deployment...
|
||||
if ( $numberOfVMs -eq 1)
|
||||
{
|
||||
if($newVM.RoleName)
|
||||
{
|
||||
$vmName = $newVM.RoleName
|
||||
}
|
||||
else
|
||||
{
|
||||
$vmName = $RGName+"-role-0"
|
||||
}
|
||||
$vmAdded = $false
|
||||
$newVM = $RGXMLData.VirtualMachine
|
||||
$vmCount = $vmCount + 1
|
||||
$VnetName = $RGXMLData.VnetName
|
||||
$instanceSize = $newVM.ARMInstanceSize
|
||||
$SubnetName = $newVM.SubnetName
|
||||
$DnsServerIP = $RGXMLData.DnsServerIP
|
||||
$NIC = "NIC" + "-$vmName"
|
||||
|
||||
#region networkInterfaces
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^2015-05-01-preview^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^type^: ^Microsoft.Network/networkInterfaces^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^name^: ^$NIC^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^location^: ^[variables('location')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^dependsOn^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])[" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])^[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])^[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])]," -Path $jsonFile
|
||||
|
||||
Add-Content -Value "$($indents[3])^properties^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])^ipConfigurations^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])[" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^name^: ^ipconfig1^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])^properties^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^privateIPAllocationMethod^: ^Dynamic^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^publicIPAddress^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[8])^id^: ^[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])}," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^subnet^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[8])^id^: ^[variables('subnet1Ref')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])]" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[2])}," -Path $jsonFile
|
||||
LogMsg "Added NIC $NIC.."
|
||||
#endregion
|
||||
|
||||
#region virtualMachines
|
||||
Add-Content -Value "$($indents[2]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^apiVersion^: ^2015-05-01-preview^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^type^: ^Microsoft.Compute/virtualMachines^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^name^: ^$vmName^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^location^: ^[variables('location')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])^dependsOn^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])[" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])^[concat('Microsoft.Network/networkInterfaces/', '$NIC')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3])]," -Path $jsonFile
|
||||
|
||||
#region VM Properties
|
||||
Add-Content -Value "$($indents[3])^properties^:" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[3]){" -Path $jsonFile
|
||||
#region Hardware Profile
|
||||
Add-Content -Value "$($indents[4])^hardwareProfile^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^vmSize^: ^$instanceSize^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])}," -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
#region OSProfie
|
||||
Add-Content -Value "$($indents[4])^osProfile^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^computername^: ^$vmName^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^adminUsername^: ^[variables('adminUserName')]^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^adminPassword^: ^[variables('adminPassword')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])}," -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
#region Storage Profile
|
||||
Invoke-Command -ScriptBlock $StorageProfileScriptBlock
|
||||
Add-Content -Value "$($indents[4])," -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
#region Network Profile
|
||||
Add-Content -Value "$($indents[4])^networkProfile^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^networkInterfaces^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])[" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^id^: ^[resourceId('Microsoft.Network/networkInterfaces','$NIC')]^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])]," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])^inputEndpoints^: " -Path $jsonFile
|
||||
Add-Content -Value "$($indents[5])[" -Path $jsonFile
|
||||
|
||||
#region Add Endpoints...
|
||||
$EndPointAdded = $false
|
||||
foreach ( $endpoint in $newVM.EndPoints)
|
||||
{
|
||||
if ( $EndPointAdded )
|
||||
{
|
||||
Add-Content -Value "$($indents[6])," -Path $jsonFile
|
||||
}
|
||||
Add-Content -Value "$($indents[6]){" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^enableDirectServerReturn^: ^False^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^endpointName^: ^$($endpoint.Name)^," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^privatePort^: $($endpoint.LocalPort)," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^publicPort^: $($endpoint.PublicPort)," -Path $jsonFile
|
||||
Add-Content -Value "$($indents[7])^protocol^: ^$($endpoint.Protocol)^" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[6])}" -Path $jsonFile
|
||||
LogMsg "Added input endpoint Name:$($endpoint.Name) PublicPort:$($endpoint.PublicPort) PrivatePort:$($endpoint.LocalPort) Protocol:$($endpoint.Protocol)."
|
||||
$EndPointAdded = $true
|
||||
}
|
||||
#endregion
|
||||
|
||||
Add-Content -Value "$($indents[5])]" -Path $jsonFile
|
||||
Add-Content -Value "$($indents[4])}" -Path $jsonFile
|
||||
#endregion
|
||||
|
||||
Add-Content -Value "$($indents[3])}" -Path $jsonFile
|
||||
LogMsg "Added Network Profile."
|
||||
#endregion
|
||||
LogMsg "Added Virtual Machine $vmName"
|
||||
Add-Content -Value "$($indents[2])}" -Path $jsonFile
|
||||
#endregion
|
||||
Add-Content -Value "$($indents[1])]" -Path $jsonFile
|
||||
#endregion
|
||||
}
|
||||
Add-Content -Value "$($indents[0])}" -Path $jsonFile
|
||||
Set-Content -Path $jsonFile -Value (Get-Content $jsonFile).Replace("^",'"') -Force
|
||||
#endregion
|
||||
|
|
|
@ -448,18 +448,28 @@ Function GenerateCommand ($Setup, $serviceName, $osImage, $HSData)
|
|||
$vmCount = 0
|
||||
if ( $CurrentTestData.ProvisionTimeExtensions )
|
||||
{
|
||||
$extensionString = [string](Get-Content .\XML\Extensions.xml)
|
||||
foreach ($line in $extensionString.Split())
|
||||
$extensionString = (Get-Content .\XML\Extensions.xml)
|
||||
foreach ($line in $extensionString.Split("`n"))
|
||||
{
|
||||
if ($line -imatch "EXECUTE-PS-")
|
||||
if ($line -imatch ">$($CurrentTestData.ProvisionTimeExtensions)<")
|
||||
{
|
||||
$ExecutePS = $true
|
||||
}
|
||||
if ($line -imatch '</Extension>')
|
||||
{
|
||||
$ExecutePS = $false
|
||||
}
|
||||
if ( ($line -imatch "EXECUTE-PS-" ) -and $ExecutePS)
|
||||
{
|
||||
$PSoutout = ""
|
||||
$line = $line.Trim()
|
||||
$line = $line.Replace("EXECUTE-PS-","")
|
||||
$line = $line.Split(">")
|
||||
$line = $line.Split("<")
|
||||
LogMsg "Executing Powershell command from Extensions.XML file : $($line[2])..."
|
||||
$PSoutout = Invoke-Expression -Command $line[2]
|
||||
$extensionString = $extensionString.Replace("EXECUTE-PS-$($line[2])",$PSoutout)
|
||||
Sleep -Milliseconds 500
|
||||
sleep -Milliseconds 1
|
||||
}
|
||||
}
|
||||
$extensionXML = [xml]$extensionString
|
||||
|
@ -534,18 +544,47 @@ Function GenerateCommand ($Setup, $serviceName, $osImage, $HSData)
|
|||
{
|
||||
if ($newExtn.Name -eq $extn)
|
||||
{
|
||||
[hashtable]$extensionHashTable = @{};
|
||||
$newExtn.Params.ChildNodes | foreach {$extensionHashTable[$_.Name] = $_.'#text'};
|
||||
$PublicConfiguration += $extensionHashTable | ConvertTo-Json
|
||||
[hashtable]$extensionHashTable = @{};
|
||||
$PrivateConfiguration += $extensionHashTable | ConvertTo-Json
|
||||
if ($newExtn.PublicConfiguration)
|
||||
{
|
||||
[hashtable]$extensionHashTable = @{};
|
||||
$newExtn.PublicConfiguration.ChildNodes | foreach {$extensionHashTable[$_.Name] = $_.'#text'};
|
||||
$PublicConfiguration += $extensionHashTable | ConvertTo-Json
|
||||
}
|
||||
if ($newExtn.PrivateConfiguration)
|
||||
{
|
||||
[hashtable]$extensionHashTable = @{};
|
||||
$newExtn.PrivateConfiguration.ChildNodes | foreach {$extensionHashTable[$_.Name] = $_.'#text'};
|
||||
$PrivateConfiguration += $extensionHashTable | ConvertTo-Json
|
||||
}
|
||||
if ( $ExtensionCommand )
|
||||
{
|
||||
$ExtensionCommand = $ExtensionCommand + " | Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter] -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
if ($PublicConfiguration -and $PrivateConfiguration)
|
||||
{
|
||||
$ExtensionCommand = $ExtensionCommand + " | Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter] -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
}
|
||||
elseif($PublicConfiguration)
|
||||
{
|
||||
$ExtensionCommand = $ExtensionCommand + " | Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter]"
|
||||
}
|
||||
elseif($PrivateConfiguration)
|
||||
{
|
||||
$ExtensionCommand = $ExtensionCommand + " | Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExtensionCommand = "Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter] -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
if ( $PublicConfiguration -and $PrivateConfiguration )
|
||||
{
|
||||
$ExtensionCommand = "Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter] -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
}
|
||||
elseif($PublicConfiguration)
|
||||
{
|
||||
$ExtensionCommand = "Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PublicConfiguration `$PublicConfiguration[$extensionCounter]"
|
||||
}
|
||||
elseif($PrivateConfiguration)
|
||||
{
|
||||
$ExtensionCommand = "Set-AzureVMExtension -ExtensionName $($newExtn.OfficialName) -ReferenceName $extn -Publisher $($newExtn.Publisher) -Version $($newExtn.Version) -PrivateConfiguration `$PrivateConfiguration[$extensionCounter]"
|
||||
}
|
||||
}
|
||||
LogMsg "Extension $extn (OfficialName : $($newExtn.OfficialName)) added to deployment command."
|
||||
$extensionCounter += 1
|
||||
|
@ -4015,36 +4054,55 @@ Function GetAllDeployementData($DeployedServices, $ResourceGroups)
|
|||
LogMsg "Collecting $ResourceGroup data.."
|
||||
$RGIPdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/publicIPAddresses" -ExpandProperties -OutputObjectFormat New -Verbose
|
||||
$RGVMs = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Compute/virtualMachines" -ExpandProperties -OutputObjectFormat New -Verbose
|
||||
$LBdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/loadBalancers" -ExpandProperties -OutputObjectFormat New -Verbose
|
||||
$NICdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/networkInterfaces" -ExpandProperties -OutputObjectFormat New -Verbose
|
||||
$numberOfVMs = 0
|
||||
foreach ($testVM in $RGVMs)
|
||||
{
|
||||
$numberOfVMs += 1
|
||||
}
|
||||
if ( $numberOfVMs -gt 1 )
|
||||
{
|
||||
$LBdata = Get-AzureResource -ResourceGroupName $ResourceGroup -ResourceType "Microsoft.Network/loadBalancers" -ExpandProperties -OutputObjectFormat New -Verbose
|
||||
}
|
||||
foreach ($testVM in $RGVMs)
|
||||
{
|
||||
$QuickVMNode = CreateQuickVMNode
|
||||
$InboundNatRules = $LBdata.Properties.InboundNatRules
|
||||
foreach ($endPoint in $InboundNatRules)
|
||||
if ( $numberOfVMs -gt 1 )
|
||||
{
|
||||
if ( $endPoint.Name -imatch $testVM.ResourceName)
|
||||
$InboundNatRules = $LBdata.Properties.InboundNatRules
|
||||
foreach ($endPoint in $InboundNatRules)
|
||||
{
|
||||
$endPointName = "$($endPoint.Name)".Replace("$($testVM.ResourceName)-","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($endPointName)Port" -Value $endPoint.Properties.FrontendPort -Force
|
||||
if ( $endPoint.Name -imatch $testVM.ResourceName)
|
||||
{
|
||||
$endPointName = "$($endPoint.Name)".Replace("$($testVM.ResourceName)-","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($endPointName)Port" -Value $endPoint.Properties.FrontendPort -Force
|
||||
}
|
||||
}
|
||||
$LoadBalancingRules = $LBdata.Properties.LoadBalancingRules
|
||||
foreach ( $LBrule in $LoadBalancingRules )
|
||||
{
|
||||
if ( $LBrule.Name -imatch "$ResourceGroup-LB-" )
|
||||
{
|
||||
$endPointName = "$($LBrule.Name)".Replace("$ResourceGroup-LB-","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($endPointName)Port" -Value $LBrule.Properties.FrontendPort -Force
|
||||
}
|
||||
}
|
||||
$Probes = $LBdata.Properties.Probes
|
||||
foreach ( $Probe in $Probes )
|
||||
{
|
||||
if ( $Probe.Name -imatch "$ResourceGroup-LB-" )
|
||||
{
|
||||
$probeName = "$($Probe.Name)".Replace("$ResourceGroup-LB-","").Replace("-probe","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($probeName)ProbePort" -Value $Probe.Properties.Port -Force
|
||||
}
|
||||
}
|
||||
}
|
||||
$LoadBalancingRules = $LBdata.Properties.LoadBalancingRules
|
||||
foreach ( $LBrule in $LoadBalancingRules )
|
||||
else
|
||||
{
|
||||
if ( $LBrule.Name -imatch "$ResourceGroup-LB-" )
|
||||
$AllEndpoints = $testVM.Properties.NetworkProfile.InputEndpoints
|
||||
foreach ($endPoint in $AllEndpoints)
|
||||
{
|
||||
$endPointName = "$($LBrule.Name)".Replace("$ResourceGroup-LB-","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($endPointName)Port" -Value $LBrule.Properties.FrontendPort -Force
|
||||
}
|
||||
}
|
||||
$Probes = $LBdata.Properties.Probes
|
||||
foreach ( $Probe in $Probes )
|
||||
{
|
||||
if ( $Probe.Name -imatch "$ResourceGroup-LB-" )
|
||||
{
|
||||
$probeName = "$($Probe.Name)".Replace("$ResourceGroup-LB-","").Replace("-probe","")
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($probeName)ProbePort" -Value $Probe.Properties.Port -Force
|
||||
Add-Member -InputObject $QuickVMNode -MemberType NoteProperty -Name "$($endPoint.EndpointName)Port" -Value $endPoint.PublicPort -Force
|
||||
}
|
||||
}
|
||||
foreach ( $nic in $NICdata )
|
||||
|
@ -6147,6 +6205,8 @@ Function RetryOperation($operation, $description, $expectResult=$null, $maxRetry
|
|||
else
|
||||
{
|
||||
$ErrorActionPreference = $oldErrorActionValue
|
||||
$retryCount ++
|
||||
WaitFor -seconds $retryInterval
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -6176,3 +6236,52 @@ Function RetryOperation($operation, $description, $expectResult=$null, $maxRetry
|
|||
|
||||
return $null
|
||||
}#endregion
|
||||
|
||||
#region LinuxUtilities
|
||||
Function GetFilePathsFromLinuxFolder ([string]$folderToSearch, $IpAddress, $SSHPort, $username, $password, $maxRetryCount=20)
|
||||
{
|
||||
$parentFolder = $folderToSearch.Replace("/" + $folderToSearch.Split("/")[($folderToSearch.Trim().Split("/").Count)-1],"")
|
||||
$LogFilesPaths = ""
|
||||
$LogFiles = ""
|
||||
$retryCount = 1
|
||||
while (($LogFilesPaths -eq "") -and ($retryCount -le $maxRetryCount ))
|
||||
{
|
||||
WaitFor -seconds 10
|
||||
LogMsg "Attempt $retryCount/$maxRetryCount : Getting all file paths inside $folderToSearch"
|
||||
$lsOut = RunLinuxCmd -username $username -password $password -ip $IpAddress -port $SSHPort -command "ls -lR $parentFolder" -runAsSudo
|
||||
foreach ($line in $lsOut.Split("`n") )
|
||||
{
|
||||
$line = $line.Trim()
|
||||
if ($line -imatch $parentFolder)
|
||||
{
|
||||
$currentFolder = $line.Replace(":","")
|
||||
}
|
||||
if ( ( ($line.Split(" ")[0][0]) -eq "-" ) -and ($currentFolder -imatch $folderToSearch) )
|
||||
{
|
||||
while ($line -imatch " ")
|
||||
{
|
||||
$line = $line.Replace(" "," ")
|
||||
}
|
||||
$currentLogFile = $line.Split(" ")[8]
|
||||
if ($LogFilesPaths)
|
||||
{
|
||||
$LogFilesPaths += "," + $currentFolder + "/" + $currentLogFile
|
||||
$LogFiles += "," + $currentLogFile
|
||||
}
|
||||
else
|
||||
{
|
||||
$LogFilesPaths = $currentFolder + "/" + $currentLogFile
|
||||
$LogFiles += $currentLogFile
|
||||
}
|
||||
LogMsg "Found $currentFolder/$currentLogFile"
|
||||
}
|
||||
}
|
||||
$retryCount += 1
|
||||
}
|
||||
if ( !$LogFilesPaths )
|
||||
{
|
||||
LogMsg "No files found in $folderToSearch"
|
||||
}
|
||||
return $LogFilesPaths, $LogFiles
|
||||
}
|
||||
#endregion
|
|
@ -4,18 +4,18 @@
|
|||
<Name>CustomScriptTouchCommand</Name>
|
||||
<OfficialName>CustomScriptForLinux</OfficialName>
|
||||
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
|
||||
<Params>
|
||||
<PublicConfiguration>
|
||||
<timestamp>EXECUTE-PS-(Get-Date).ticks</timestamp>
|
||||
<fileUris></fileUris>
|
||||
<commandToExecute>touch /var/log/CustomExtensionSuccessful</commandToExecute>
|
||||
</Params>
|
||||
</PublicConfiguration>
|
||||
<Version>1.*</Version>
|
||||
</Extension>
|
||||
<Extension>
|
||||
<Name>OsPatching</Name>
|
||||
<OfficialName>OSPatchingForLinux</OfficialName>
|
||||
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
|
||||
<Params>
|
||||
<PublicConfiguration>
|
||||
<timestamp>EXECUTE-PS-(Get-Date).ticks</timestamp>
|
||||
<rebootAfterPatch>Auto</rebootAfterPatch>
|
||||
<category>Important</category>
|
||||
|
@ -26,11 +26,19 @@
|
|||
<startTime>12:00</startTime>
|
||||
<disabled>$false</disabled>
|
||||
<stop>$false</stop>
|
||||
</Params>
|
||||
</PublicConfiguration>
|
||||
<Version>2.*</Version>
|
||||
</Extension>
|
||||
<Extension>
|
||||
<Name>LinuxDiagnosticDefaultDataSet</Name>
|
||||
<OfficialName>LinuxDiagnostic</OfficialName>
|
||||
<Publisher>"Microsoft.OSTCExtensions"</Publisher>
|
||||
<PrivateConfiguration>
|
||||
<storageAccountName>EXECUTE-PS-$xmlConfig.config.Azure.General.StorageAccount</storageAccountName>
|
||||
<storageAccountKey>EXECUTE-PS-(Get-AzureStorageKey -StorageAccountName $xmlConfig.config.Azure.General.StorageAccount).Primary</storageAccountKey>
|
||||
</PrivateConfiguration>
|
||||
<Version>2.*</Version>
|
||||
</Extension>
|
||||
<Extension>
|
||||
<Name>LinuxDiagnostic</Name>
|
||||
<!-- To be done... -->
|
||||
</Extension>
|
||||
</Extensions>
|
||||
</Extensions>
|
||||
|
||||
|
|
@ -8,57 +8,66 @@ if ($isDeployed)
|
|||
{
|
||||
try
|
||||
{
|
||||
$testServiceData = Get-AzureService -ServiceName $isDeployed
|
||||
|
||||
#Get VMs deployed in the service..
|
||||
$testVMsinService = $testServiceData | Get-AzureVM
|
||||
|
||||
$hs1vm1 = $testVMsinService
|
||||
$hs1vm1Endpoints = $hs1vm1 | Get-AzureEndpoint
|
||||
$hs1vm1sshport = GetPort -Endpoints $hs1vm1Endpoints -usage ssh
|
||||
$hs1VIP = $hs1vm1Endpoints[0].Vip
|
||||
$hs1ServiceUrl = $hs1vm1.DNSName
|
||||
$hs1ServiceUrl = $hs1ServiceUrl.Replace("http://","")
|
||||
$hs1ServiceUrl = $hs1ServiceUrl.Replace("/","")
|
||||
$lsOutput = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "ls /var/log/" -runAsSudo
|
||||
LogMsg -msg $lsOutput -LinuxConsoleOuput
|
||||
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "tar -cvzf /home/$user/AzureExtensionLogs.tar.gz /var/log/azure/*" -runAsSudo
|
||||
RemoteCopy -download -downloadFrom $hs1VIP -files "/home/$user/AzureExtensionLogs.tar.gz" -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password
|
||||
$varLogFolder = "/var/log"
|
||||
$lsOut = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "ls -lR $varLogFolder" -runAsSudo
|
||||
$hs1VIP = $AllVMData.PublicIP
|
||||
$hs1vm1sshport = $AllVMData.SSHPort
|
||||
$hs1ServiceUrl = $AllVMData.URL
|
||||
$hs1vm1Dip = $AllVMData.InternalIP
|
||||
$hs1vm1Hostname = $AllVMData.RoleName
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
$LogFilesPaths = ""
|
||||
$LogFiles = ""
|
||||
$folderToSearch = "/var/log/azure"
|
||||
foreach ($line in $lsOut.Split("`n") )
|
||||
$FoundFiles = GetFilePathsFromLinuxFolder -folderToSearch $folderToSearch -IpAddress $hs1VIP -SSHPort $hs1vm1sshport -username $user -password $password
|
||||
$LogFilesPaths = $FoundFiles[0]
|
||||
$LogFiles = $FoundFiles[1]
|
||||
foreach ($file in $LogFilesPaths.Split(","))
|
||||
{
|
||||
if ($line -imatch $varLogFolder)
|
||||
foreach ($fileName in $LogFiles.Split(","))
|
||||
{
|
||||
$currentFolder = $line.Replace(":","")
|
||||
}
|
||||
if ( ( ($line.Split(" ")[0][0]) -eq "-" ) -and ($currentFolder -imatch $folderToSearch) )
|
||||
{
|
||||
if ($LogFilesPaths)
|
||||
if ( $file -imatch $fileName )
|
||||
{
|
||||
$LogFilesPaths += "," + $currentFolder + "/" + $line.Split(" ")[8]
|
||||
$LogFiles += "," + $line.Split(" ")[8]
|
||||
}
|
||||
else
|
||||
{
|
||||
$LogFilesPaths = $currentFolder + "/" + $line.Split(" ")[8]
|
||||
$LogFiles += $line.Split(" ")[8]
|
||||
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "cat $file > $fileName" -runAsSudo
|
||||
RemoteCopy -download -downloadFrom $hs1VIP -files $fileName -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password
|
||||
}
|
||||
}
|
||||
}
|
||||
RemoteCopy -download -downloadFrom $hs1VIP -files $LogFilesPaths -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password
|
||||
}
|
||||
RemoteCopy -download -downloadFrom $hs1VIP -files "/var/log/waagent.log" -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password
|
||||
$lsOutput = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "ls /var/log/" -runAsSudo
|
||||
LogMsg -msg $lsOutput -LinuxConsoleOuput
|
||||
if ($lsOutput -imatch "CustomExtensionSuccessful")
|
||||
{
|
||||
$extensionVerified = $true
|
||||
}
|
||||
else
|
||||
{
|
||||
$extensionVerified = $false
|
||||
}
|
||||
|
||||
$ConfirmExtensionScriptBlock = {
|
||||
|
||||
$vmDetails = Get-AzureVM -ServiceName $isDeployed
|
||||
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "CustomScriptForLinux" ))
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $true
|
||||
LogMsg "CustomScriptForLinux extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
LogErr "CustomScriptForLinux extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
return $ExtensionVerfiedWithPowershell
|
||||
}
|
||||
|
||||
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming CustomScript extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
|
||||
|
||||
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified )
|
||||
{
|
||||
$testResult = "PASS"
|
||||
}
|
||||
else
|
||||
{
|
||||
$testResult = "FAIL"
|
||||
LogMsg "Please check logs."
|
||||
}
|
||||
LogMsg "Test result : $testResult"
|
||||
}
|
||||
|
|
|
@ -14,37 +14,12 @@ if ($isDeployed)
|
|||
$hs1vm1Dip = $AllVMData.InternalIP
|
||||
$hs1vm1Hostname = $AllVMData.RoleName
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
$lsOutput = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "ls /var/log/" -runAsSudo
|
||||
LogMsg -msg $lsOutput -LinuxConsoleOuput
|
||||
$varLogFolder = "/var/log"
|
||||
$lsOut = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "ls -lR $varLogFolder" -runAsSudo
|
||||
$LogFilesPaths = ""
|
||||
$LogFiles = ""
|
||||
$folderToSearch = "/var/log/azure"
|
||||
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "chmod -R 666 $varLogFolder" -runAsSudo
|
||||
WaitFor -Seconds 120
|
||||
foreach ($line in $lsOut.Split("`n") )
|
||||
{
|
||||
$line = $line.Trim()
|
||||
if ($line -imatch $varLogFolder)
|
||||
{
|
||||
$currentFolder = $line.Replace(":","")
|
||||
}
|
||||
if ( ( ($line.Split(" ")[0][0]) -eq "-" ) -and ($currentFolder -imatch $folderToSearch) )
|
||||
{
|
||||
$currentLogFile = $line.Replace(" "," ").Replace(" "," ").Replace(" "," ").Replace(" "," ").Replace(" "," ").Split(" ")[8]
|
||||
if ($LogFilesPaths)
|
||||
{
|
||||
$LogFilesPaths += "," + $currentFolder + "/" + $currentLogFile
|
||||
$LogFiles += "," + $currentLogFile
|
||||
}
|
||||
else
|
||||
{
|
||||
$LogFilesPaths = $currentFolder + "/" + $currentLogFile
|
||||
$LogFiles += $currentLogFile
|
||||
}
|
||||
}
|
||||
}
|
||||
$FoundFiles = GetFilePathsFromLinuxFolder -folderToSearch $folderToSearch -IpAddress $hs1VIP -SSHPort $hs1vm1sshport -username $user -password $password
|
||||
$LogFilesPaths = $FoundFiles[0]
|
||||
$LogFiles = $FoundFiles[1]
|
||||
$retryCount = 1
|
||||
$maxRetryCount = 20
|
||||
if ($LogFilesPaths)
|
||||
|
@ -112,9 +87,9 @@ if ($isDeployed)
|
|||
$extensionVerified = $false
|
||||
LogErr "extension.log file does not present"
|
||||
$waitForExtension = $true
|
||||
$retryCount += 1
|
||||
WaitFor -Seconds 30
|
||||
}
|
||||
$retryCount += 1
|
||||
}
|
||||
while (($retryCount -lt $maxRetryCount) -and $waitForExtension )
|
||||
}
|
||||
|
@ -123,17 +98,24 @@ if ($isDeployed)
|
|||
LogErr "No Extension logs are available."
|
||||
$extensionVerified = $false
|
||||
}
|
||||
|
||||
$ConfirmExtensionScriptBlock = {
|
||||
|
||||
$vmDetails = Get-AzureVM -ServiceName $isDeployed
|
||||
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "OSPatchingForLinux" ))
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $true
|
||||
LogMsg "OSPatchingForLinux extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
LogErr "OSPatchingForLinux extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "OSPatchingForLinux" ))
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $true
|
||||
LogMsg "OSPatchingForLinux extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
LogErr "OSPatchingForLinux extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
return $ExtensionVerfiedWithPowershell
|
||||
}
|
||||
|
||||
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming OS PATCHING extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
|
||||
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified )
|
||||
{
|
||||
$testResult = "PASS"
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
<#-------------Create Deployment Start------------------#>
|
||||
Import-Module .\TestLibs\RDFELibs.psm1 -Force
|
||||
$result = ""
|
||||
$testResult = ""
|
||||
$resultArr = @()
|
||||
$isDeployed = DeployVMS -setupType $currentTestData.setupType -Distro $Distro -xmlConfig $xmlConfig
|
||||
if ($isDeployed)
|
||||
{
|
||||
try
|
||||
{
|
||||
$hs1VIP = $AllVMData.PublicIP
|
||||
$hs1vm1sshport = $AllVMData.SSHPort
|
||||
$hs1ServiceUrl = $AllVMData.URL
|
||||
$hs1vm1Dip = $AllVMData.InternalIP
|
||||
$hs1vm1Hostname = $AllVMData.RoleName
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
$LogFilesPaths = ""
|
||||
$LogFiles = ""
|
||||
$folderToSearch = "/var/log/azure"
|
||||
$FoundFiles = GetFilePathsFromLinuxFolder -folderToSearch $folderToSearch -IpAddress $hs1VIP -SSHPort $hs1vm1sshport -username $user -password $password
|
||||
$LogFilesPaths = $FoundFiles[0]
|
||||
$LogFiles = $FoundFiles[1]
|
||||
if ($LogFilesPaths)
|
||||
{
|
||||
$retryCount = 1
|
||||
$maxRetryCount = 10
|
||||
do
|
||||
{ LogMsg "Attempt : $retryCount/$maxRetryCount : Checking extension log files...."
|
||||
foreach ($file in $LogFilesPaths.Split(","))
|
||||
{
|
||||
foreach ($fileName in $LogFiles.Split(","))
|
||||
{
|
||||
if ( $file -imatch $fileName )
|
||||
{
|
||||
$out = RunLinuxCmd -username $user -password $password -ip $hs1VIP -port $hs1vm1sshport -command "cat $file > $fileName" -runAsSudo
|
||||
RemoteCopy -download -downloadFrom $hs1VIP -files $fileName -downloadTo $LogDir -port $hs1vm1sshport -username $user -password $password
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( Test-Path "$LogDir\extension.log" )
|
||||
{
|
||||
$extensionOutput = Get-Content -Path $LogDir\extension.log
|
||||
if ($extensionOutput -imatch "Start mdsd")
|
||||
{
|
||||
LogMsg "Extension Agent in started in Linux VM."
|
||||
$waitForExtension = $false
|
||||
$extensionVerified = $true
|
||||
}
|
||||
else
|
||||
{
|
||||
LogMsg "Extension Agent not started in Linux VM"
|
||||
$waitForExtension = $true
|
||||
$extensionVerified = $false
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$extensionVerified = $false
|
||||
LogErr "extension.log file does not present"
|
||||
$waitForExtension = $true
|
||||
WaitFor -Seconds 30
|
||||
}
|
||||
$retryCount += 1
|
||||
}
|
||||
while (($retryCount -lt $maxRetryCount) -and $waitForExtension )
|
||||
}
|
||||
else
|
||||
{
|
||||
LogErr "No Extension logs are available."
|
||||
$extensionVerified = $false
|
||||
}
|
||||
|
||||
$ConfirmExtensionScriptBlock = {
|
||||
$vmDetails = Get-AzureVM -ServiceName $isDeployed
|
||||
if ( ( $vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Status -eq "Success" ) -and ($vmDetails.ResourceExtensionStatusList.ExtensionSettingStatus.Name -imatch "Microsoft.OSTCExtensions.LinuxDiagnostic" ))
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $true
|
||||
LogMsg "LinuxDiagnostic extension status is SUCCESS in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
else
|
||||
{
|
||||
$ExtensionVerfiedWithPowershell = $false
|
||||
LogErr "LinuxDiagnostic extension status is FAILED in (Get-AzureVM).ResourceExtensionStatusList.ExtensionSettingStatus"
|
||||
}
|
||||
return $ExtensionVerfiedWithPowershell
|
||||
}
|
||||
$ExtensionVerfiedWithPowershell = RetryOperation -operation $ConfirmExtensionScriptBlock -description "Confirming VM DIAGNOSTICS extension from Azure side." -expectResult $true -maxRetryCount 10 -retryInterval 10
|
||||
if ( $ExtensionVerfiedWithPowershell -and $extensionVerified)
|
||||
{
|
||||
$testResult = "PASS"
|
||||
}
|
||||
else
|
||||
{
|
||||
$testResult = "FAIL"
|
||||
}
|
||||
LogMsg "Test result : $testResult"
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
$ErrorMessage = $_.Exception.Message
|
||||
LogMsg "EXCEPTION : $ErrorMessage"
|
||||
}
|
||||
Finally
|
||||
{
|
||||
$metaData = ""
|
||||
if (!$testResult)
|
||||
{
|
||||
$testResult = "Aborted"
|
||||
}
|
||||
$resultArr += $testResult
|
||||
#$resultSummary += CreateResultSummary -testResult $testResult -metaData $metaData -checkValues "PASS,FAIL,ABORTED" -testName $currentTestData.testName# if you want to publish all result then give here all test status possibilites. if you want just failed results, then give here just "FAIL". You can use any combination of PASS FAIL ABORTED and corresponding test results will be published!
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$testResult = "Aborted"
|
||||
$resultArr += $testResult
|
||||
}
|
||||
|
||||
$result = GetFinalResultHeader -resultarr $resultArr
|
||||
|
||||
#Clean up the setup
|
||||
DoTestCleanUp -result $result -testName $currentTestData.testName -deployedServices $isDeployed
|
||||
|
||||
#Return the result and summery to the test suite script..
|
||||
return $result
|
Загрузка…
Ссылка в новой задаче