Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Automating rebuild
PostPosted: Fri Jan 20, 2012 8:34 am 
Offline
Senior Newbie

Joined: Fri Jan 20, 2012 8:30 am
Posts: 5
Has anyone got something like this working, a bash script to delete an instance and bring it back up again using a StackScript?


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 9:32 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Yes you'll want to look at the api http://www.linode.com/api/

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 9:48 am 
Offline
Senior Newbie

Joined: Fri Jan 20, 2012 8:30 am
Posts: 5
I should have said - I have been using the API, and I did get started building something, but it turns out to be a ton of work to replicate the dashboard's Rebuild and Reboot functionality.

You have to fire off a number of jobs, monitor their status, etc. So I was wondering if anyone had automated all that via the API.


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 9:59 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
You shouldn't have to monitor the status of any jobs since they all execute in order, all you need to do is queue them up in the right order.

A workflow like this should work
1) Shutdown the linode
2) Delete all the disks and config profiles
3) Deploy from your stack script
4) Create a swap partition
6) Create a new config profile with the disks from 3 and 4
7) Boot the profile from 6

You can have the stack script mail you when it's complete and issue a reboot to itself and let lassie bring it back up.

You can do all that in only a hand full of bash commands

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 10:18 am 
Offline
Senior Newbie

Joined: Fri Jan 20, 2012 8:30 am
Posts: 5
It's asynchronous though, unless someone's made a blocking API wrapper.

You generally have to fire these off, get their job ID, and poll until the job is complete before moving on to the next one. Not rocket science, but not trivial either.


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 10:20 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
No it's synchronous, the jobs are queued and performed one after the other. Send a bunch using the api and check the manager queue you'll only ever see one running.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 10:42 am 
Offline
Senior Newbie

Joined: Fri Jan 20, 2012 8:30 am
Posts: 5
I see, thanks.

Still interested if anyone has a sample script, but if not, this makes it a lot more straightforward.


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 10:44 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
This is what I wrote to send commands to the api https://github.com/rwky/Linode-Bash-API it has some macros in there which can guide you on how to capture disk ids etc.

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Fri Jan 20, 2012 11:18 am 
Offline
Senior Newbie

Joined: Fri Jan 20, 2012 8:30 am
Posts: 5
Thanks, I've been using the Ruby wrapper, but this looks fine too.

I think the business about Job IDs still makes it a non-trivial exercise though, as a script needs to notify if things are failing.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group