Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.


Deutsch

Variablen

Um 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:

  • Name
  • Typ
  • Wert

Variables können in dem Menü Add-ins → Variablen erstellt und bearbeitet werden.

Image Added



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
  • Netze
  • Standort
  • Gerät


Global:

Wird einer Variable ein Wert zugewiesen, gilt diese global. Diese kann dann in einem Add-in verwendet werden.


Netze:

1. Wechseln Sie in das Menü Netze, wählen ein Netzwerk aus und klicken auf Variablen → Variablen hinzufügen.

Image Added

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.

Image Added


Standorte:

1. Wechseln Sie in das Menü Standorte, wählen einen Standort aus und klicken auf Variablen → Variablen hinzufügen.

Image Added

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.

Image Added


Geräte:

1. Wechseln Sie in das Menü Geräte, wählen ein Gerät aus und klicken auf Variablen → Variablen hinzufügen.

Image Added

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.

Image Added



Neuen Variablen-Typ definieren:

1. Wechseln Sie in das Menü Add-ins und klicken auf Variablen.

Image Added

2. Klicken Sie auf Variablen-Typen.

Image Added

3. Klicken Sie anschließend auf Neuen Typ hinzufügen.

Image Added

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

  • Variablen Typ: Wählen Sie die Option String selection aus.
  • Name: Vergeben Sie einen aussagekräftigen Namen für die Variable (in diesem Beispiel Switch).
  • Name / Wert: Vergeben Sie einen oder mehrere Namen und zugehörige Wert(e) (in diesem Beispiel enable → on und disabled → off).

Image Added


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:

Regulärer AusdruckBeschreibung
IPv4Dieser Variablen-Typ unterstützt nur valide IPv4-Adressen.
Subnet maskDieser Variablen-Typ unterstützt nur valide Subnetzmasken.
[A-Z a-z]*Dieser Variablen-Typ unterstützt nur ASCII-Zeichen von A-Z und a-z.
User definedMit dieser Option können Sie einen eigenen regulären Ausdruck erstellen, um die Eingabe zu limitieren.

Passen Sie die folgenden Parameter an und klicken auf Speichern

  • Variablen Typ: Wählen Sie die Option Regulärer Ausdruck aus.
  • Name: Vergeben Sie einen aussagekräftigen Namen für die Variable (in diesem Beispiel IP).
  • Anzeigename: In diesem Beispiel wird zum besseren Verständnis zusätzlich ein Anzeigename hinterlegt, da im Namen kein Bindestrich verwendet werden darf. 
  • Regulärer Ausdruck: Wählen Sie im Dropdown-Menü die gewünschte Option aus (in diesem Beispiel IPv4).

Image Added

 


Neue Variable anlegen:

1. Wechseln Sie in das Menü Add-ins → Variablen und klicken auf Neue Variable.

Image Added

2. Passen Sie die folgenden Parameter an und klicken auf Speichern:

  • Name: Vergeben Sie einen aussagekräftigen Namen für die Variable (in diesem Beispiel wlanstate).
  • Variablen Typ: Wählen Sie im Dropdown-Menü einen Variablen Typ aus (in diesem Beispiel den im Abschnitt Neuen Variablen-Typ definieren erstellten Typ Switch).
  • Wert: Vergeben Sie einen Wert für die Variable oder wählen im Dropdown-Menü eine Option aus.

Image Added



Verwenden von Variablen:

Werte von Variablen können in dem Objekt context.vars verwendet werde:

/**
 * @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-Variablen:

System-Variablen verwalten spezifische Aspekte der Smart-Konfiguration.

  • Alle System-Variablen (außer der Variable UF_DEFAULT_IF) können in den Projektvorgaben angepasst werden.
  • System-Variablen können nicht durch Add-in Skripte modifiziert werden (Read-Only).
  • System-Variablen können nur in den Menüs Netze und Geräte verwendet werden.
  • System-Variablen können nur für Status-Anfragen verwendet werden (die Konfiguration wird ausgerollt, wenn eine System-Variable einen bestimmten Wert hat).

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 “Code will be executed, if variable is met.” eingefügt werden.

/**
 * @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.

     };

};

Verfügbare System-Variablen:

  • INITIAL_TEST_MODE_ENABLED:

    • Aktiviert einen Test-Modus von 300 Sekunden für den initialen Konfigurations-Rollout (im Standard aktiv).
    • Kann nach dem initialen Konfigurations-Rollout mit der Einstellung Testmodus nach initialem Konfigurations-Rollout in dem Menü Projektvorgaben → Inbetriebnahme von Geräten angepasst werden. 
  • PASSWORD:

    • Globales Haupt-Geräte-Passwort.
    • Kann unter Projektvorgaben → Basis angepasst werden.
  • UF_CLEAR_DEFAULT_CFG:

    • Deaktiviert die Standard-Schnittstellen einer Unified Firewall während des Konfigurations-Rollouts (im Standard deaktiviert).
    • Kann mit der Einstellung Default-Netze beim Konfigurations-Rollout auf LANCOM R&S®Unified Firewalls deaktivieren in dem Menü Projektvorgaben → Inbetriebnahme von Geräten angepasst werden.
  • UF_DEFAULT_IF:

    • Standard-Schnittstelle für den Netzwerk-Rollout per LANCOM Management Cloud.
    • Die Standard-Schnittstelle ist eth1 und kann ausschließlich per API geändert werden.
  • LMC_DOMAIN:

    • URL für private LMC-Instanzen.
  • UF_ETH0_NETWORKS ... UF_ETH10_NETWORKS:

    • Zuweisung der ETH-Ports von Unified Firewalls zu den Netzwerken.
  • VPN_IDENTITY_SEPARATOR:

    • Zeichen, welches für die automatische Erstelleung von VPN-Verbindungen verwendet wird (z.B. mit dem Standard-Zeichen "@": ALL@HQ__).


Werte

Schreiben

Sie können die Konfiguration, welche an ein Gerät gesendet werden soll, per config.setScalarByOid modifizieren:

/**
 * @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");
};

Konfigurations-Änderungen, welche per config.setScalarByOidvorgenommen wurden, sind in der Konfigurations-Vorschau sichtbar, da diese in der Konfiguration hinzugefüht werden, bevor diese an das Gerät gesendet wird.

Dies kann auch per config.addScriptLine erreicht werden:

/**
 * @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"');
};

Konfigurations-Änderungen, die per config.addScriptLinevorgenommen 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.


Lesen

Informationen können von einem Gerät über die Funktion config.getScalarByOid ausgelesen werden:

/**
 * @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");
};

Es gibt kein Äquivalent für config.addScriptLine, um Daten vom Gerät zu lesen.


Englisch

...

Deutsch

Hier wird sämtlicher Inhalt des Dokuments in Deutsch eingefügt!

Englisch

Variables

To further extend the use of Add-

Ins

ins we have the possibility to use variables. These can be used as read-only values within Add-

In

in scripts.

A variable consists of

  • name
  • type
  • value

You can create and edit Add-ins in the menu Add-ins → Variables.

Image Added



Adding Variables:

A variable can be set

/overwritten on the following levels, with ascending order:
  • Location
  • Network
  • Device

For this, open the respective Variables view, and add the defined variables.

Defining a Variable Type

A variable is either of type string or can have a custom type.

To define a new type click on the Variable Types button. Image Removed

Next, click on Add new type.

Image Removed

Give the type a name (e.g. Switch), and add a number of selectable variable values, for example:

  • enabled -> on
  • disabled -> off

Click on Save to save your variable type.

Image Removed

Review your types, then close the dialog to return to the variables page.

Image Removed

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.

Image Removed

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 (***).

Image Removed

Click on the checkbox to save your variable definition.

Image Removed

Using variables

the following places and follows a hierarchy where the last one overrides the previous ones.

  • global
  • network
  • site
  • device


Global:

If a value is assigned to a variable, the variable is valid globally. The variable can then be used in an Add-in.


Networks:

1) Go to the menu Networks, select a network and click on Variables → Add Variables.

Image Added

2) Select the desired variable and assign it a value or select an action. Click Add afterwards.

Image Added


Sites:

1) Go to the menu Sites, select a site and click on Variables → Add variables.

Image Added

2) Select the desired variable and assign it a value or select an action. Click Add afterwards.

Image Added


Devices:

1) Go to the menu Devices, select a device and click on Variables → Add variables.

Image Added

2) Select the desired variable and assign it a value or select an action. Click Add afterwards.

Image Added



Defining a Variable Type

1) Go to the meu Add-ins and click on Variables.

Image Added

2) Click on Variable types.

Image Added

3) Click Add new type afterwards.

Image Added

4) There are two possible variable types (String selection and Regular expression).

String selection:

Modify the follwing parameters and click Save

  • Variable type: Select the option String selection.
  • Name: Enter a descriptive name for the variable (in this example Switch).
  • Name / Value: Enter one or multiple names and associated value(s) (in this example enable → on and disabled → off).

Image Added


Regular expression:

To limit the input for variables, also regular expressions are supported (Regex). 

The following options can be used for regular expressions:

Regular expressionDescription
IPv4Only a valid IP address is allowed for variables with that variable-type.
Subnet maskOnly 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 definedYou 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).

Image Added



Create a new Variable

1) Go to the menu Add-ins → Variables and click on New variable.

Image Added

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.

Image Added



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

Now, you can use your variable in the following way:

exports.main = function (config, context) {

     // access the variables value:
     if (context.vars.wlanState == "on") {
        context.setScalarByOid("1.2.1" /* /Setup/Name TODO: enable wlan interface here*/, 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.

Seiteneigenschaften