This commit is contained in:
crusader 2018-06-14 19:30:46 +09:00
parent f6bb993458
commit 0b21cff78b
3 changed files with 77 additions and 14 deletions

View File

@ -16,8 +16,8 @@ public class CentralInfraHostDaemonService implements InfraHostDaemonService {
@Autowired @Autowired
InfraHostDaemonDAO infraHostDaemonDAO; InfraHostDaemonDAO infraHostDaemonDAO;
public InfraHostDaemon regist(InfraHostDaemon infraOSDaemon) throws OverflowException { public InfraHostDaemon regist(InfraHostDaemon infraHostDaemon) throws OverflowException {
return this.infraHostDaemonDAO.save(infraOSDaemon); return this.infraHostDaemonDAO.save(infraHostDaemon);
} }
public InfraHostDaemon read(Long id) throws OverflowException { public InfraHostDaemon read(Long id) throws OverflowException {

View File

@ -14,7 +14,10 @@ import com.loafle.overflow.model.discovery.Port;
import com.loafle.overflow.model.discovery.Zone; import com.loafle.overflow.model.discovery.Zone;
import com.loafle.overflow.model.infra.Infra; import com.loafle.overflow.model.infra.Infra;
import com.loafle.overflow.model.infra.InfraHost; import com.loafle.overflow.model.infra.InfraHost;
import com.loafle.overflow.model.infra.InfraHostApplication;
import com.loafle.overflow.model.infra.InfraHostDaemon;
import com.loafle.overflow.model.infra.InfraHostIP; import com.loafle.overflow.model.infra.InfraHostIP;
import com.loafle.overflow.model.infra.InfraHostMachine;
import com.loafle.overflow.model.infra.InfraHostOS; import com.loafle.overflow.model.infra.InfraHostOS;
import com.loafle.overflow.model.infra.InfraHostPort; import com.loafle.overflow.model.infra.InfraHostPort;
import com.loafle.overflow.model.infra.InfraZone; import com.loafle.overflow.model.infra.InfraZone;
@ -56,12 +59,24 @@ public class CentralInfraService implements InfraService {
@Autowired @Autowired
InfraServiceDAO infraServiceDAO; InfraServiceDAO infraServiceDAO;
@Autowired
CentralInfraHostMachineService infraHostMachineService;
@Autowired
CentralInfraHostOSService infraHostOSService;
@Autowired @Autowired
CentralInfraHostIPService infraHostIPService; CentralInfraHostIPService infraHostIPService;
@Autowired @Autowired
CentralInfraHostPortService infraHostPortService; CentralInfraHostPortService infraHostPortService;
@Autowired
CentralInfraHostApplicationService infraHostApplicationService;
@Autowired
CentralInfraHostDaemonService infraHostDaemonService;
@Autowired @Autowired
CentralMetaCryptoTypeService metaCryptoTypeService; CentralMetaCryptoTypeService metaCryptoTypeService;
@ -153,9 +168,13 @@ public class CentralInfraService implements InfraService {
infraZone.setProbe(probe); infraZone.setProbe(probe);
infraHost.setInfraZone(infraZone); infraHost.setInfraZone(infraZone);
infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
infraHost.setInfraHostIPs(Arrays.asList(infraHostIP));
return this.infraHostDAO.save(infraHost); infraHost = this.infraHostDAO.save(infraHost);
infraHostIP.setInfraHost(infraHost);
this.infraHostIPService.regist(infraHostIP);
return infraHost;
} }
@Override @Override
@ -229,6 +248,7 @@ public class CentralInfraService implements InfraService {
infraHostIP.getMetaIPType().getName())); infraHostIP.getMetaIPType().getName()));
} }
infraHostPort.setInfraHost(infraHost);
infraHostPort = this.infraHostPortService.regist(infraHostPort); infraHostPort = this.infraHostPortService.regist(infraHostPort);
com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService(); com.loafle.overflow.model.infra.InfraService infraService = new com.loafle.overflow.model.infra.InfraService();
@ -288,22 +308,65 @@ public class CentralInfraService implements InfraService {
infraHost.setInfraZone(new InfraZone(infraZoneID)); infraHost.setInfraZone(new InfraZone(infraZoneID));
infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to()); infraHost.setMetaInfraType(MetaInfraType.Enum.HOST.to());
infraHost = this.infraHostDAO.save(infraHost);
InfraHostMachine infraHostMachine = oriInfraHost.getInfraHostMachine();
if (null != infraHostMachine) {
infraHostMachine.setInfraHost(infraHost);
this.infraHostMachineService.regist(infraHostMachine);
}
InfraHostOS infraHostOS = oriInfraHost.getInfraHostOS(); InfraHostOS infraHostOS = oriInfraHost.getInfraHostOS();
if (null != infraHostOS) { if (null != infraHostOS) {
// MetaTargetHostType metaTargetHostType = // MetaTargetHostType metaTargetHostType =
// this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS); // this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS);
infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
infraHost.setInfraHostOS(infraHostOS); infraHost = this.infraHostDAO.save(infraHost);
infraHostOS.setInfraHost(infraHost);
this.infraHostOSService.regist(infraHostOS);
} else { } else {
infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to()); infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
infraHost = this.infraHostDAO.save(infraHost);
} }
infraHost.setInfraHostIPs(oriInfraHost.getInfraHostIPs()); if (null != oriInfraHost.getInfraHostIPs()) {
infraHost.setInfraHostPorts(oriInfraHost.getInfraHostPorts()); for (InfraHostIP infraHostIP : oriInfraHost.getInfraHostIPs()) {
infraHost.setInfraHostApplications(oriInfraHost.getInfraHostApplications()); infraHostIP = this.infraHostIPService.validate(infraHostIP);
infraHost.setInfraHostDaemons(oriInfraHost.getInfraHostDaemons()); infraHostIP.setInfraHost(infraHost);
return this.infraHostDAO.save(infraHost); this.infraHostIPService.regist(infraHostIP);
}
} else {
throw new OverflowException("InfraHostIPs is not valid");
}
if (null != oriInfraHost.getInfraHostPorts()) {
for (InfraHostPort infraHostPort : oriInfraHost.getInfraHostPorts()) {
infraHostPort = this.infraHostPortService.validate(infraHostPort);
infraHostPort.setInfraHost(infraHost);
this.infraHostPortService.regist(infraHostPort);
}
}
if (null != oriInfraHost.getInfraHostApplications()) {
for (InfraHostApplication infraHostApplication : oriInfraHost.getInfraHostApplications()) {
infraHostApplication.setInfraHost(infraHost);
this.infraHostApplicationService.regist(infraHostApplication);
}
}
if (null != oriInfraHost.getInfraHostDaemons()) {
for (InfraHostDaemon infraHostDaemon : oriInfraHost.getInfraHostDaemons()) {
infraHostDaemon.setInfraHost(infraHost);
this.infraHostDaemonService.regist(infraHostDaemon);
}
}
return infraHost;
} }
@Override @Override

View File

@ -52,16 +52,16 @@ public class NoAuthProbeServiceTest {
@Test @Test
public void acceptNoAuthProbe() throws Exception { public void acceptNoAuthProbe() throws Exception {
List<NoAuthProbe> noAuthProbes = this.noAuthProbeService.acceptNoAuthProbe((long) 1, "192.168.1.0/24"); NoAuthProbe noAuthProbe = this.noAuthProbeService.acceptNoAuthProbe((long) 1, "192.168.1.0/24");
Assert.assertNotEquals(noAuthProbes.size(), 0); Assert.assertNotNull(noAuthProbe);
} }
@Test @Test
public void denyNoauthProbe() throws Exception { public void denyNoauthProbe() throws Exception {
List<NoAuthProbe> noAuthProbes = this.noAuthProbeService.denyNoauthProbe((long) 1); NoAuthProbe noAuthProbe = this.noAuthProbeService.denyNoauthProbe((long) 1);
Assert.assertNotEquals(noAuthProbes.size(), 0); Assert.assertNotNull(noAuthProbe);
} }
@Test @Test