run a script before creating domain

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

run a script before creating domain

James Harper
I seem to be living in constant fear of starting the same domain on more
than one machine at once. As a way of preventing this, I'd like to be
able to have a script execute as part of an 'xm create' that runs before
doing any of the actual domain creation.

At the moment, all I'd do is do a 'ping' to see if the domain is up and
running. Not foolproof but would save me >99% of the time. In a cluster
environment there should be a way to determine remotely if a domain is
running.

Ideally, there would be a 'dom_check_exists' script automatically run
(if it exists) which could be implemented in a cluster environment, but
for now, where is a good place to hook into this?

Thanks

James

_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xensource.com/xen-devel
Reply | Threaded
Open this post in threaded view
|

Re: run a script before creating domain

Mark Williamson
Seems to me it might be nice to have a few hooks to trigger scripts at key
points.  You'd be able to configure these in the Xend config file (or
similar) and use them to implement extra checks / logging / functionality for
a specific environment.

> Ideally, there would be a 'dom_check_exists' script automatically run
> (if it exists) which could be implemented in a cluster environment, but
> for now, where is a good place to hook into this?

Needs to go inside Xend to strictly fit into the architecture.  How about
hacking it into tools/python/xen/xend/XendDomainInfo.py::create()?  Your
first step would be to add a call to vm.precreate_trigger(), which would run
your script in the first instance (or more generally, one that had been
configured in Xend's config).  You could use the return value of the script
to allow / disallow the creation, and return the output text as an error
message.

Of course, if you're just interested in hacking something up quickly, you
could add it to the xm tool's create command.  It's a bit ugly but it'll do
the job and be quick to hack in.

Cheers,
Mark

> Thanks
>
> James
>
> _______________________________________________
> Xen-devel mailing list
> [hidden email]
> http://lists.xensource.com/xen-devel

--
Dave: Just a question. What use is a unicyle with no seat?  And no pedals!
Mark: To answer a question with a question: What use is a skateboard?
Dave: Skateboards have wheels.
Mark: My wheel has a wheel!

_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xensource.com/xen-devel
Reply | Threaded
Open this post in threaded view
|

Re: run a script before creating domain

Ewan Mellor
In reply to this post by James Harper
On Fri, Jan 13, 2006 at 11:57:48AM +1100, James Harper wrote:

> I seem to be living in constant fear of starting the same domain on more
> than one machine at once. As a way of preventing this, I'd like to be
> able to have a script execute as part of an 'xm create' that runs before
> doing any of the actual domain creation.
>
> At the moment, all I'd do is do a 'ping' to see if the domain is up and
> running. Not foolproof but would save me >99% of the time. In a cluster
> environment there should be a way to determine remotely if a domain is
> running.

For such a quick-and-dirty check, couldn't you just write yourself a wrapper
script that did the ping and then called xm create?

If you want to do this properly, then inside Xend would be the best place, as
Mark Williamson suggests.  XendRoot handles the config file and the script
directories (see XendRoot.get_network_script for example).

Cheers,

Ewan.

_______________________________________________
Xen-devel mailing list
[hidden email]
http://lists.xensource.com/xen-devel