PowerCLI wrapper with Skaffolder part1 – The architecture

Skaffolder is a technology “Made in Italy” that speed-up the coding process for every developer, by the usage of templates and code generators. Additionally, this platform can realize front-end code saving a lot of time spent in coding and testing but keeping the focus on what is really dependent on the purpose of the application.

Here I’dd like to share use-cases in a series of articles which describe how to build an integration for Powershell/PowerCLI scripts using Skaffolder.

This example will use MongoDB and NodeJS as backend; finally, the generated code will be shipped in a docker-compose. For this reason, it’s mandatory to install docker on your system.

Using container since the development is becoming a mandatory eay to work that accelerate the environment distribution without wasting time installing or build elements which strictly depends on the underline technology.

The architecture

Basically, every PowerCLI script must be handled by an API method which is connected to a specific model. The use of NodeJS gains some advantages like:

  1. A native asynchronous process handling (this could avoid the use of system scheduling)
  2. The use of Swagger Library, which easily creates API methods using a YAML file definition
  3. The use of the same language to develop front end and back end applications

 

Near the script launcher, in the major part of the application, it is necessary to provide the right authentication barer, that simply provide and consume authentication token and organize API method with roles.

Model View and Execution workflow

All begins drawing the model that fits with your application. Skaffolder has an interesting GUI that provides a great whiteboard to really design Class, methods and relations. Every time it is possible to generate web services based on Swagger and uses JSON Web Token to handle the authentication. For this example I consider two private web services:

  • Login API (provided by default)
  • ScriptExecution API

Note: If you start with I started a new Skaffolder project giving PowerCLILaunch as the name of this project. Consequently the db name will be PowerCLILaunch_db.

Focusing on Models the final picture will be composed by:

  • ScriptExecution
    • attributes:
      • ID
      • TimeStart, TimeUpdate and TimeEnd: handles time process from start to end, including updates during script execution
      • Filename: PowerShell or PowerCLI file to execute
      • HasResults: stores information about results after script execution (Error in case of errors inside and outside the execution script.
      • ResultType: a string JSON that describes the way to store and present results (eg: table, objects, single value,…)
      • State: can be running or end
    • methods:
      • CRUD standard
      • Launch: this launch the script (once per execution id)
  • Result: store results in relation many to 1 with ScriptExecution. is composed by:
    • attributes:
      • ID
      • ExecTime: the same as ScriptExecution TimeUpdate
      • Name: attribute value name
      • Value: value
    • methods: CRUD standard

Working with Server Template

After Model design, it’s time to work with Skaffolder template before the code generation. I suggest the use its CLI especially if you are developing under MAC or Linux machine. Now create a new directory and issue “sk login” and “sk open”, then choose the right project.

As you can see the template is delivered in a directory called .skaffolder; there is possible make customization giving a different indication to the code generator in order to personalize the generated code to a specific environment.

Finally, generate the code

After template modifications, you can generate the simply typing sk generate:

In the next post, I’ll show how to customize the template and build the “Launch method”.

If you want to try Skaffolder, just check the official link here: https://www.skaffolder.com

   Send article as PDF