List all devices managed by Junos Space.
Add and remove devices to/from Junos Space.
Get information about all of the software images that Junos Space manages.
With this information, you can stage images to devices to be used at a later time to upgrade.
Directly issue a software upgrade to a device.
Remove staged images from a device.
Add/remove address objects and groups.
Policy management (this one might take longer than the previous items).
So, without futher adieu, here’s a basic tutorial on how to add/remove devices, and issue a software upgrade to one of them.
First, make sure you have the go-junos library imported.
// Make sure you have the go-junos library imported.
Now let’s connect to our Junos Space server.
Now that we’ve established our connection, let’s work with the devices.
// Get information about all the devices within Junos Space.
Note: Currently, there is no action to handle the jobID number that is returned, but something is in the works. You could query the job-management API and return job info if you’d like. See the Junos Space API for more information.
Here’s how to resynchronize a device with Junos Space. This comes in handy if you make a lot of changes outside of Space, such as adding interfaces, etc.
Let’s take a look at how we can issue a software upgrade using this library.
The false option basically let’s you choose if you want to remove any pre-existing image when staging a new one. true for yes, false for no.
// UseDownloaded: Use a pre-staged image. If set to false, then the image will be downloaded at the time of the upgrade.
// Validate: Validates our configuration against the new image.
// Reboot: Reboot after an upgrade.
// RebootAfter: Reboot after X minutes. Leaving this 0 basically disables this option.
// Cleanup: Remove any existing images.
// RemoveAfter: Remove our image after a successful upgrade, to free up more space.
And that’s pretty much it! Software upgrades can take a while, depending on the device and image, so please keep that in mind. Just like I noted above, the jobID has no function at the moment, but will in the future. Again, you could query the server yourself to check the status, or see the job status in the Junos Space GUI.
I hope that you find this helpful. More abilities will be coming soon, so please check back.
For more information, please check the documentation on the Github repo, or the GoDoc page.