We have seen a couple providers who don't have set plans, and their
sizes can be completely arbitrary. (ie, 128mb to 2gb of ram, in 1mb
increments).
I have been pondering how to best expose this flexibility, without
making it too complicated.
Currently we have list_sizes as the main way to get a NodeSize object
to use when calling create_node. What we do today for providers like
VPS.net, is a range(), and create potentially hundreds of NodeSize
objects. This seems less than optimal if you wanted to make a UI
listing all of the available sizes for example.
I think the best was to do it would be to add a new optional method to
the driver interface. (Alternative names welcome)
'variable_node_size', would take the same kwargs (and optionally
provider specific ones) as the NodeSize interface, if the provider
can't create a NodeSize as requested, throw an exception.
For all of the other drivers, they would just not implement this method.
So, using it would be something like
ns = None
if hasattr(driver, 'variable_node_size'):
try:
ns = driver.variable_node_size(ram=568, disk=50)
except:
# node size isn't available
if not ns:
ns = driver.list_sizes()[0] # fall back to your normal node size selection
Thoughts?
Thanks,
Paul
Being more specific, VPS.net and vCloud both have variable sizes.
vCloud has fixed RAM, but variable disk (you can pick how many GB you
want). VPS.net allows you to get different sizes in fixed units,
adding 256M of RAM and 10G of disk per unit.
> I have been pondering how to best expose this flexibility, without
> making it too complicated.
>
> Currently we have list_sizes as the main way to get a NodeSize object
> to use when calling create_node. What we do today for providers like
> VPS.net, is a range(), and create potentially hundreds of NodeSize
> objects. This seems less than optimal if you wanted to make a UI
> listing all of the available sizes for example.
>
> I think the best was to do it would be to add a new optional method to
> the driver interface. (Alternative names welcome)
> 'variable_node_size', would take the same kwargs (and optionally
> provider specific ones) as the NodeSize interface, if the provider
> can't create a NodeSize as requested, throw an exception.
>
> For all of the other drivers, they would just not implement this method.
>
> So, using it would be something like
>
> ns = None
> if hasattr(driver, 'variable_node_size'):
> try:
> ns = driver.variable_node_size(ram=568, disk=50)
> except:
> # node size isn't available
>
> if not ns:
> ns = driver.list_sizes()[0] # fall back to your normal node size selection
I think the use case is going to be someone wants an equivalent sized
node on a different provider. So maybe the interface should just be
driver.get_size(ram=568, disk=50), which is supported on any provider.
The providers that have discrete sizes, we just round up. The NodeSize
object has price in it, so you should be able to inspect and make sure
that the machine satisfies your requirement. This way we would still
support list_sizes, which has all the possible sizes on that provider.
For VPS.net and vCloud, it would be a really long list that gets
generated.
# no matter what the driver, ns will have at least 568M of RAM and 50G of disk
try:
ns = driver.get_size(ram=568, disk=50)
except NodeSizeNotFound:
.....
No matter what the solution, I think it should be supported on all the
drivers, so we do not need to do weird hasattr stuff.
-Alex
--
co-founder, cloudkick.com
twitter.com/cloudkick
541 231 0624
Nice, I really like the idea of a get_size method. The default
implementation can just call list_sizes(), and find the nearest match,
and just always round up.
And since you can inspect the NodeSize after the call, you can always
see exactly what you are getting.
I guess if the call is something like disk=500, and the provider has a
max disk size of 100gb, we would just throw an exception, as its not
possible to get a node that big? (the other option is to round 'down'
in that case, but I think it becomes a messy interface then -- always
rounding up to the next available size makes lots of sense to me)
Thanks,
Paul