Automate naming computers in Deploystudio

One thing I have always wondered has been removing the error and the manual out of our imaging process.
While Deploystudio does offer many tools to automate the process and design workflows to achieve completion, I still needed to come up with a way to deal with computer names and the computer records that are stored in Deploystudio.
Thankfully, Deploystudio has a REST API which can be used.

What I wanted to do:
-Netboot a computer into Deploystudio
-Select a designated workflow
-Have a script grab the serial of the mac and look through Deploystudio database for a record,if that record exists, the computer name and hostname will be updated with a new generated name based on a designed convention along with other informations should we find the need for and if the record doesn’t exist, it will be created.

I have put together a couple of scripts, that about handles everything in one go.
While on the Deploystudio Server, Download my scripts from my Repo and keep them together.
Now that we have downloaded the pieces, we need to add our info to the scripts
Setup.py –> Needs the path to your DS Repo
I would recommend opening up a Terminal window and navigating to the Repo.
Once in the repo, type pwd to get the full path and copy that into setup.py
Screen Shot 2015-03-22 at 2.58.41 PM

Set DS_repo_path to your DS Repo path (Replace the contents of with your path) and save the file.
Open hostname_generator.py and add your Deploystudio Url and credentials
Screen Shot 2015-03-22 at 3.01.58 PM

host = ‘Deploystudio Url’ ##–> Deploystudio URL
adminuser = ‘Deploystudio_username’##–> Deploystudio username
adminpass = ‘Deploystudio_password’ ##–> Deploystudio password
Once done, Save the file and open up a Terminal window
Make sure you have git installed; You can check by typing git –version in Terminal
It will returned the version of git you are running or if you are not, Launch a Menu to install it.

Screen Shot 2015-03-22 at 4.36.15 PM

Before you continue down, Make sure Git is installed
While in Terminal, navigate to the location of both setup.py and hostname_generator.py and type:
python setup.py
Screen Shot 2015-03-22 at 3.08.32 PM

(I assume your DS Server has access to the internet as we need to download a few things)
Seat back and relax
Screen Shot 2015-03-22 at 3.13.21 PM
Once completed, Launch Deploystudio Admin and confirm the presence of hostname_generator.py in your Scripts section.

Screen Shot 2015-03-22 at 4.55.26 PM

Now we add hostname_generator.py to a workflow; it needs to be before the Configure task since we want to update the database prior to configuring the settings.
Also setup the script with Postpone uncheck and automate check as we want to make sure the database is updated on the first go and unattended.

Screen Shot 2015-03-22 at 5.01.22 PM

That’s it…. We are done, netboot a mac and test out your new workflow.

Advertisements

2 thoughts on “Automate naming computers in Deploystudio

  1. Pingback: Automate naming computers in Deploystudio | Dinesh Ram Kali.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s