You've already forked akpaevj-executor-scripts
mirror of
https://github.com/akpaevj/executor-scripts.git
synced 2025-07-17 07:12:23 +02:00
s
This commit is contained in:
@ -6,31 +6,24 @@
|
||||
#required Xml.sbsl
|
||||
|
||||
@Global
|
||||
method NeedUpdate(
|
||||
PlatformVersion: String,
|
||||
method NeedUpdateConfiguration(
|
||||
Server: String,
|
||||
Infobase: String,
|
||||
User: String,
|
||||
Password: String,
|
||||
RequestedName: String,
|
||||
RequestedVersion: String): Boolean
|
||||
val ConfigurationInfo = GetConfigurationInfo(PlatformVersion, Server, Infobase, User, Password)
|
||||
|
||||
if ConfigurationInfo.Name != RequestedName
|
||||
throw new IllegalStateException("Requested configuration name is different from the target one")
|
||||
;
|
||||
|
||||
val VersionIsUpper = V8.VersionIsUpper(ConfigurationInfo.Version, RequestedVersion)
|
||||
return VersionIsUpper
|
||||
RequestedVersion: String,
|
||||
PlatformVersion = ""): Boolean
|
||||
val ConfigurationInfo = GetConfigurationInfo(Server, Infobase, User, Password, PlatformVersion)
|
||||
return V8.VersionIsUpper(ConfigurationInfo.Version, RequestedVersion)
|
||||
;
|
||||
|
||||
@Global
|
||||
method GetConfigurationInfo(
|
||||
PlatformVersion: String,
|
||||
Server: String,
|
||||
Infobase: String,
|
||||
User: String,
|
||||
Password: String): ConfigInfo?
|
||||
Password: String,
|
||||
PlatformVersion = ""): ConfigInfo?
|
||||
val SshAgentBaseDir = Files.CreateTempDirectory("", True)
|
||||
val SshAgent = StartSshAgent(PlatformVersion, Server, Infobase, SshAgentBaseDir.Path)
|
||||
|
||||
@ -72,13 +65,13 @@ method GetConfigurationInfo(
|
||||
|
||||
@Global
|
||||
method UpdateConfiguration(
|
||||
PlatformVersion: String,
|
||||
Server: String,
|
||||
Infobase: String,
|
||||
User: String,
|
||||
Password: String,
|
||||
AccessCode: String,
|
||||
CfuPath: String): Number
|
||||
CfuPath: String,
|
||||
PlatformVersion = ""): Number
|
||||
val Platform = V8.GetInstalledPlatform(PlatformVersion)
|
||||
|
||||
val OutFile = Files.CreateTempFile()
|
||||
@ -102,14 +95,14 @@ method UpdateConfiguration(
|
||||
|
||||
@Global
|
||||
method UpdateExtension(
|
||||
PlatformVersion: String,
|
||||
Server: String,
|
||||
Infobase: String,
|
||||
User: String,
|
||||
Password: String,
|
||||
AccessCode: String,
|
||||
ExtensionName: String,
|
||||
ExtensionPath: String): Number
|
||||
ExtensionPath: String,
|
||||
PlatformVersion = ""): Number
|
||||
val Platform = V8.GetInstalledPlatform(PlatformVersion)
|
||||
|
||||
val OutFile = Files.CreateTempFile()
|
||||
|
67
Common/Log.sbsl
Normal file
67
Common/Log.sbsl
Normal file
@ -0,0 +1,67 @@
|
||||
@Global
|
||||
enum LogLevel
|
||||
Trace,
|
||||
Debug,
|
||||
Information,
|
||||
Warning,
|
||||
Error,
|
||||
Critical,
|
||||
None
|
||||
;
|
||||
|
||||
@Global
|
||||
method t(Message: String)
|
||||
Log(LogLevel.Trace, Message)
|
||||
;
|
||||
|
||||
@Global
|
||||
method d(Message: String)
|
||||
Log(LogLevel.Debug, Message)
|
||||
;
|
||||
|
||||
@Global
|
||||
method i(Message: String)
|
||||
Log(LogLevel.Information, Message)
|
||||
;
|
||||
|
||||
@Global
|
||||
method w(Message: String)
|
||||
Log(LogLevel.Warning, Message)
|
||||
;
|
||||
|
||||
@Global
|
||||
method e(Message: String)
|
||||
Log(LogLevel.Error, Message)
|
||||
;
|
||||
|
||||
@Global
|
||||
method c(Message: String)
|
||||
Log(LogLevel.Critical, Message)
|
||||
;
|
||||
|
||||
method Log(Level: LogLevel, Message: String)
|
||||
var LevelString = ""
|
||||
|
||||
case Level
|
||||
when LogLevel.Trace
|
||||
LevelString = "TRACE"
|
||||
when LogLevel.Debug
|
||||
LevelString = "DEBUG"
|
||||
when LogLevel.Information
|
||||
LevelString = "INFO"
|
||||
when LogLevel.Warning
|
||||
LevelString = "WARN"
|
||||
when LogLevel.Error
|
||||
LevelString = "ERROR"
|
||||
when LogLevel.Critical
|
||||
LevelString = "CRIT"
|
||||
;
|
||||
|
||||
val Content = "${DateTime.Now()} - %LevelString - %Message"
|
||||
|
||||
if Level.Index >= LogLevel.Error.Index
|
||||
Console.WriteError(Content)
|
||||
else
|
||||
Console.Write(Content)
|
||||
;
|
||||
;
|
@ -40,7 +40,7 @@ method BlockConnections(
|
||||
AccessCode: String,
|
||||
RasAddress = "localhost",
|
||||
RasPort = 1545)
|
||||
use Administration = new V8ServerAdministration(RasAddress, RasPort)
|
||||
use Administration = new V8ServerAdministration(RasAddress, RasPort, 10s)
|
||||
Administration.Authenticate()
|
||||
|
||||
val Cluster = Administration.GetClusters().FirstOrDefault()
|
||||
@ -66,8 +66,7 @@ method BlockConnections(
|
||||
method CloseConnection(Connection: V8Connection)
|
||||
try
|
||||
Connection.Disconnect()
|
||||
catch Exception: unknown
|
||||
|
||||
finally
|
||||
;
|
||||
;
|
||||
|
||||
@ -78,7 +77,7 @@ method UnblockConnections(
|
||||
Password: String,
|
||||
RasAddress = "localhost",
|
||||
RasPort = 1545)
|
||||
use Administration = new V8ServerAdministration(RasAddress, RasPort)
|
||||
use Administration = new V8ServerAdministration(RasAddress, RasPort, 10s)
|
||||
Administration.Authenticate()
|
||||
|
||||
val Cluster = Administration.GetClusters().FirstOrDefault()
|
||||
|
@ -140,4 +140,9 @@ structure Class
|
||||
|
||||
return QResult.Get("Data") as Bytes
|
||||
;
|
||||
;
|
||||
|
||||
@Global
|
||||
method NewInstance(Connection: SqlConnection): Class
|
||||
return new Class(Connection)
|
||||
;
|
44
UpdateConfiguration.sbsl
Normal file
44
UpdateConfiguration.sbsl
Normal file
@ -0,0 +1,44 @@
|
||||
#required Common/Log.sbsl
|
||||
#required Common/V8Database.sbsl
|
||||
#required Common/Sql.sbsl
|
||||
#required Common/V8.sbsl
|
||||
#required Common/Path.sbsl
|
||||
#required Common/BatchMode.sbsl
|
||||
#required Common/Ras.sbsl
|
||||
|
||||
method Script(
|
||||
Server: String,
|
||||
Infobase: String,
|
||||
User: String,
|
||||
Password: String,
|
||||
SqlUser: String,
|
||||
SqlPassword: String,
|
||||
RequiredVersion: String,
|
||||
TemplatesPath: String,
|
||||
AccessCode: String,
|
||||
PlatformVersion: String = "")
|
||||
use Connection = Sql.BuildConnection(Server, Infobase, SqlUser, SqlPassword)
|
||||
val Database = V8Database.NewInstance(Connection)
|
||||
val ConfigInfo = Database.GetConfigInfo()
|
||||
|
||||
if V8.VersionIsUpper(ConfigInfo.Version, RequiredVersion)
|
||||
val CfuPath = Path.Join(Path.Join(TemplatesPath, RequiredVersion.Replace(".", "_")), "1cv8.cfu")
|
||||
|
||||
if Path.Exists(CfuPath)
|
||||
Log.i("Using CFU path: $CfuPath")
|
||||
else
|
||||
throw new IllegalStateException("Couldn't find CFU file of required version $RequiredVersion by path: %CfuPath")
|
||||
;
|
||||
|
||||
Log.i("Blocking connections")
|
||||
Ras.BlockConnections(Infobase, User, Password, AccessCode)
|
||||
|
||||
Log.i("Updating configuration (%Server/%Infobase)")
|
||||
BatchMode.UpdateConfiguration(Server, Infobase, User, Password, AccessCode, CfuPath, PlatformVersion)
|
||||
|
||||
Log.i("Unblocking connections")
|
||||
Ras.UnblockConnections(Infobase, User, Password, AccessCode)
|
||||
else
|
||||
Log.i("It doesn't need to update configuration (Current: ${ConfigInfo.Version}, Required: %RequiredVersion)")
|
||||
;
|
||||
;
|
Reference in New Issue
Block a user