From d7d47acf1ba0414dfa9ca8c7158bc4aec00ce35c Mon Sep 17 00:00:00 2001 From: insanity Date: Tue, 5 Jun 2018 18:04:00 +0900 Subject: [PATCH] test --- .../service/CentralInfraHostService.java | 2 ++ .../target/service/CentralTargetService.java | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java index 277f1bf..e2c2d35 100644 --- a/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java +++ b/src/main/java/com/loafle/overflow/central/module/infra/service/CentralInfraHostService.java @@ -1,5 +1,6 @@ package com.loafle.overflow.central.module.infra.service; + import com.loafle.overflow.central.module.infra.dao.InfraHostDAO; import com.loafle.overflow.core.exception.OverflowException; import com.loafle.overflow.model.infra.InfraHost; @@ -27,4 +28,5 @@ public class CentralInfraHostService implements InfraHostService { public InfraHost readByIp(String ip) throws OverflowException { return this.infraHostDAO.findByIpv4(ip); } + } diff --git a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java index 954a875..7c4acc4 100644 --- a/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java +++ b/src/main/java/com/loafle/overflow/central/module/target/service/CentralTargetService.java @@ -1,8 +1,14 @@ package com.loafle.overflow.central.module.target.service; +import java.util.List; + +import com.loafle.overflow.central.module.infra.service.CentralInfraHostService; import com.loafle.overflow.central.module.probe.service.CentralProbeService; import com.loafle.overflow.central.module.target.dao.TargetDAO; import com.loafle.overflow.core.exception.OverflowException; +import com.loafle.overflow.model.discovery.Host; +import com.loafle.overflow.model.infra.InfraHost; +import com.loafle.overflow.model.meta.MetaInfraType; import com.loafle.overflow.model.probe.Probe; import com.loafle.overflow.model.target.Target; import com.loafle.overflow.service.central.target.TargetService; @@ -21,6 +27,8 @@ public class CentralTargetService implements TargetService { private TargetDAO targetDAO; @Autowired private CentralProbeService probeService; + @Autowired + private CentralInfraHostService infraHostService; @Transactional public Target regist(Target target, Probe probe) throws OverflowException { @@ -66,4 +74,26 @@ public class CentralTargetService implements TargetService { } return this.targetDAO.save(t); } + + @Transactional + public void registDiscoveredTargets(Long probeId, List hosts, List services) { + /* + 해당 host의 mac에 해당하는 infraHost가 이미 존재하는지 검사 + infraHost가 없다면 create + infraHost가 있다면 update + infraHost.getTarget()이 있어도 무조건 새로운 target으로 연결 + + + for(Host host : hosts) { + Target target = new Target(); + + MetaInfraType infraType = new MetaInfraType(); + infraType.setId(2); + InfraHost infraHost = new InfraHost(); + infraHost.setInfraType(infraType); + infraHost.setProbe(new Probe(probeId)); + infraHost.setTarget(target); + } + */ + } }