remove InfraHost in Probe

This commit is contained in:
snoop 2017-08-21 14:46:54 +09:00
parent a422808cf2
commit 51aa8e3c6e
7 changed files with 89 additions and 21 deletions

View File

@ -28,7 +28,7 @@ public class Probe {
private String cidr; private String cidr;
private Date authorizeDate; private Date authorizeDate;
private Member authorizeMember; private Member authorizeMember;
private InfraHost host; // private InfraHost host;
@Id @Id
@GeneratedValue(strategy= GenerationType.IDENTITY) @GeneratedValue(strategy= GenerationType.IDENTITY)
@ -155,14 +155,14 @@ public class Probe {
public void setAuthorizeMember(Member authorizeMember) { public void setAuthorizeMember(Member authorizeMember) {
this.authorizeMember = authorizeMember; this.authorizeMember = authorizeMember;
} }
//
@ManyToOne // @ManyToOne
@JoinColumn(name = "HOST_ID", nullable = false) // @JoinColumn(name = "HOST_ID", nullable = false)
public InfraHost getHost() { // public InfraHost getHost() {
return host; // return host;
} // }
//
public void setHost(InfraHost host) { // public void setHost(InfraHost host) {
this.host = host; // this.host = host;
} // }
} }

View File

@ -397,3 +397,39 @@ INSERT INTO public.domain_member (create_date,domain_id,member_id) VALUES (
INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES ( INSERT INTO public.api_key (api_key,create_date,domain_id) VALUES (
'52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1); '52abd6fd57e511e7ac52080027658d13','2017-06-26 13:02:28.347',1);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_MACHINE','2017-08-21 12:59:10.244',1,NULL,NULL);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_OS','2017-08-21 13:05:24.883',3,NULL,NULL);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_HOST','2017-08-21 14:20:01.830',2,NULL,NULL);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_SERVICE','2017-08-21 14:24:26.525',7,NULL,NULL);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_OS_APPLICATION','2017-08-21 14:27:19.474',4,NULL,NULL);
INSERT INTO public.infra (infra_type,create_date,type_id,probe_id,target_id) VALUES (
'INFRA_OS_DAEMON','2017-08-21 14:28:48.761',5,NULL,NULL);
INSERT INTO public.infra_machine (meta,id) VALUES (
'i am a infra machine',1);
INSERT INTO public.infra_os (meta,id,machine_id,vendor_id) VALUES (
'',2,1,26);
INSERT INTO public.infra_host (ip,mac,id,os_id) VALUES (
3232235980,8796753988883,3,2);
INSERT INTO public.infra_service (port,port_type,tls_type,id,host_id,vendor_id) VALUES (
80,'TCP',false,4,3,45);
INSERT INTO public.infra_os_application ("name",id,os_id) VALUES (
'Apache',5,2);
INSERT INTO public.infra_os_daemon ("name",id,os_id) VALUES (
'Apache',6,2);

View File

@ -3,6 +3,8 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraHost; import com.loafle.overflow.module.infra.model.InfraHost;
import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
@ -25,7 +27,7 @@ public class InfraHostServiceTest {
private InfraHostService infraHostService; private InfraHostService infraHostService;
@Test @Test
@Ignore // @Ignore
public void regist() throws Exception { public void regist() throws Exception {
InfraHost infraHost = new InfraHost(); InfraHost infraHost = new InfraHost();
@ -34,9 +36,16 @@ public class InfraHostServiceTest {
infraHost.setIp(3232235980L); infraHost.setIp(3232235980L);
InfraOS infraOS = new InfraOS(); InfraOS infraOS = new InfraOS();
infraOS.setId(1); infraOS.setId(2);
infraHost.setOs(infraOS);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(2);
infraHost.setInfraType(metaInfraType);
// infraHost.setOs(infraOS);
this.infraHostService.regist(infraHost); this.infraHostService.regist(infraHost);

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.infra.model.InfraOSApplication; import com.loafle.overflow.module.infra.model.InfraOSApplication;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
@ -24,7 +25,7 @@ public class InfraOSApplicationServiceTest {
@Autowired @Autowired
private InfraOSApplicationService infraOSApplicationService; private InfraOSApplicationService infraOSApplicationService;
@Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
InfraOSApplication infraOSApplication = new InfraOSApplication(); InfraOSApplication infraOSApplication = new InfraOSApplication();
@ -32,10 +33,14 @@ public class InfraOSApplicationServiceTest {
infraOSApplication.setName("Apache"); infraOSApplication.setName("Apache");
InfraOS infraOS = new InfraOS(); InfraOS infraOS = new InfraOS();
infraOS.setId(1); infraOS.setId(2);
infraOSApplication.setOs(infraOS); infraOSApplication.setOs(infraOS);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(4);
infraOSApplication.setInfraType(metaInfraType);
this.infraOSApplicationService.regist(infraOSApplication); this.infraOSApplicationService.regist(infraOSApplication);

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.infra.model.InfraOSDaemon; import com.loafle.overflow.module.infra.model.InfraOSDaemon;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.junit.Assert; import org.junit.Assert;
@ -24,7 +25,7 @@ public class InfraOSDaemonServiceTest {
@Autowired @Autowired
private InfraOSDaemonService infraOSDaemonService; private InfraOSDaemonService infraOSDaemonService;
@Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -32,10 +33,15 @@ public class InfraOSDaemonServiceTest {
infraOSDaemon.setName("Apache"); infraOSDaemon.setName("Apache");
InfraOS infraOS = new InfraOS(); InfraOS infraOS = new InfraOS();
infraOS.setId(1); infraOS.setId(2);
infraOSDaemon.setOs(infraOS); infraOSDaemon.setOs(infraOS);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(5);
infraOSDaemon.setInfraType(metaInfraType);
this.infraOSDaemonService.regist(infraOSDaemon); this.infraOSDaemonService.regist(infraOSDaemon);
Assert.assertNotEquals(infraOSDaemon.getId(), 0); Assert.assertNotEquals(infraOSDaemon.getId(), 0);

View File

@ -2,6 +2,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraOS; import com.loafle.overflow.module.infra.model.InfraOS;
import com.loafle.overflow.module.infra.model.InfraOSPort; import com.loafle.overflow.module.infra.model.InfraOSPort;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -22,7 +23,7 @@ public class InfraOSPortServiceTest {
@Autowired @Autowired
private InfraOSPortService infraOSPortService; private InfraOSPortService infraOSPortService;
@Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -33,6 +34,11 @@ public class InfraOSPortServiceTest {
InfraOS infraOS = new InfraOS(); InfraOS infraOS = new InfraOS();
infraOS.setId(1); infraOS.setId(1);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(2);
infraOSPort.setInfraType(metaInfraType);
infraOSPort.setOs(infraOS); infraOSPort.setOs(infraOS);
// FIXME::vendor??? // FIXME::vendor???

View File

@ -3,6 +3,7 @@ package com.loafle.overflow.module.infra.service;
import com.loafle.overflow.module.infra.model.InfraHost; import com.loafle.overflow.module.infra.model.InfraHost;
import com.loafle.overflow.module.infra.model.InfraService; import com.loafle.overflow.module.infra.model.InfraService;
import com.loafle.overflow.module.meta.model.MetaInfraType;
import com.loafle.overflow.module.meta.model.MetaInfraVendor; import com.loafle.overflow.module.meta.model.MetaInfraVendor;
import com.loafle.overflow.spring.AppConfigTest; import com.loafle.overflow.spring.AppConfigTest;
import org.junit.Assert; import org.junit.Assert;
@ -25,7 +26,7 @@ public class InfraServiceServiceTest {
@Autowired @Autowired
private InfraServiceService infraServiceService; private InfraServiceService infraServiceService;
@Ignore // @Ignore
@Test @Test
public void regist() throws Exception { public void regist() throws Exception {
@ -35,7 +36,7 @@ public class InfraServiceServiceTest {
infraService.setPortType("TCP"); infraService.setPortType("TCP");
InfraHost infraHost = new InfraHost(); InfraHost infraHost = new InfraHost();
infraHost.setId(1); infraHost.setId(3);
infraService.setHost(infraHost); infraService.setHost(infraHost);
infraService.setTlsType(false); infraService.setTlsType(false);
@ -45,6 +46,11 @@ public class InfraServiceServiceTest {
infraService.setVendor(metaInfraVendor); infraService.setVendor(metaInfraVendor);
MetaInfraType metaInfraType = new MetaInfraType();
metaInfraType.setId(7);
infraService.setInfraType(metaInfraType);
this.infraServiceService.regist(infraService); this.infraServiceService.regist(infraService);
Assert.assertNotEquals(infraService.getId(), 0); Assert.assertNotEquals(infraService.getId(), 0);