forked from bekimd-ms/AzureStack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestloopnew.ps1
108 lines (89 loc) · 2.74 KB
/
testloopnew.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
Param(
[string]$location = "",
[string]$dns = "",
[string]$sub = "",
[string]$user = "",
[string]$pwd = "",
[string]$maxvm=2,
[string]$vmcount=4,
[string]$vnet = "",
[string]$vnetrg = "",
[string]$sleeptime = 10
)
function CreateNewVnet
{
$rgname = " -rgname '" + $size + "vm" + (-join(Get-Random $chars -Count 8)) + "' "
$command = $commandprefix + $rgname + ( GetCommand $size )
Write-Host "Starting Public VM in new vnet : " $size ": " $command
#$processes += @(Start-Process -PassThru Powershell "$command")
}
function CreateVMinVnet
{
$rgname = " -rgname '" + $size + "vm" + (-join(Get-Random $chars -Count 8)) + "' "
$command = $commandprefix + $rgname + ( GetCommand $size )
Write-Host "Starting Private VM in vnet : " $size ": " $command
#$processes += @(Start-Process -PassThru PowerShell ./testcnt.ps1)
#$processes += @(Start-Process -PassThru Powershell "$command")
}
$commandprefix = "./tools/logindeployvm.ps1 -location " + $location + " -dns " + $dns + " -sub " + $sub + `
" -user " + $user + " -pwd " + $pwd + " -vnetrg " + $vnetrg + " -vnet " + $vnet
Write-Host "Command " $commandprefix
$chars = [char[]] ([char]'0'..[char]'9' + [char]'a'..[char]'z')
$chars = $chars * 3
$sizes = @("xxl") * 2
$sizes = $sizes + (@("xl") * 4 )
$sizes = $sizes + (@("l") * 8 )
$sizes = $sizes + (@("m") * 16 )
$sizes = $sizes + (@("s") * 32 )
$sizes = $sizes + (@("xs") * 38 )
$sizes = $sizes | sort {get-random }
function GetCommand( $size )
{
switch( $size )
{
"xxl" { "-vmsize Standard_D4 -disknum 4 -disksize 1023" }
"xl" { "-vmsize Standard_D3 -disknum 2 -disksize 1023" }
"l" { "-vmsize Standard_D2 -disknum 1 -disksize 1023" }
"m" { "-vmsize Standard_D1 -disknum 1 -disksize 511" }
"s" { "-vmsize Standard_D1 -disknum 1 -disksize 127" }
"xs" { "-vmsize Standard_D1 -disknum 0 -disksize 0" }
}
}
$nextvm = 0
$activevm = 0
$vnets = @()
$vnetsvmcount = @()
while( $nextvm -lt $vmcount )
{
Write-Host "Active deployments ", $activevm
Write-Host "Next VM ", $nextvm
if( $activevm -lt $maxvm )
{
$size = $sizes[$nextvm]
$nextvm = $nextvm + 1
}
$liveproc = 0
Write-Host "Checking processes..."
foreach( $process in $processes )
{
if( -not $process.HasExited )
{
$liveproc = $liveproc + 1
}
}
$activevm = $liveproc
start-sleep -s $sleeptime
}
# vnets
# name
# vmcount
# vnetcnt
# loop
# if( vnetcnt < 4 ) { vnet += @( CreatePubVMandVnet ) vnetcnt++ }
# vnet = choose vnet
# if( vnet )
# {
# vnet.AddVM()
# vnet.vmcount ++
# if( vnet.vmcount > maxvminvnet ) { vnet.disable; vnetcnt-- }
# }