Now that SUSECon 2016 is over and everyone is heading back home, it’s time to provide more background on some of the new features and technologies we showcased in Washington.
Today I’m going to pick the new Formulas with Forms in SUSE Manager 3, a feature that also made it into our “Demopalooza”, the coolest technical keynote in the industry. It’s what we used to manage the start time, duration, and quality of the session recordings we did with the Raspberry PI.
This first of a series of blogs is an introduction into the concepts and technology behind Formulas with Forms. It will be followed by posts about what our plans for the future are, how you can tweak them to meet your needs, and how to write your own.
Like so many other cool things at SUSE, Formulas with Forms started as a SUSE Hackweek project. In a nutshell, we are taking Salt’s concept of Formulas, collections of States that are packed up in a folder and are written following some best practices, to the next level.
The idea was as simple as it was promising: Formulas usually come with a file called “pillar.example” that provides a template of the parameters (or Pillars in Salt speak) that you can use to customize your Formula.
Now what if you could expose those Pillars to admins in SUSE Manager in a pretty form with checkboxes and dropdown menus, so that they don’t have to edit files to apply and customize Formulas for use with their servers?
That’s what we did. And we made it really easy to write those forms in YAML. Let me take the “timezone” Formula again. It comes with a pillar.example that looks like this:
timezone: name: 'Europe/Berlin' utc: True
This will create a Pillar namespace called “timezone” that has two attributes, “name” and “utc” (which is a boolean).
The form.yml for this Pillar looks very similar. In fact, it’s mainly annotating the Pillar syntax with additional tags, all starting with “$”:
timezone: $type: hidden-group name: $type: select $values: ["UTC", "Europe/Berlin", "US/Mountain"] $default: Europe/Berlin utc: $type: boolean $default: True
The first entry creates a group that allows you to bundle form fields (and the Pillar data they generate) into namespaces.
We need to do this because the pillar.example expects the attributes “name” and “utc” to be keys within the “timezone” Pillar. If we changed the type from “hidden-group” to “group”, this grouping by namespace would actually be visible as an extra box around the fields in the web form.
While “name” could just be a text field, we choose to make it a dropdown menu, so you don’t have to type (and correctly spell) the timezone. We also pick a default with the “$default” tag. Finally we add “utc” as a boolean and give it a default of “True”.
It’s as simple as that. In most cases, both the field type and the default can be missing, and things would still work. In that case we’d just get a plain text field without a default value. And for cases as simple as the “timezone” Formula we even have a small Python script that can generate a minimal form.yml file automatically!
In the next post I’m going to present a few use cases and examples for Formulas as Forms.
This is Joachim Werner blogging live from a 747-8 over the North Atlantic on the way back home from SUSECon.