11 Replies Latest reply on Jul 28, 2014 6:11 AM by Ben Vassie

    Naming ESX datastores via an XML list

      Share This:

      Hello.

       

      I am using BSA and AO to build an ESXi (5.1) host and also create multiple VMs.

       

      Once BSA has installed ESXi on the blade, AO will add it a vCenter, the next step is to create the datastores.

       

      The host has nine disks, one of which contains the OS, AO will query the host and obtain a list of disks, this then goes into a for loop and creates a datastore on each disk, the problem I have now is that I need to give them a meaningful name. The names (in order) are:

       

      • S_OSVMFS01-A
      • S_OSVMFS02-A
      • S_DATAVMFS01-A
      • D_OSVMFS01-B
      • D_OSVMFS02-B
      • D_DATAVMFS01-B
      • SOFTWARE_LIBRARY-A

       

      I have stored this as an XML configuration item:


      <Datastores>

        <Datastore>S_OSVMFS01-A</Datastore>

        <Datastore>S_OSVMFS02-A</Datastore>

        <Datastore>S_DATAVMFS01-A</Datastore>

        <Datastore>D_OSVMFS01-B</Datastore>

        <Datastore>D_OSVMFS02-B</Datastore>

        <Datastore>D_DATAVMFS01-B</Datastore>

        <Datastore>SOFTWARE_LIBRARY-A</Datastore>

      </Datastores>

       

      How do I use this via a for loop when creating my datastores?

        • 1. Re: Naming ESX datastores via an XML list

          Here is the output when I query the ESXi hosts for its disks:

           

          naa.600508b1001c63cb638620f0a47d1d70           500

          naa.600508b1001ca33a308dc36cf6094597 49.9990234375

          naa.600508b1001cd36764594a64a81ca6f7          1000

          naa.600508b1001c226f8f19d379a48316c7          1500

          naa.600508b1001cbaad60ffa758ebfaa7b0           500

          naa.600508b1001cfb53dafd1380545e778c  99.998046875

          naa.600508b1001c863a2a5e6d30db1ea459           500

          naa.600508b1001c7ccff79b96202b1ab00a           500

           

          The command to create a datastore is:

           

          New-Datastore -VMHost $esxhost -Name $name -Path $diskid -Vmfs -FileSystemVersion 5

          AO will pass

           

          New-Datastore -VMHost build01.synergy.local -Name $name -Path naa.600508b1001c63cb638620f0a47d1d70 -Vmfs -FileSystemVersion 5

          I need $name to be taken from my XML list

           

          Thanks

          • 2. Re: Naming ESX datastores via an XML list

            By the way, the 50gb disk is the system drive, I have a switch that will discard disks under 60gb

            • 3. Re: Naming ESX datastores via an XML list
              Aryan Anantwar

              Hi Ben,

               

              Do you want to create multiple Datastores in this AO process by reading the names from a XML list?

              If so, You should use For_Loop for this.

              Share your XML sample.

               

               

              Regards,

              Aryan Anantwar

              • 4. Re: Naming ESX datastores via an XML list

                Hello

                 

                I want to run my process to obtain the list of disks from the ESXi host, then create a datastore on each one

                 

                Here is my adapter response when I query the host:

                 

                [adapter response=

                <command-result>

                  <metadata>

                    <status>success</status>

                  </metadata>

                  <targets-output>

                    <target-output>

                      <metadata>

                        <os-id>Windows Server 2008</os-id>

                        <os-version>6.1</os-version>

                        <os-arch>amd64</os-arch>

                        <status>success</status>

                      </metadata>

                      <commands-output>

                        <command-output>

                          <metadata>

                            <command>powershell.exe -command d:\auto\scripts\list-disks.ps1 localhost Administrator YhZOvW5f esx-host-01.synergy.local</command>

                            <working-dir></working-dir>

                            <command-dir></command-dir>

                            <line-count>8</line-count>

                            <execution-milliseconds>72619</execution-milliseconds>

                            <exit-code>0</exit-code>

                            <status>success</status>

                          </metadata>

                          <output>

                            <line index="1">naa.600508b1001c63cb638620f0a47d1d70           500</line>

                            <line index="2">naa.600508b1001ca33a308dc36cf6094597 49.9990234375</line>

                            <line index="3">naa.600508b1001cd36764594a64a81ca6f7          1000</line>

                            <line index="4">naa.600508b1001c226f8f19d379a48316c7          1500</line>

                            <line index="5">naa.600508b1001cbaad60ffa758ebfaa7b0           500</line>

                            <line index="6">naa.600508b1001cfb53dafd1380545e778c  99.998046875</line>

                            <line index="7">naa.600508b1001c863a2a5e6d30db1ea459           500</line>

                            <line index="8">naa.600508b1001c7ccff79b96202b1ab00a           500</line>

                          </output>

                        </command-output>

                      </commands-output>

                    </target-output>

                  </targets-output>

                </command-result>]

                 

                Disk IDSizeName
                naa.600508b1001c63cb638620f0a47d1d70500S_OSVMFS01-A
                naa.600508b1001cd36764594a64a81ca6f71000S_DATAVMFS01-A
                naa.600508b1001c226f8f19d379a48316c71500D_DATAVMFS01-B
                naa.600508b1001cbaad60ffa758ebfaa7b0500S_OSVMFS02-A
                naa.600508b1001cfb53dafd1380545e778c99.998046875SOFTWARE_LIBRARY-A
                naa.600508b1001c863a2a5e6d30db1ea459500D_OSVMFS01-B
                naa.600508b1001c7ccff79b96202b1ab00a500D_OSVMFS02-B

                 

                Each one needs to be a new datastore with the following names:

                 

                S_OSVMFS01-A (500gb)

                S_OSVMFS02-A (500gb)

                S_DATAVMFS01-A (1000gb)

                D_OSVMFS01-B (500gb)

                D_OSVMFS02-B (500gb)

                D_DATAVMFS01-B (1500gb)

                SOFTWARE_LIBRARY-A (100gb)

                • 5. Re: Naming ESX datastores via an XML list
                  Aryan Anantwar

                  Hi Ben,

                   

                  This can be done using xslt or a simple For_Loop activity.

                  • if you build an XML which includes above values into one XML then it will be pretty easy.

                  XML should look like:

                  <Datastores>

                       <Datastore>

                       <DiskID>xxx</DiskID>

                       <Size>xxx</Size>

                       <Name>xxx<Name>

                       <Datastore>   

                          .

                       </Datastore>

                  </Datastores>

                   

                  Or I am creating a sample process for your usecase, but got confused.

                  the response returns 8 entries of disks & you have details for 7 to create datastores.

                  if you share proper mapping, I can help you over this.

                   

                  Regards,

                  Aryan Anantwar

                  1 of 1 people found this helpful
                  • 6. Re: Naming ESX datastores via an XML list

                    The disk IDs are different each time, my input is the adapter response when I query the hosts for the disk

                    I use a switch not to touch the 50gb disk as this is the OS drive

                    • 7. Re: Re: Naming ESX datastores via an XML list
                      Aryan Anantwar

                      Hi Ben,

                       

                      I have created  processes according to your usecase.

                      Use "Create Datastores" Process, provide your adapter response to this as input.(disk info)

                       

                      Also map proper values to "Call Powershell command" as I have provided dummy values for adapters.

                       

                      • "Create Datastores" process, extracts the disk info form input given to this process.
                      • Then iterates a loop for each disk item, also skippes the 50 GB drive by checking DiskSize in condition.
                      • Forms a Command to create datastore.
                      • Assigns this command to "Call Powershell command" process.
                      • Then retrieves the powershell adapter response, extract the resutlt string & appends to a File.

                       

                      Study the workflow, make required changes and if you think it, go with it.

                       

                      PFA for module .roar file.

                       

                      Regards,

                      Aryan Anantwar

                      1 of 1 people found this helpful
                      • 8. Re: Naming ESX datastores via an XML list

                        Thank you, however as per the table above (Re: Naming ESX datastores via an XML list) some of the datastores have to have a particular name based on their size

                        Ben

                        • 9. Re: Naming ESX datastores via an XML list
                          Aryan Anantwar

                          Ben,

                           

                          Execute and test the workflow I shared.

                          It is creating the datastores with same names you mapped in above table.

                          The processs I created generates below commands:

                          • New-Datastore -VMHost build01.synergy.local -Name S_OSVMFS01-A -Path naa.600508b1001c63cb638620f0a47d1d70 -Vmfs -FileSystemVersion
                          • New-Datastore -VMHost build01.synergy.local -Name S_OSVMFS02-A -Path naa.600508b1001cd36764594a64a81ca6f7 -Vmfs -FileSystemVersion 5
                          • New-Datastore -VMHost build01.synergy.local -Name S_DATAVMFS01-A -Path naa.600508b1001c226f8f19d379a48316c7 -Vmfs -FileSystemVersion 5
                          • New-Datastore -VMHost build01.synergy.local -Name D_OSVMFS01-B -Path naa.600508b1001cbaad60ffa758ebfaa7b0 -Vmfs -FileSystemVersion 5
                          • New-Datastore -VMHost build01.synergy.local -Name D_OSVMFS02-B -Path naa.600508b1001cfb53dafd1380545e778c -Vmfs -FileSystemVersion 5
                          • New-Datastore -VMHost build01.synergy.local -Name D_DATAVMFS01-B -Path naa.600508b1001c863a2a5e6d30db1ea459 -Vmfs -FileSystemVersion 5
                          • New-Datastore -VMHost build01.synergy.local -Name SOFTWARE_LIBRARY-A -Path naa.600508b1001c7ccff79b96202b1ab00a -Vmfs -FileSystemVersion 5

                           

                          Moreover, if you want to specify names as per specific size to datastores, the you can use multiple switch activities.

                           

                          Regards,

                          Aryan Anantwar

                          • 10. Re: Naming ESX datastores via an XML list

                            Thank you, I am trying it now, I need to swap the PowerShell command with my Command Line command as trying to run VMware PowerCLI commands does not work via the PowerShell adapter.

                             

                            I have to create a ps1 file on the VC first, then pass commands from AO into it.

                            • 11. Re: Naming ESX datastores via an XML list

                              The only problem with that is that the output from the list disk command is different per host meaning the order is not guaranteed.