Package: xopera-template-library
Template Library CLIThis is a CLI client for the Template library.Table of ContentsIntroductionPrerequisitesInstallationUsageSetupAuthTemplatesTemplate groupsUsersUser groupsIntroductionTemplate library CLI is calledxopera-template-libraryand is
available onPyPIandTestPyPIinstances. The tool can be used to view, upload and
download TOSCA template modules and their implementations.Prerequisitesxopera-template-libraryrequires python 3 (and a virtual environment). In a typical modern Linux environment, we
should already be set. In Ubuntu, however, we might need to run the following commands:$sudoaptupdate$sudoaptinstall-ypython3-venvpython3-wheelpython-wheel-commonInstallationAfter the prerequisites are satisfy you can proceed with the installation.
The simplest way to testxopera-template-libraryis to install it into virtual environment:$mkdir~/opera&&cd~/opera$python3-mvenv.venv&&..venv/bin/activate(.venv)$pipinstallxopera-template-libraryUsageThis part explains the usage of Template library CLI tool.$xopera-template-librarytemplate-husage: xopera-template-library [-h] [-v]{template,template-group,user-group,user,setup,login,logout}...positional arguments:{template,template-group,user-group,user,setup,login,logout}template            Template actions.template-group      Actions for groups of templates.user-group          Actions for groups of users.user                User info.setup               Setup client variables.login               Login to your account.logout              Logout of your account.optional arguments:-h, --help            show this help message and exit-v, --verbose         Increase output verbosityAt any point the-h/--help(help) flag is available to display proceeding options. There is also-v/--verboseflag
that will turn on the debug mode to see more output.SetupBefore you begin usingxopera-template-librarytool you have to make sure that Template library REST API endpoint and
KeyCloak auth endpoint are properly configured. This can be done withsetupcommand where you will be able to change
the default values that are:# default REST API endpointREST_API_ENDPOINT="https://template-library-radon.xlab.si/api"# default KeyCloak endpointKEYCLOAK_ENDPOINT="https://openid-radon.xlab.si"If you run onlyxopera-template-library setupyou will be able to modify only the REST API endpoint. You have to use--keycloakflag to tell the CLI that you will modify KeyCloak auth endpoint too.Examples:$xopera-template-librarysetup--keycloakCurrent Template Library REST API endpoint: https://template-library-radon.xlab.si/apiModify API endpoint (press enter to keep the current):Template library REST API endpoint has been set to: https://template-library-radon.xlab.si/api.Current KeyCloak auth endpoint: https://openid-radon.xlab.siModify KeyCloak endpoint (press enter to keep the current):KeyCloak endpoint has been set to: https://openid-radon.xlab.si.AuthYou can access public templates without authorizing.
For other actions and to see your private templates, you need to login with your Keycloak identity provider account.You can login as:XLAB KeyCloak userOther identity provider's KeyCloak user (use--identity-providerflag)If--identity-providerand the ID are present, user will be logged in with the chosen identity provider.
If you do not know the ID of the provider you can leave out the ID and the available providers will be listed and you
will be able to choose one for authentication.Examples:#loginasXLABKeyCloakuser$xopera-template-librarylogin--username"username1"--password"password1"#loginasanotheridentityprovider'sKeyCloakuser(youknowidentityproviderID)$xopera-template-librarylogin--username"username1"--password"password1"--identity-provider"identity_provider_ID"#loginasanotheridentityprovider's KeyCloak user (you don'tknowidentityproviderID)$xopera-template-librarylogin--username"username1"--password"password1"--identity-providerTo logout, usexopera-template-library logoutTemplatesNext you can use optionlistto display available templates.
The templates will list in a table with templates' information.
You can use filters forkeyword(template name and description), templatetypeand templateprivacysetting.
Optionversiondisplays a list of template's published versions.Examples:$xopera-template-librarytemplatelist$xopera-template-librarytemplatelist--keywordaws$xopera-template-librarytemplatelist--typenode--publictrue$xopera-template-librarytemplateversion--nameAwsLambdaTo download a template you have to provide apathto where you want the template to be saved and the name of the
template to download. By default, the last version is downloaded.
With argument--versionyou can download other versions.Example:$xopera-template-librarytemplateget--nameDemoBlueprintOpenFaaS--pathexample/$xopera-template-librarytemplateget--nameDemoBlueprintOpenFaaS--pathexample/--version0.0.1If the desired template does not exist you can create and upload your own.
You can start by generating a basic file structure by usingcreateoption.
You will be asked for your template's name and type.Possible types aredata,artifact,capability,requirement,relationship,interface,node,group,policy,csarandother.Examples:$xopera-template-librarytemplatecreateTemplate type: nodeTemplate name: ExampleTemplateWhen using thexopera-template-library template createCLI command this will automatically create the structure for
your template, which contains the following files:|-- Folder|-- files|-- create.yml|-- delete.yml|-- NodeType.tosca|-- README.mdThe structure is similar toRADON particlesand is compatible withEclipse Winerymodelling tool.After the basic files are generated you can edit them and upload your template to the library (usesaveCLI command).
By default templates are private. For publishing your template publicly, add--publicflag.Examples:$xopera-template-librarytemplatesave--nameAwsLambda--pathexample/AwsLambdaFunction--public--version0.0.1Template groupsTemplates can be ordered intemplate groups. User can create a template group, list existing groups and get a list
of templates in a template group. Template group owners can add and remove templates.Examples:$xopera-template-librarytemplate-groupcreate--group_nameAwsGroup--group_description"A group of AWS related templates"$xopera-template-librarytemplate-grouplist$xopera-template-librarytemplate-groupget--group_nameAwsGroup$xopera-template-librarytemplate-groupadd-template--group_nameAwsGroup--template_nameAwsBucket$xopera-template-librarytemplate-groupremove-template--group_nameAwsGroup--template_nameAwsBucketUsersUsers can look up their info, list user groups they are members of and list template groups they have access to.Examples:$xopera-template-libraryuserinfo$xopera-template-libraryuseruser-groups$xopera-template-libraryusertemplate-groupsUser groupsUsers can be members ofuser groups. User groups can be granted access to groups of templates. User can create a
user group, list existing groups, get a list of users in a given user group and get a list of template groups a user
group is granted access to.User group owners can add and remove users and access to template groups.Examples:$xopera-template-libraryuser-groupcreate--group_nameRadonGroup--group_description"Members of Radon project"$xopera-template-libraryuser-grouplist$xopera-template-libraryuser-groupget-users--group_nameRadonGroup$xopera-template-libraryuser-grouptemplate-groups--group_nameRadonGroup$xopera-template-libraryuser-groupadd-user--group_nameRadonGroup--usernamejohny$xopera-template-libraryuser-groupremove-user--group_nameRadonGroup--usernamejohny$xopera-template-libraryuser-groupadd-templates--user_groupRadonGroup--template_groupAwsGroup$xopera-template-libraryuser-groupremove-templates--user_groupRadonGroup--template_groupAwsGroup