Users & Sessions¶
Users¶
Permissions¶
AMI has its own way of doing permission control over different groups of users so that certain windows are only visible to users with entitlements. Suppose we have two windows named Restricted and Everyone. The Restricted window should NOT be visible to the users whose role is NOT Admin. The following screenshot shows how to set up such a scenario.
-
Go to Dashboard -> Custom Callbacks
-
Go to onStartup tab and enter the following AMI script commands:
-
Hit Submit
Now the users should be able to see different windows based on their entitlements.
Sessions¶
Both the AmiWeb and AmiCenter have and manage sessions. Sessions are uniquely identified by a unique session identifier(_SESSIONID).
AmiWebSession¶
An AmiWebSession is created every time a user logs in to the frontend dashboard. The same user name can have multiple logins and a login can have multiple sessions. The below ERD(Entity Relation Diagram) is created to describe the relationship:
(1). One username can have multiple logins:
A user logins into a dashboard with two different browsers. We will see two login records,uniquely identified by __LOGINID, under the same username:
(2). One login can have multiple sessions: By default each login can have one session. This can be changed by configuring the property: ami.web.default.MAXSESSIONS
After updating the max sessions, if we click Account->Start New Session we could create a new session under the same login.
Headless sessions¶
(1).Getting Started
A headless session is a session that no single user claims ownership of. To create a headless session, edit your headless.txt
in amione/data/
by adding a line as follows: headless|headless123|2000x1000|ISDEV=true
, where the first argument is the headless session name and the third argument is the resolution of the screen on which the headless session will be displayed.
Before any user claims the ownership of a headless session, the __LOGINID for the headless session will be null.
(2).Claiming ownership
A user can claim ownership of a headless session by going to Account->Take Ownership of Headless Session -> \<headless session name>
After ownership is taken, this headless session will be tied to the current login.
(3).Releasing ownership
Likewise, the user can release the ownership of the headless session by clicking Account->Release Ownership of Headless Session.
AmiCenterSessions¶
Just like the notion of AmiWebSession, Ami Center also has the notion of session. One can see what sessions currently exist in the center by typing SHOW SESSIONS
in the DB console or frontend shell tool.
AmiCenterSession Composition¶
Typically, there are 4 different types of AmiCenterSession:
-
__SYSTEM is like the master session, sitting on top of the session hierarchy.
-
__RTFEED is another session that manages all the real time feeds.
-
__SCHEDULER sessions are sessions associated with timers. Each timer has one unique session associated with it.
-
Your DB console terminal or frontend shell tool also has one session associated with it.
Managing sessions with f1 console commands¶
Sessions can also be managed through the f1 console port. By default, f1.console.port=3285
In this section we'll review the commands available:
amiWebServer.showLogins()
-
Show all logins
amiWebServer.showSessions()
-
Show all sessions
amiWebServer.killSession(String sessionId)
-
Kill a user session
amiWebServer.createHeadlessSession(String sessionName, String username, String resolution, String attributes)
-
Creates a headless session, resolution is in format widthXheight, eg 1000x2000, attributes in a comma delimited list
amiWebServer.deleteHeadlessSession(String sessionName)
-
Delete a headless session
amiWebServer.describeHeadlessSession(String sessionName)
-
Print the headless session details as it is saved in headless.txt
amiWebServer.disableHeadlessSession(String name)
-
Disables a headless session
amiWebServer.enableHeadlessSession(String sessionName)
-
Enable a headless session
amiWebServer.killLogin(String uid)
-
Kill user login
amiWebServer.showPanels(String sessionId)
-
Show all panels
amiWebServer.exec(String sessionId, String script)
-
Execute amiscript
Headless Sessions (cont)¶
A headless session is a session not tied to a specific user.
Example: Automated Report Generation¶
Below are the steps for automatically generating reports and sharing them by sending an email, sending to an SFTP server, and saving to a filesystem.
Note that before starting AMI you will need to configure your headless.txt
in amione/data/
to create a headless session:
If you are looking to send reports by email then please set the relevant Email Configuration Properties in your local.properties
file e.g.
Create the report¶
The PdfBuilder can be used to construct pdf documents, collating text and images together. First, go to Dashboard > Data Modeller then right click on the background and select "Add Datamodel", then put in the relevant pdf logic. Below is an example of a pdf with two pages, the first page has some text and a chart from the layout, the second just has text.
The report can then be sent to a number of targets:
It can be sent via email (given email properties mentioned above were set):
Saved to local file system
The pdf can also be saved to amione/reports/
, in this case titled with the date it is generated on:
SFTP
The report can also be shared via a SFTP connection. First, go to Dashboard -> Data Modeler -> Attach Datasource...; then select SFTP from the datasources, and input your sftp server details. Click Add Datasource. Once successful, you can upload files to your remote server like so:
The above line will upload the pdf to the remote server at the path reports/report.pdf
.
Automate the datamodel¶
To automate the datamodel (and pdf generation) we can use the Timer interface, this can be accessed by clicking the Timers (0) button in the bottom right corner of the Edit Datamodel window.
Any standard crontab timer can then be used. For example, 0 */2 * * * * UTC
runs every two minutes. Inputting a time like 14:30:00
would make it run every day at 14:30. Click Test and make sure that the upcoming Runtimes are expected.
Once you've configured everything correctly, submit the timer, finish the datamodel, and save the layout.
Creating a headless session¶
We now have a layout with a datamodel which creates and sends a pdf. However, this is tied to a user session, so when the user logs out the reports will stop generating. To make sure our reports continue to run we'll need to use a headless session.
First, edit headless.txt
in amione/data/
as described at the start of this guide. Then start AMI and login as admin or dev user. Under Account -> Take ownership of headless session, select the headless session you set up in the headless.txt file.
Open the layout you made for constructing the report, then select Account -> Release ownership of this headless session.
This session will now continuously run and keep sending reports.