Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepy
# Cirrus Link provides these scripts as examples only, they are not supported or guaranteed to meet any particular functionality. Cirrus Link cannot provide any assistance to modify these scripts to meet a particular need.

# Create new server set
serverProps = {}
serverProps["Name"] = "Server Set 1"
serverProps["Description"] = ""
serverProps["PrimaryHostEnabled"] = True
serverProps["PrimaryHostId"] = "MyPrimaryHost"
system.cirruslink.engine.createConfig("Sets", serverProps)

# Find server set Id
savedSets = system.cirruslink.engine.readConfig("Sets")
for config in savedSets:
	if config ["Name"] == "Server Set 1":
		serverSetId = config["id"]
 
# Create new server
serverProps = {}
serverProps["Name"] = "My Server"
serverProps["Enabled"] = True
serverProps["Url"] = "tcp://192.0.2.1:1883"
serverProps["ServerSetId"] = serverSetId
serverProps["Username"] = "MyUserName"
serverProps["Password"] = "MyPassword"
system.cirruslink.engine.createConfig("Servers", serverProps)

# Find server Id
savedServers = system.cirruslink.engine.readConfig("Servers")
for config in savedServers:
	if config ["Name"] == "My Server":
		serverId = config["id"] # Read server configuration

# Update server properties using MergeOverwrite
serverProps = {}
serverProps["KeepAlive"] = "60"
serverProps["ServerSetId"] = serverSetId
system.cirruslink.engine.createConfigupdateConfig("Servers", serverId, "MergeOverwrite", serverProps)

# Delete server
system.cirruslink.engine.deleteConfig("Servers", serverId)

...