+ Developer list since it seems to better belong there. But it seems to me that the allocator is entirely the wrong place to put such a check. What you are trying to implement is a network check. If you implement a NetworkElement then your network element gets called whenever a VM is about to be placed into a network. You can prevent it there. I don't see what this has to do with the specific host it is placed on.
Chiradeep On 8/8/12 3:16 PM, "Prachi Damle" <prachi.da...@citrix.com> wrote: >Yeah, if your precondition fails you don't need to call >super.allocateTo() at all, simply return empty list. You can refer >FirstFitRoutingAllocator that does the exact same thing. > >-Prachi > >-----Original Message----- >From: Amir Nashat [mailto:amir.nas...@citrix.com] >Sent: Wednesday, August 08, 2012 3:07 PM >To: 'cloudstack-us...@incubator.apache.org' >Subject: RE: CloudStack Allocator Pre-Condition Check > >Ok, I'll use your suggestion of returning an empty list which is what my >intention was with setting the returnUpTo value to 0. I won't modify the >returnUpTo value but rather return an empty ArrayList if my pre-condition >fails. > >It seems my approach was wrong so it's no longer important but to answer >your question of how I was planning on setting returnUpT=0, I was going >to extend the FirstFitAllocator class, override the allocateTo() method >and if my pre-condition failed I would set a value of returnUpTo = 0 and >call the super.allocateTo() passing in the modified returnUpTo. > >Thanks again for your help! > >Amir > > > >-----Original Message----- >From: Prachi Damle [mailto:prachi.da...@citrix.com] >Sent: Wednesday, August 08, 2012 2:36 PM >To: cloudstack-us...@incubator.apache.org >Subject: RE: CloudStack Allocator Pre-Condition Check > >Yes you can use vmProfile.getHostName(). > >About the returnUpTo Value, I don't see why you should set it 0. >returnUpTo = 1 means you allocator should atmost 1 suitable host - it >could still return empty result. >returnUpTo = -1 would mean lalloctaor should return as many matching >hosts as it finds. > >If your pre-condition is not satisfied by the VM profile, you can just >return an empty list irrespective of the returnUpto value. > >Also where do you plan to set the returnUpto value ? The existing >FirstFitPlanner sets the returnUpTo = -1 and calls the allocators. >Are you planning on implementing custom planner and set a different >returnUpto value? > >-Prachi > >-----Original Message----- >From: Amir Nashat [mailto:amir.nas...@citrix.com] >Sent: Wednesday, August 08, 2012 2:16 PM >To: 'cloudstack-us...@incubator.apache.org' >Subject: RE: CloudStack Allocator Pre-Condition Check > >Hi Prachi, > >So are you suggesting to set the returnUpTo value to 0? > >To confirm, I can get the hostname of the guest VM from >vmProfile.getHostName() ...this is correct? > >Thanks for your feedback! > >Amir > > > >-----Original Message----- >From: Prachi Damle [mailto:prachi.da...@citrix.com] >Sent: Wednesday, August 08, 2012 2:12 PM >To: cloudstack-us...@incubator.apache.org >Subject: RE: CloudStack Allocator Pre-Condition Check > > Amir, > >Yes to add any custom checks on top of the existing host allocation you >will need to write your HostAllocator extending the default >FirstFitAllocator. Also replace the FirstFitAllocator in componets.xml by >your custom allocator. >If your condition verification fails, your allocator should return an >empty list of hosts and not an error. The deployment planner will handle >the empty result returned by the host allocator. > >Thanks, >Prachi > > >-----Original Message----- >From: Amir Nashat [mailto:amir.nas...@citrix.com] >Sent: Wednesday, August 08, 2012 1:58 PM >To: cloudstack-us...@incubator.apache.org >Subject: CloudStack Allocator Pre-Condition Check > >Hello, > >I would like to get feedback as to the best approach for performing a >pre-condition check before allocating a guest vm to a physical host. For >my example, a pre-condition check is to verify the guest vm does not use >an existing DNS entry. If the pre-condition fails we do not want to >allocate the guest vm to the physical host and we want to record this as >an error condition. > >As far as I can tell the only option I have is to extend the default >FirstFitAllocator class and override the allocateTo methods to first >perform my pre-condition verification and if it passes then to call the >the overridden allocateTo() method. If it fails then I would throw a >RuntimeException of some sort or possibly set the returnUpTo value equal >to 0. > >Can you please advise as what would be the best approach? If anyone else >is performing pre-conditions checks in their allocation logic before >provisioning a guest VM please let me know of your approach. > > >Thank you, > >Amir