discovery target end

This commit is contained in:
snoop 2017-06-27 19:35:41 +09:00
parent 1e3fc868a7
commit 840198b925
2 changed files with 76 additions and 44 deletions

View File

@ -8,6 +8,8 @@ import (
"strconv"
"git.loafle.net/overflow/discovery/discovery/types"
"git.loafle.net/overflow/overflow_service/proxy"
"git.loafle.net/overflow/overflow_service/proxy/utils"
)
type TargetInfo struct {
@ -151,10 +153,10 @@ func registInfraPort(port *types.DiscoveryPort, io *infra.InfraOS, p *probe.Prob
return nil, err
}
err = RegistTarget(port.Target, iip, p)
if err != nil {
return nil, err
}
//err = RegistTarget(port.Target, iip, p)
//if err != nil {
// return nil, err
//}
return &ip, nil
}
@ -205,50 +207,77 @@ func registInfraService(ih *infra.InfraHost, port *types.DiscoveryPort, service
//FIXME: Discovery Result
func (t *TargetService) RegistTarget(ti *TargetInfo) (string, error) {
//serviceTarget
m := make(map[string]string)
for _, host := range *ti.Hosts {
im, err := registInfraMachine(host, ti.Probe)
hBy, err := json.Marshal(ti.Hosts)
if err != nil {
return "", err
}
io, err := registInfraOS(im, host.Os)
pBy, err := json.Marshal(ti.Probe)
if err != nil {
return "", err
}
ih, err := registInfraHost(host, io, ti.Probe)
m[utils.MODEL_PROBE] = string(pBy)
hostListStr := utils.MODEL_LIST
hostListStr += "|"
hostListStr += utils.MODEL_HOST
m[hostListStr] = string(hBy)
out, err := proxy.InvokeDB("serviceTarget", "saveAllTarget", m)
if err != nil {
return "", err
return "",err
}
for _, port := range host.Ports {
_, err := registInfraPort(port, io, ti.Probe)
//for _, host := range *ti.Hosts {
//
// im, err := registInfraMachine(host, ti.Probe)
//
// if err != nil {
// return "", err
// }
//
// io, err := registInfraOS(im, host.Os)
//
// if err != nil {
// return "", err
// }
//
// ih, err := registInfraHost(host, io, ti.Probe)
//
// if err != nil {
// return "", err
// }
//
// for _, port := range host.Ports {
//
// _, err := registInfraPort(port, io, ti.Probe)
//
// if err != nil {
// return "", err
// }
//
// for _, service := range port.Services {
//
// _, err := registInfraService(ih, port, service, ti.Probe)
//
// if err != nil {
// return "", err
// }
// }
//
// }
//
//}
if err != nil {
return "", err
}
for _, service := range port.Services {
_, err := registInfraService(ih, port, service, ti.Probe)
if err != nil {
return "", err
}
}
}
}
return "", nil
return out, nil
}

View File

@ -19,6 +19,9 @@ const (
MODEL_SENSOR = "com.loafle.overflow.module.sensor.model.Sensor"
MODEL_SENSOR_ITEM = "com.loafle.overflow.module.sensor.model.SensorItem"
MODEL_HOST = "com.loafle.overflow.module.discovery.model.Host"
MODEL_STRING = "java.lang.String"
MODEL_LONG = "java.lang.Long"
MODEL_LIST = "java.util.List"
)