zoukankan      html  css  js  c++  java
  • Add the Multiple machines for the MCS Machine Catalog

    1. Create the MCS type machine catalog

    New-BrokerCatalog -name 'TestCatalog' -ProvisioningType 'MCS' -SessionSupport 'MuiltiSession' -PersistUserChanges 'onlocal'

    2. Add the machine to MCS machine catalog

    $password = "1qaz!QAZ"
    $securepassword = $Password | ConvertTo-SecureString -AsPlainText -Force
    $ADAccount = New-AcctADAccount -IdentityPoolName MCS_catalog2 -Count 180 -OutVariable result -ADUserName "xfadministrator" -ADPassword $SecurePassword
    $machines = $ADAccount.SuccessfulAccounts
    Foreach($machine in $machines)
    {
        $VMName = $machine | select ADAccountName       
        New-provVM -ProvisioningSchemeName "MCS_catalog2" -ADAccountName $VMName.ADAccountName    
        #$provVM = Get-provVM |select ADAccountName,VMId |Where-Object{$_.ADAccountName -like $VMName}    
        New-BrokerMachine -CatalogUid 6 -MachineName $VMName.ADAccountName 
    }
    

    3.Delete the machine from XenServer host

    for ($i=0; $i -le 3600000; $i++)
    {
            start-sleep -seconds 3
            $i
    Connect-XenServer -url "http://10.150.182.76" -UserName "root" -Password "9JdUl63w3Unf" -NoWarnCertificates -SetDefaultSession

    $myVms = Get-XenVM | select name_label| Where-Object {$_.name_label -like "fwmachine*"}
    for($j = 0; $j -lt $myVms.length-1; $j++){ 
            $number1 = $myVms[$j].name_label.substring(9)
            $number2 = $myVms[$myVms.length-1].name_label.substring(9)
            if ($number1 -lt $number2){
                $delVm = $myVms[$j].name_label      
            }else{
                $delVm = $myVms[$myVms.length-1].name_label
            }  
                 $delVm   
                 Remove-XenVM -Name $delVm
    
          }
                   
    }

     4.Delete the vdisk from xenserver

    Connect-XenServer -url "http://10.150.182.76" -UserName "root" -Password "9JdUl63w3Unf" -NoWarnCertificates -SetDefaultSession
    
    Get-XenVDI -Name fwmachine* | Remove-XenVDI
  • 相关阅读:
    linux系统调整磁盘分区
    Linux命令sort和uniq 的基本使用
    路由的执行优先级
    Linux命令xargs的使用
    wget命令的使用
    Linux环境下错误码及意义总结
    Linux下使用ip netns命令进行网口的隔离和配置ip地址
    MongoDB初始化创建管理员账户登录
    Python字符串的截取原理,下标的位置图示
    Python操作MongoDB查询时处理ObjectId
  • 原文地址:https://www.cnblogs.com/Lina-zhu/p/9115659.html
Copyright © 2011-2022 走看看