Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5a3f23bec9
@ -79,8 +79,8 @@ func NewInfraService() *InfraService {
|
||||
return &InfraService{}
|
||||
}
|
||||
|
||||
func (is *InfraService) Save(infra *Infra) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infra", "save", infra, "com.loafle.overflow.module.infra.model.Infra")
|
||||
func (is *InfraService) Regist(infra *Infra) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infra", "save", infra, utils.MODEL_INFRA)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -89,8 +89,8 @@ func (is *InfraService) Save(infra *Infra) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveMachine(i *InfraMachine) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infraMachine", "save", i, "com.loafle.overflow.module.infra.model.InfraMachine")
|
||||
func (is *InfraService) RegistMachine(i *InfraMachine) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infraMachine", "save", i, utils.MODEL_INFRA_MACHINE)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -99,8 +99,8 @@ func (is *InfraService) SaveMachine(i *InfraMachine) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveHost(i *InfraHost) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infraHost", "save", i, "com.loafle.overflow.module.infra.model.InfraHost")
|
||||
func (is *InfraService) RegistHost(i *InfraHost) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("infraHost", "save", i, utils.MODEL_INFRA_HOST)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -109,8 +109,8 @@ func (is *InfraService) SaveHost(i *InfraHost) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveOS(i *InfraOS) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOS", "save", i, "com.loafle.overflow.module.infra.model.InfraOS")
|
||||
func (is *InfraService) RegistOS(i *InfraOS) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOS", "save", i, utils.MODEL_INFRA_OS)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -119,8 +119,8 @@ func (is *InfraService) SaveOS(i *InfraOS) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveOSApplication(i *InfraOSApplication) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSApplication", "save", i, "com.loafle.overflow.module.infra.model.InfraOSApplication")
|
||||
func (is *InfraService) RegistOSApplication(i *InfraOSApplication) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSApplication", "save", i, utils.MODEL_INFRA_OS_APPLICATION)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -129,8 +129,8 @@ func (is *InfraService) SaveOSApplication(i *InfraOSApplication) (string, error)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveOSDaemon(i *InfraOSDaemon) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSDaemon", "save", i, "com.loafle.overflow.module.infra.model.InfraOSDaemon")
|
||||
func (is *InfraService) RegistOSDaemon(i *InfraOSDaemon) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSDaemon", "save", i, utils.MODEL_INFRA_OS_DAEMON)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -139,8 +139,8 @@ func (is *InfraService) SaveOSDaemon(i *InfraOSDaemon) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveOSPort(i *InfraOSPort) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSPort", "save", i, "com.loafle.overflow.module.infra.model.InfraOSPort")
|
||||
func (is *InfraService) RegistOSPort(i *InfraOSPort) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraOSPort", "save", i, utils.MODEL_INFRA_OS_PORT)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -149,8 +149,8 @@ func (is *InfraService) SaveOSPort(i *InfraOSPort) (string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (is *InfraService) SaveService(i *InfraService) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraService", "save", i, "com.loafle.overflow.module.infra.model.InfraService")
|
||||
func (is *InfraService) RegistService(i *InfraService) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("InfraService", "save", i, utils.MODEL_INFRA_SERVICE)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -161,7 +161,7 @@ func (is *InfraService) SaveService(i *InfraService) (string, error) {
|
||||
|
||||
func (is *InfraService) Read(id string) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("infra", "findOne", id, "java.lang.Long")
|
||||
out, err := utils.InvokeDBByModel("infra", "findOne", id, utils.MODEL_LONG)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
@ -172,7 +172,7 @@ func (is *InfraService) Read(id string) (string, error) {
|
||||
|
||||
func (is *InfraService) ReadChild(infraType, id string) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel(infraType, "findOne", id, "java.lang.Long")
|
||||
out, err := utils.InvokeDBByModel(infraType, "findOne", id, utils.MODEL_LONG)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
36
proxy/infra/infra_service_test.go
Normal file
36
proxy/infra/infra_service_test.go
Normal file
@ -0,0 +1,36 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/meta"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestInfraRegist(t *testing.T) {
|
||||
is := InfraService{}
|
||||
|
||||
infraType := meta.MetaInfraType{
|
||||
Id: json.Number("1"),
|
||||
}
|
||||
|
||||
infra := &Infra{
|
||||
MetaInfraType: infraType,
|
||||
ChildId: json.Number("0"),
|
||||
CreateDate: timestamp.Now(),
|
||||
}
|
||||
res, err := is.Regist(infra)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(res)
|
||||
}
|
||||
|
||||
func TestInfraList(t *testing.T) {
|
||||
is := InfraService{}
|
||||
res, err := is.Read("1")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(res)
|
||||
}
|
@ -3,132 +3,46 @@ package target
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
"git.loafle.net/overflow/overflow_service/proxy"
|
||||
|
||||
"fmt"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/infra"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/session"
|
||||
)
|
||||
|
||||
type Target struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Ip int64 `json:"ip,omitempty"`
|
||||
Port int `json:"port,omitempty"`
|
||||
TargetType string `json:"targetType,omitempty"`
|
||||
VendorName string `json:"vendorName,omitempty"`
|
||||
Kinds string `json:"kinds,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
PortType string `json:"portType,omitempty"`
|
||||
Member *member.Member `json:"member,omitempty"`
|
||||
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
Probe *probe.Probe `json:"probe,omitempty"`
|
||||
Infra *infra.Infra `json:"infra,omitempty"`
|
||||
}
|
||||
|
||||
type TargetService struct {
|
||||
|
||||
}
|
||||
|
||||
func NewTargetService() *TargetService {
|
||||
return &TargetService{}
|
||||
}
|
||||
|
||||
func (t *TargetService)GetModel() interface{} {
|
||||
func (t *TargetService) GetModel() interface{} {
|
||||
return &Target{}
|
||||
}
|
||||
|
||||
func (t *TargetService)List(tm *Target) (string, error) {
|
||||
func (t *TargetService) ReadAllByProbe(p *probe.Probe) (string, error) {
|
||||
|
||||
tm.Member.Id = session.GetSessionMember().Id
|
||||
|
||||
bytes, err := json.Marshal(tm)
|
||||
out, err := utils.InvokeDBByModel("target", "findAllByProbe", p, utils.MODEL_PROBE)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
m := make(map[string]string)
|
||||
m["com.loafle.overflow.target.model.Target"] = string(bytes)
|
||||
|
||||
out, err := proxy.InvokeDB("target", "findAll", m)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
return out, err;
|
||||
return out, err
|
||||
}
|
||||
|
||||
func (t *TargetService)Create(tm *Target) (string,error) {
|
||||
|
||||
//bytes, err := json.Marshal(tm)
|
||||
//
|
||||
//if err != nil {
|
||||
// return ""
|
||||
//}
|
||||
//
|
||||
//m := make(map[string]string)
|
||||
//m["com.loafle.overflow.target.model.Target"] = string(bytes)
|
||||
//
|
||||
//out := proxy.InvokeDB("target", "create", m)
|
||||
|
||||
out, err := utils.InvokeDB("target", "create", tm)
|
||||
func (t *TargetService) Regist(target *Target) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("target", "save", target, utils.MODEL_TARGET)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
return out, nil
|
||||
|
||||
}
|
||||
|
||||
func (t *TargetService)CreateAll(tmlist *[]*Target) (string,error) {
|
||||
|
||||
|
||||
|
||||
outlist := make([]string, 0)
|
||||
for _, ttt := range *tmlist {
|
||||
|
||||
ttt.Member = session.GetSessionMember()
|
||||
out,err := t.Create(ttt)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
outlist = append(outlist, out)
|
||||
}
|
||||
|
||||
bytes,err := json.Marshal(outlist)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return string(bytes), nil
|
||||
|
||||
}
|
||||
|
||||
func (t *TargetService)CreateListTT(tmlist *[]*Target) (string, error) {
|
||||
bytes, err := json.Marshal(tmlist)
|
||||
|
||||
if err != nil {
|
||||
return "",err
|
||||
}
|
||||
|
||||
m := make(map[string]string)
|
||||
m["java.util.List"] = string(bytes)
|
||||
|
||||
fmt.Println(string(bytes))
|
||||
out, err := proxy.InvokeDB("target", "createAll", m)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
//
|
||||
//
|
||||
return out, nil;
|
||||
//return ""
|
||||
}
|
@ -1,114 +1,42 @@
|
||||
package target
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/infra"
|
||||
"git.loafle.net/overflow/overflow_service/proxy/probe"
|
||||
"testing"
|
||||
//"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
|
||||
|
||||
"git.loafle.net/overflow/overflow_service/proxy/member"
|
||||
|
||||
)
|
||||
|
||||
func TestCreateTarget(t *testing.T) {
|
||||
func TestTargetRegist(t *testing.T) {
|
||||
ts := NewTargetService()
|
||||
|
||||
p := &probe.Probe{}
|
||||
p.Id = json.Number("1")
|
||||
i := &infra.Infra{}
|
||||
i.Id = json.Number("1")
|
||||
|
||||
tt := Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL0000000",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
target := &Target{
|
||||
CreateDate: timestamp.Now(),
|
||||
Probe: p,
|
||||
Infra: i,
|
||||
}
|
||||
|
||||
ts := NewTargetService()
|
||||
|
||||
|
||||
ts.Create(&tt)
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
func TestFindAll(t *testing.T) {
|
||||
tt := Target{
|
||||
Member:&member.Member{Id:"1"},
|
||||
res, err := ts.Regist(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ts := NewTargetService()
|
||||
|
||||
|
||||
str := ts.List(&tt)
|
||||
t.Log(str)
|
||||
}
|
||||
|
||||
|
||||
func TestCreateAll(t *testing.T) {
|
||||
|
||||
tl := make([]*Target, 0)
|
||||
|
||||
tl = append(tl, &Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL2222",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
})
|
||||
|
||||
tl = append(tl, &Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL3333",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
})
|
||||
|
||||
tl = append(tl, &Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL4444",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
})
|
||||
|
||||
tl = append(tl, &Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL5555",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
})
|
||||
|
||||
tl = append(tl, &Target{
|
||||
Ip:3232235882,
|
||||
Port:5432,
|
||||
TargetType:"DATABASE",
|
||||
Kinds:"PostgreSQL6666",
|
||||
Version:"9.5.0",
|
||||
VendorName:"PostgreSQL 9.5.0",
|
||||
PortType:"TCP",
|
||||
Member:&member.Member{Id:"1"},
|
||||
})
|
||||
|
||||
|
||||
ts := NewTargetService()
|
||||
|
||||
|
||||
ts.CreateListTT(&tl)
|
||||
t.Log(res)
|
||||
|
||||
}
|
||||
|
||||
func TestTargetList(t *testing.T) {
|
||||
ts := NewTargetService()
|
||||
p := &probe.Probe{
|
||||
Id: "1",
|
||||
}
|
||||
res, err := ts.ReadAllByProbe(p)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(res)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user