...
Deutsch | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
VariablenUm die Nutzung der Add-ins weiter auszubauen, besteht die Möglichkeit Variablen zu verwenden. Diese können als schreibgeschützte Werte in Add-ins verwendet werden. Eine Variable besteht aus den folgenden Parametern:
Variables can be created in the Add-in menu by selecting the variables buttonkönnen in dem Menü Add-ins → Variablen erstellt und bearbeitet werden. Variablen hinzufügen:Eine Variable kann an verschiedenen Stellen verwendet werden. Bei Verwendung der gleichen Variable an mehreren Stellen überschreibt die letzte Variable die vorherigen Einträge.
Global: Wird einer Variable ein Wert zugewiesen, gilt diese global. Diese kann dann in einem Add-in verwendet werden. Netze: Wechseln 1. Wechseln Sie in das Menü Netze → Variablen, wählen ein Netzwerk aus und klicken auf auf Variablen → Variablen hinzufügen. Standorte: Wechseln Sie in das Menü Standorte → Variablen und klicken auf Variablen hinzufügen. Geräte: 2. Wählen Sie die gewünschte Variable aus und weisen dieser gegebenenfalls einen Wert zu bzw. wählen die Aktion aus. Klicken Sie anschließend auf Hinzufügen. Standorte: 1. Wechseln Sie in das Menü Geräte Standorte, wählen ein Gerät einen Standort aus und klicken auf auf Variablen → Variablen hinzufügen. Neuen Variablen-Typ definieren 2. Wählen Sie die gewünschte Variable aus und weisen dieser gegebenenfalls einen Wert zu bzw. wählen die Aktion aus. Klicken Sie anschließend auf Hinzufügen. Geräte: 1. Wechseln Wechseln Sie in das Menü Add-ins Geräte, wählen ein Gerät aus und klicken auf auf Variablen → Variablen hinzufügen. 2. Klicken Sie auf Variablen-Typen. Neuen Variablen-Typ definieren:1. Wechseln Sie in das Menü Add-ins und klicken auf Variablen. 2. Klicken Sie auf Variablen-Typen. 3. Klicken Sie anschließend auf Neuen Typ hinzufügen. 4. Es gibt zwei mögliche Variablen-Typen (String selection und Regulärer Ausdruck). String selection: Passen Sie die folgenden Parameter an und klicken auf Speichern:
Regulärer Ausdruck: Um die Eingabe-Möglichkeiten für Variablen zu limitieren, wird auch die Möglichkeit zur Verwendung regulärer Ausdrücke (regular expressions - Regex) unterstützt. Für die regulären Ausdrücke stehen die folgenden Optionen zur Verfügung:
Passen Sie die folgenden Parameter an und klicken auf Speichern:
Defining a Neue Variable anlegen: 1. Wechseln Sie in das Menü Add-ins → Variablen und klicken auf Neue Variable. 2. Passen Sie die folgenden Parameter an und klicken auf Speichern:
Verwenden von Variablen:Werte von Variablen können in dem Objekt To define a new variable click on the Variable definition button. Provide a variable name and select the variable type from the drop down list. Select the default value of the variable from the previously defined selections of the variable type. Select the checkbox Use as password if you want to hide the contents within the UI with asterisks ( Click on the checkbox to save your variable definition. Using variablesVariable values can be used using the object
Systemvariables-Variablen:System-Variablen verwalten spezifische Aspekte der Smart-Konfiguration.
System variables manage specific aspects of the smart configuration.
Beispiel für eine Status-Anfrage: Der folgende Code-Auszug zeigt die generelle Herangehensweise für eine Status-Anfrage. Tauschen Sie die Variablen “Systemvariable” und “Value” je nach Bedarf aus. Der Add-in Code muss unter der auskommentierten Zeile Example for a status query: The following code snippet shows the general approach for a status query. Change the variables “Systemvariable” and “Value” according to your needs. Enter the actual Addin code under the commented line “Code will be executed, if variable is met.” eingefügt werden.
Available Verfügbare System variables-Variablen:
WerteWritingSchreibenSie können die Konfiguration, welche an ein Gerät gesendet werden soll, per To modify the configuration that is sent to a device you can use
Changes made by Konfigurations-Änderungen, welche per Dies kann auch per
Changes made by Konfigurations-Änderungen, die per Readingvorgenommen wurden, sind nicht in der Konfigurations-Vorschau sichtbar, da diese nur auf dem Gerät ausgeführt werden.Diese Mehode funktioniert ausschließlich auf LCOS-basierten Geräten. LesenInformationen können von einem Gerät über die Funktion
There is no equivalent Es gibt kein Äquivalent für |
Englisch | |
---|---|
VariablesTo further extend the use of Add-ins we have the possibility to use variables. These can be used as read-only values within Add-in scripts. A variable consists of
Variables can be created You can create and edit Add-ins in the menu Add-in menu by selecting the variables button.ins → Variables. Adding Variables:A variable can be set the following places and follows a hierarchy where the last one overrides the previous ones.
For this, open the respective Variables view, and add the defined variables. As an example, here you can find the Variables menu on a device. Defining a Variable TypeA variable is either of type To define a new type click on the Variable Types button. Next, click on Add new type. Give the type a name (e.g. Switch), and add a number of selectable variable values, for example:
Click on Save to save your variable type. We also support regular expression for variable types to limit the input for variables. | |
Regular expression | description |
IPv4 | Only a valid IP address is allowed for variables with that variable-type. |
Subnet mask | Only a valid subnet mask is allowed for variables with that variable-type. |
[A-Z a-z]* | Only ASCII characters in the range from A-Z and a-z are allowed for variables with that variable-type |
User defined | You are able to create your own regular expression to limit the input. |
Regular expression | Description |
---|---|
IPv4 | Only a valid IP address is allowed for variables with that variable-type. |
Subnet mask | Only a valid subnet mask is allowed for variables with that variable-type. |
[A-Z a-z]* | Only ASCII characters in the range from A-Z and a-z are allowed for variables with that variable-type. |
User defined | You are able to create your own regular expression to limit the input. |
Modify the follwing parameters and click Save:
- Variable Type: Select the option Regular expression.
- Name: Enter a descriptive name for the variable (in this example IP).
- Display name: For better understanding a Display name is added in this example, as no blank space must be used in the Name.
- Regular expression: In the dropdown menu select the desired option (in this example IPv4).
Create a new Variable
1) Go to the menu Add-ins → Variables and click on New variable.
2) Modify the following parameters and click Save:
- Name:Enter a descriptive name for the variable (in this example wlanstate).
- Variable type: In the dropdown menu select a Variable type (in this example the newly created type Switch defined in the section Defining a Variable type).
- Value: Enter a value for the variable or select an option in the dropdown menu.
Defining a Variable
To define a new variable click on the Variable definition button. Provide a variable name and select the variable type from the drop down list.
Select the default value of the variable from the previously defined selections of the variable type. Select the checkbox Use as password if you want to hide the contents within the UI with asterisks (***
).
Click on the checkbox to save your variable definition.
Using variables
Variable values can be used using the object context.vars
:
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
if (context.vars.deviceName) { // checks if the variable is set
context.setScalarByOid("1.2.1" /* /Setup/Name */, config.vars.deviceName);
}
};
System variables
System variables manage specific aspects of the smart configuration.
- All System variables (with the exception of the variable UF_DEFAULT_IF) can be modified in the Project specifications.
- System variables cannot be modified by Add-in scripts (Read-Only).
- System variables are only available for the Network and Device layers.
- System variables can only be used for status queries (the configuration is to be rolled out, if the System variable equals a certain value).
Example for a status query:
The following code snippet shows the general approach for a status query. Change the variables “Systemvariable” and “Value” according to your needs. Enter the actual Addin code under the commented line “Code will be executed, if variable is met.”.
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
if Systemvariable == ("Value"){
//Code will be executed, if variable is met.
};
};
Available System variables:
INITIAL_TEST_MODE_ENABLED:
- Enables a 300 second test mode for initial configuration rollout (enabled by default).
- Can be modified with the setting Testmode after initial configuration rollout in the menu Project specifications -> → Device startup.
PASSWORD:
- Global Main device password.
- Can be modified in the menu Project specifications -> → Basic.
UF_CLEAR_DEFAULT_CFG:
- Disables default interfaces of a Unified Firewall during configuration rollout (disabled by default).
- Can be modified with the setting Disable default networks during configuration rollout to LANCOM R&S®Unified Firewalls in the menu Project specifications -> → Device startup.
UF_DEFAULT_IF:
- Default interface for network rollout via the LANCOM Management Cloud.
- The default interface is eth1 and can only be changed via the API.
LMC_DOMAIN:
- URL setting for private LMC instances.
UF_ETH0_NETWORKS ... UF_ETH10_NETWORKS:
- Network assignment to ETH port of the Unified Firewalls.
VPN_IDENTITY_SEPARATOR:
- Symbol used for the automatic VPN creation: (e.g with the default "@": ALL@HQ__).
Values
Writing
To modify the configuration that is sent to a device you can use config.setScalarByOid
:
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
config.setScalarByOid("1.2.9.11", "Comment 1");
config.setScalarByOid("1.2.9.12", "Comment 2");
};
Changes made by config.setScalarByOid
will be visible in the config preview, as they are applied to the configuration before it is sent to the device.
The same can be achieved by using config.addScriptLine
:
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
// LCOS only:
config.addScriptLine('set /Setup/SNMP/Comment-1 "Hello"');
config.addScriptLine('set /Setup/SNMP/Comment-2 "World"');
};
Changes made by config.addScriptLine
are NOT visible in the config preview, as they are only run on the device. This method only works on LCOS based devices.
Reading
/**
* @param {Config} config
* @param {Context} context
* Do not edit this comment or parameter types. Required for code suggestions
*/
exports.main = function (config, context) {
var comment1 = config.getScalarByOid("1.2.9.11");
var comment2 = config.getScalarByOid("1.2.9.12");
};
There is no equivalent config.addScriptLine
to read data from the device.
...