006.Insert wake and ping configs for the rest of machines

master
Tudor Stanciu 2022-01-21 01:07:15 +02:00
parent e37c5203ba
commit bf4dcf54e2
1 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,18 @@
declare @server_performer_id int, @wake_action_id int, @ping_action_id int
select @server_performer_id = PerformerId from PowerActionPerformer where PerformerCode = 'NETWORK_RESURRECTOR_SERVER'
select @wake_action_id = PowerActionId from PowerAction where PowerActionCode = 'WAKE'
select @ping_action_id = PowerActionId from PowerAction where PowerActionCode = 'PING'
-- insert WAKE configuration for all machine that don't have it
insert into PowerActionConfiguration (MachineId, PowerActionId, PerformerId)
select m.MachineId, @wake_action_id, @server_performer_id
from Machine m
left join PowerActionConfiguration c on m.MachineId = c.MachineId and c.PowerActionId = @wake_action_id
where c.ConfigurationId is null
-- insert PING configuration for all machine that don't have it
insert into PowerActionConfiguration (MachineId, PowerActionId, PerformerId)
select m.MachineId, @ping_action_id, @server_performer_id
from Machine m
left join PowerActionConfiguration c on m.MachineId = c.MachineId and c.PowerActionId = @ping_action_id
where c.ConfigurationId is null