ing
This commit is contained in:
		
							parent
							
								
									f6bb993458
								
							
						
					
					
						commit
						0b21cff78b
					
				@ -16,8 +16,8 @@ public class CentralInfraHostDaemonService implements InfraHostDaemonService {
 | 
			
		||||
  @Autowired
 | 
			
		||||
  InfraHostDaemonDAO infraHostDaemonDAO;
 | 
			
		||||
 | 
			
		||||
  public InfraHostDaemon regist(InfraHostDaemon infraOSDaemon) throws OverflowException {
 | 
			
		||||
    return this.infraHostDaemonDAO.save(infraOSDaemon);
 | 
			
		||||
  public InfraHostDaemon regist(InfraHostDaemon infraHostDaemon) throws OverflowException {
 | 
			
		||||
    return this.infraHostDaemonDAO.save(infraHostDaemon);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public InfraHostDaemon read(Long id) throws OverflowException {
 | 
			
		||||
 | 
			
		||||
@ -14,7 +14,10 @@ import com.loafle.overflow.model.discovery.Port;
 | 
			
		||||
import com.loafle.overflow.model.discovery.Zone;
 | 
			
		||||
import com.loafle.overflow.model.infra.Infra;
 | 
			
		||||
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.InfraHostMachine;
 | 
			
		||||
import com.loafle.overflow.model.infra.InfraHostOS;
 | 
			
		||||
import com.loafle.overflow.model.infra.InfraHostPort;
 | 
			
		||||
import com.loafle.overflow.model.infra.InfraZone;
 | 
			
		||||
@ -56,12 +59,24 @@ public class CentralInfraService implements InfraService {
 | 
			
		||||
  @Autowired
 | 
			
		||||
  InfraServiceDAO infraServiceDAO;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostMachineService infraHostMachineService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostOSService infraHostOSService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostIPService infraHostIPService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostPortService infraHostPortService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostApplicationService infraHostApplicationService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralInfraHostDaemonService infraHostDaemonService;
 | 
			
		||||
 | 
			
		||||
  @Autowired
 | 
			
		||||
  CentralMetaCryptoTypeService metaCryptoTypeService;
 | 
			
		||||
 | 
			
		||||
@ -153,9 +168,13 @@ public class CentralInfraService implements InfraService {
 | 
			
		||||
    infraZone.setProbe(probe);
 | 
			
		||||
    infraHost.setInfraZone(infraZone);
 | 
			
		||||
    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
 | 
			
		||||
@ -229,6 +248,7 @@ public class CentralInfraService implements InfraService {
 | 
			
		||||
          infraHostIP.getMetaIPType().getName()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    infraHostPort.setInfraHost(infraHost);
 | 
			
		||||
    infraHostPort = this.infraHostPortService.regist(infraHostPort);
 | 
			
		||||
 | 
			
		||||
    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.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();
 | 
			
		||||
    if (null != infraHostOS) {
 | 
			
		||||
      // MetaTargetHostType metaTargetHostType =
 | 
			
		||||
      // this.metaTargetHostTypeService.readByInfraHostOS(infraHostOS);
 | 
			
		||||
      infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
 | 
			
		||||
      infraHost.setInfraHostOS(infraHostOS);
 | 
			
		||||
      infraHost = this.infraHostDAO.save(infraHost);
 | 
			
		||||
 | 
			
		||||
      infraHostOS.setInfraHost(infraHost);
 | 
			
		||||
      this.infraHostOSService.regist(infraHostOS);
 | 
			
		||||
    } else {
 | 
			
		||||
      infraHost.setMetaTargetHostType(MetaTargetHostType.Enum.UNKNOWN.to());
 | 
			
		||||
      infraHost = this.infraHostDAO.save(infraHost);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    infraHost.setInfraHostIPs(oriInfraHost.getInfraHostIPs());
 | 
			
		||||
    infraHost.setInfraHostPorts(oriInfraHost.getInfraHostPorts());
 | 
			
		||||
    infraHost.setInfraHostApplications(oriInfraHost.getInfraHostApplications());
 | 
			
		||||
    infraHost.setInfraHostDaemons(oriInfraHost.getInfraHostDaemons());
 | 
			
		||||
    if (null != oriInfraHost.getInfraHostIPs()) {
 | 
			
		||||
      for (InfraHostIP infraHostIP : oriInfraHost.getInfraHostIPs()) {
 | 
			
		||||
        infraHostIP = this.infraHostIPService.validate(infraHostIP);
 | 
			
		||||
        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
 | 
			
		||||
 | 
			
		||||
@ -52,16 +52,16 @@ public class NoAuthProbeServiceTest {
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  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
 | 
			
		||||
  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
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user