PowerActionConfiguration
parent
43dddcf59f
commit
b01587eef8
|
@ -0,0 +1,93 @@
|
|||
if not exists (select top 1 1 from sys.objects where name = 'PowerAction' and type = 'U')
|
||||
begin
|
||||
create table PowerAction
|
||||
(
|
||||
PowerActionId int identity(1, 1) constraint PK_PowerAction primary key,
|
||||
PowerActionCode varchar(30),
|
||||
PowerActionName varchar(130)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from PowerAction)
|
||||
begin
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'WAKE', 'Wake machine'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'PING', 'Ping machine'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'SHUTDOWN', 'Shutdown machine'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'RESTART', 'Restart machine'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'SLEEP', 'Sleep machine'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'LOGOUT', 'Logout machine user'
|
||||
insert into PowerAction (PowerActionCode, PowerActionName)
|
||||
select 'LOCK', 'Lock machine user screen'
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from sys.objects where name = 'PowerActionPerformer' and type = 'U')
|
||||
begin
|
||||
create table PowerActionPerformer
|
||||
(
|
||||
PerformerId int identity(1, 1) constraint PK_PowerActionPerformer primary key,
|
||||
PerformerCode varchar(50),
|
||||
PerformerName varchar(130)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from PowerActionPerformer)
|
||||
begin
|
||||
insert into PowerActionPerformer (PerformerCode, PerformerName)
|
||||
select 'NETWORK_RESURRECTOR_SERVER', 'Network resurrector server' union
|
||||
select 'NETWORK_RESURRECTOR_AGENT', 'Network resurrector agent'
|
||||
end
|
||||
|
||||
if not exists (select top 1 1 from sys.objects where name = 'MachineAgent' and type = 'U')
|
||||
begin
|
||||
create table MachineAgent
|
||||
(
|
||||
MachineId int constraint PK_MachineAgent primary key,
|
||||
AgentPort int not null,
|
||||
constraint FK_MachineAgent_Machine foreign key (MachineId) references Machine(MachineId)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from sys.objects where name = 'PowerActionConfiguration' and type = 'U')
|
||||
begin
|
||||
create table PowerActionConfiguration
|
||||
(
|
||||
ConfigurationId int identity(1, 1) constraint PK_PowerActionConfiguration primary key,
|
||||
MachineId int constraint FK_PowerActionConfiguration_Machine foreign key references Machine(MachineId),
|
||||
PowerActionId int constraint FK_PowerActionConfigurationn_PowerAction foreign key references PowerAction(PowerActionId),
|
||||
PerformerId int constraint FK_PowerActionConfiguration_PowerActionPerformer foreign key references PowerActionPerformer(PerformerId)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
declare @orion_machine_id int, @server_performer_id int, @agent_performer_id int
|
||||
select @orion_machine_id = MachineId from Machine where MachineName = '***REMOVED***'
|
||||
select @server_performer_id = PerformerId from PowerActionPerformer where PerformerCode = 'NETWORK_RESURRECTOR_SERVER'
|
||||
select @agent_performer_id = PerformerId from PowerActionPerformer where PerformerCode = 'NETWORK_RESURRECTOR_AGENT'
|
||||
|
||||
if not exists (select top 1 1 from MachineAgent)
|
||||
begin
|
||||
insert into MachineAgent (MachineId, AgentPort)
|
||||
select @orion_machine_id, ***REMOVED***
|
||||
end
|
||||
|
||||
if not exists (select top 1 1 from PowerActionConfiguration)
|
||||
begin
|
||||
insert into PowerActionConfiguration (MachineId, PowerActionId, PerformerId)
|
||||
select @orion_machine_id,
|
||||
PowerActionId,
|
||||
case when PowerActionCode in ('WAKE', 'PING') then @server_performer_id
|
||||
else @agent_performer_id
|
||||
end
|
||||
from PowerAction
|
||||
end
|
||||
go
|
|
@ -1,32 +0,0 @@
|
|||
if not exists (select top 1 1 from sys.objects where name = 'ShutdownType' and type = 'U')
|
||||
begin
|
||||
create table ShutdownType
|
||||
(
|
||||
ShutdownTypeId int identity(1, 1) constraint PK_ShutdownType primary key,
|
||||
ShutdownTypeCode varchar(50),
|
||||
ShutdownTypeName varchar(130)
|
||||
)
|
||||
end
|
||||
go
|
||||
|
||||
if not exists (select top 1 1 from ShutdownType)
|
||||
begin
|
||||
insert into ShutdownType (ShutdownTypeCode, ShutdownTypeName)
|
||||
select 'NETWORK_RESURRECTOR_SERVER', 'Network resurrector server' union
|
||||
select 'NETWORK_RESURRECTOR_AGENT', 'Network resurrector agent'
|
||||
end
|
||||
|
||||
if not exists (select top 1 1 from sys.objects where name = 'ShutdownConfiguration' and type = 'U')
|
||||
begin
|
||||
create table ShutdownConfiguration
|
||||
(
|
||||
ConfigurationId int identity(1, 1) constraint PK_ShutdownConfiguration primary key,
|
||||
MachineId int constraint FK_ShutdownConfiguration_Machine foreign key references Machine(MachineId),
|
||||
ShutdownTypeId int constraint FK_ShutdownConfiguration_ShutdownType foreign key references ShutdownType(ShutdownTypeId),
|
||||
AgentPort int,
|
||||
[Default] bit,
|
||||
[Disabled] bit constraint DF_ShutdownConfiguration_Disabled default 0,
|
||||
[Description] varchar(2000)
|
||||
)
|
||||
end
|
||||
go
|
Loading…
Reference in New Issue