none
Object Model, please find my test machine and move it to the default pool. RRS feed

  • Question

  • Using the HCK Object Model, I would like to quickly find a certain test machine (I know it's hostname) and move it from whatever pool it is in to the Default Pool.  Is there a straightforward way to do that?  I was hoping that $RootPool.GetMachines() might do it, but nope. : ) 

    Tuesday, April 9, 2013 11:47 PM

Answers

  • If you don't know which machine pool the machine is in, you have to iterate through the child pools (MachinePool.GetChildPools) for each machine pool in the root machine pool (ProjectManager.GetRootMachinePool) to find the machine.

    Friday, April 12, 2013 12:02 AM

All replies

  • Hi,

    To find the machine, you must look into its respective machine pool and then you can move it to the default pool.

    Regards,

    Nilesh.

    Wednesday, April 10, 2013 1:07 PM
  • Nilesh,

    Thank you for your reply.  So here's a question:  What if I don't know what pool the machine is in; can I ask the object model to go find it for me?  Also, if I really am limited to iterating through all the pools, is there a straightforward way to do that, and recursively, so no pools or subpools are missed?  It seems by iterating through pools, machines, projects, and other things, I am able to get what I'm after by using loops and checking each iterated value, but it also seems that if I understand the Object Model well enough, I may be able to get what I'm after in a much more direct manner.  Is that a correct assumption?

    -- hh

    Wednesday, April 10, 2013 4:09 PM
  • If you don't know which machine pool the machine is in, you have to iterate through the child pools (MachinePool.GetChildPools) for each machine pool in the root machine pool (ProjectManager.GetRootMachinePool) to find the machine.

    Friday, April 12, 2013 12:02 AM
  • Hi HH,

    Iterating is the only good way to get a machine pool in which your machine is. There is no specific method in OM API which will do the task you want to do.

    If you dont want to iterate through the childpools, you may do it the other way given below :

    If you know the projectName, you can retrieve projectObject [$projObj=$manager.getProject("projectName")], then you can retrieve productInstances [$piList=$projObj.getProductInstances()] under this project, find your machine in this productInstances [$machList=$pi.getMachines()], once you get your machine's machineObject, you can get its machine pool [$poolobj=$machine.Pool], and now you can move your machine from its pool to the DefaultPool. :)

    Thanks,

    Nilesh.



    • Edited by Nilesh90 Friday, April 12, 2013 9:57 AM
    Friday, April 12, 2013 9:55 AM
  • Hi,

    You would be the one who create the machine pool so you should know where the machine should place.

    Monday, April 15, 2013 2:16 AM
  • Thank you.  That is a good answer, and I'll do that.
    Wednesday, November 27, 2013 1:55 AM
  • Nilesh90,  Thank you for your answer.  I also appreciate the detail, still getting used to the PowerShell syntax.  : )
    Wednesday, November 27, 2013 1:57 AM
  • Correct.  And usually I will know that, except for times when I abandon a machine and forget what project I left it in. 

    : )

    Wednesday, November 27, 2013 1:58 AM
  • Hi HH,

    Iterating through all child pools to find the machine, is a troublesome task. it's a best practice to keep the machine in default pool. I coded the script for moving the machine from default pool to other machine pool.

    Thanks,

    Mudit

    Wednesday, November 27, 2013 4:53 AM