Skip to content

Commit

Permalink
Merge pull request #1 from uriwang/github_uricmdb
Browse files Browse the repository at this point in the history
GitHub uricmdb
  • Loading branch information
uriwang committed Apr 11, 2018
2 parents 0145b3f + 19cf833 commit 70c0db4
Show file tree
Hide file tree
Showing 37 changed files with 746 additions and 363 deletions.
4 changes: 4 additions & 0 deletions readme.md
Expand Up @@ -53,5 +53,9 @@
## Contributing
关于 bk-cmdb 分支管理、issue 以及 pr 规范,请阅读 [bk-cmdb Contributing Guide](docs/CONTRIBUTING.md)

## FAQ

https://github.com/Tencent/bk-cmdb/wiki/FAQ

## License
bk-cmdb 是基于 MIT 协议, 详细请参考 [LICENSE](LICENSE)
4 changes: 2 additions & 2 deletions resources/errors/common/default/common.json
Expand Up @@ -3,12 +3,12 @@
"1199001": "序列化JSON失败",
"1199002": "HTTP请求失败",
"1199003": "输入参数无效",
"1199004": "数据数据读取失败",
"1199004": "数据读取失败",
"1199005": "输入内容为空",
"1199006": "'%s' 数据参数校验不通过",
"1199007": "'%s' 必须为字符串类型",
"1199008": "'%s' 不可以被省略",
"1199009": "'%s' 参数必须是整形",
"1199009": "'%s' 参数必须是整型",
"1199010": "'%s' 未赋值",
"1199011": "'%s' 参数无效或不存在",
"1199012": "唯一性校验不通过",
Expand Down
11 changes: 11 additions & 0 deletions resources/errors/english/en/apiserver_v2.json
@@ -0,0 +1,11 @@
{
"1170001":"Business name must be 1-32 characters",
"1170002":"%s",
"1170003":"The length of the set name cannot exceed 24 bytes",
"1170004":"Each module ID must be a number",
"1170005":"Each set ID must be a number",
"1170006":"osType must be windows or linux",
"1170007":"Multi-module transfers cannot contain default module",

"":""
}
35 changes: 35 additions & 0 deletions resources/errors/english/en/common.json
@@ -0,0 +1,35 @@
{
"1199000": "Deserializing JSON data failed",
"1199001": "Serialized JSON failed",
"1199002": "HTTP request failed",
"1199003": "invalid input parameter",
"1199004": "Data read failed",
"1199005": "The input is empty",
"1199006": "'%s' data parameter verification does not pass",
"1199007": "'%s' must be a string type",
"1199008": "'%s' cannot be omitted",
"1199009": "'%s' parameters must be integral",
"1199010": "'%s' unassigned",
"1199011": "'%s' the parameter is invalid or does not exist",
"1199012": "uniqueness does not pass",
"1199013": "Failed to read Data field data",
"1199014": "Duplicate data",
"1199015": "Data out of bounds",
"1199016": "Field regular check failed",
"1199017": "Failed to query data",
"1199018": "New data failed",
"1199019": "No relevant data found",
"1199020": "Failed to update data",
"1199021": "Failed to delete data",
"1199022": "Dependent service [%s] did not start",
"1199024": "'%s' must be a string type",
"1199025": "'%s' must be boolean",
"1199026": "Configuration file missing [%s] configuration item",
"1199027": "'%s' authorization information query failed",
"1199028": "Field value check does not pass",
"1199029": "Function return value format problem",
"1199030": "HTTP POST parsing failed",
"1199031": "'%s' initialization failed",

"":""
}
10 changes: 10 additions & 0 deletions resources/errors/english/en/event_server.json
@@ -0,0 +1,10 @@
{
     "1103000": "Failed to create instance",
     "1103001": "Delete Instance Failed",
     "1103002": "Failed to update instance",
     "1103003": "Failed to query instance data",
     "1103004": "Failed to create model",
     "1103005": "Delete Model Failed",
     "1103006": "Update model failed",
     "1103007": "Query Model Failed"
}
21 changes: 21 additions & 0 deletions resources/errors/english/en/host_controller.json
@@ -0,0 +1,21 @@
{
"1106000": "Failed to query host instance",
"1106002": "Failed to add new host instance",
"1106003":"Query Host Snapshot Failed",
"1106004": "Failed to transfer host module",
"1106005":"Failed to delete the host default cluster module",
"1106006": "Failed to get host module relationship",
"1106007": "The original host module relationship failed to be deleted",
"1106008":"Failed to get host already bound to relational module",
"1106009": "Failed to transfer host from resource pool",
"1106010":"The host has already belonged to another business. Please refresh the page and reselect the host to be assigned",
"1106011": "The host belongs to a module other than the idle machine",
"1106012": "Failed to transfer host to resource pool",
"1106013": "Newly added user-defined configuration",
"1106014":"Query Host Collection Failed",
"1106015": "Failed to create a host collection",
"1106016":"Failed to modify host collection",
"1106017": "Failed to modify host collections",

"":""
}
21 changes: 21 additions & 0 deletions resources/errors/english/en/host_server.json
@@ -0,0 +1,21 @@
{
"1106000": "Failed to query host instance",
"1106002": "Failed to add new host instance",
"1106003":"Query Host Snapshot Failed",
"1106004": "Failed to transfer host module",
"1106005":"Failed to delete the host default cluster module",
"1106006": "Failed to get host module relationship",
"1106007": "The original host module relationship failed to be deleted",
"1106008":"Failed to get host already bound to relational module",
"1106009": "Failed to transfer host from resource pool",
"1106010":"The host has already belonged to another business. Please refresh the page and reselect the host to be assigned",
"1106011": "The host belongs to a module other than the idle machine",
"1106012": "Failed to transfer host to resource pool",
"1106013": "Newly added user-defined configuration",
"1106014":"Query Host Collection Failed",
"1106015": "Failed to create a host collection",
"1106016":"Failed to modify host collection",
"1106017": "Failed to modify host collections",

"":""
}
4 changes: 4 additions & 0 deletions resources/errors/english/en/migrate.json
@@ -0,0 +1,4 @@
{
"1105000":"Failed to migrate data",
"":""
}
11 changes: 11 additions & 0 deletions resources/errors/english/en/object_controller.json
@@ -0,0 +1,11 @@
{
"1102000": "Attribute grouping failed to store",
"1102001": "Delete Attribute Grouping Failed",
"1102002": "Query Attribute Grouping Failed",
"1102003": "Update Attribute Grouping Failed",
"1102004": "The new instance failed",
"1102005": "Failed to update instance",
"1102006": "Delete Instance Failed",
"1102007": "Query instance failed",
"": ""
}
6 changes: 6 additions & 0 deletions resources/errors/english/en/proc_controller.json
@@ -0,0 +1,6 @@
{
"1107001": "Remove process from module failed",
"1107002": "Failed to add process to module",
"1107003": "The query process failed",
"":""
}
11 changes: 11 additions & 0 deletions resources/errors/english/en/proc_server.json
@@ -0,0 +1,11 @@
{
    "1108001": "Query process details failed",
     "1108002": "Bind process model failed",
     "1108003": "Unlocking process model binding failed",
     "1108004": "Unlocking process model binding failed",
     "1108005": "The update process failed",
     "1108006": "The query process failed",
     "1108007": "Delete process failed",
     "1108008": "The creation process failed",
     "": ""
}
55 changes: 55 additions & 0 deletions resources/errors/english/en/topo_server.json
@@ -0,0 +1,55 @@
{
"1101000": "Failed to create instance",
"1101001": "Delete Instance Failed",
"1101002": "Failed to update instance",
"1101003": "Querying instance data failed",
"1101004": "Failed to create model",
"1101005": "Delete Model Failed",
"1101006": "Update model failed",
"1101007": "Query model failed",
"1101008": "Failed to create a set",
"1101009": "Delete set Failed",
"1101010": "Failed to update set information",
"1101011": "Failed to query set information",
"1101013": "Failed to create model",
"1101014": "Delete Model Failed",
"1101015": "Update model failed",
"1101016": "Query model failed",
"1101017": "Failed to create a model instance",
"1101018": "Failed to delete model properties",
"1101019": "Failed to update model properties",
"1101020": "Query Model Property Failed",
"1101021": "Failed to create a model classification",
"1101022": "Delete Model Classification Failed",
"1101023": "Update model classification failed",
"1101024": "Query model classification failed",
"1101025": "Failed to create model attribute grouping",
"1101026": "Failed to delete model attribute grouping",
"1101027": "Failed to update model attribute grouping",
"1101028": "Query Model Attribute Grouping Failed",
"1101029": "There is a model under the category, not allowed to delete",
"1101030": "Having a host under the target",
"1001031": "Delete Business Failure",
"1001032": "Update business failed",
"1001033": "Query service failure",
"1001034": "Failed to create business",
"1001035": "Prohibition of deleting the built-in model",
"1001037": "Failed to create a mainline",
"1001038": "Delete Mainline Failed",
"1001039": "Failed to query the main line",
"1001040": "Query Model Topology Failed",
"1001041": "Creating a User Group",
"1001042": "Delete User Group",
"1001043": "Update User Grouping",
"1001044": "Query User Grouping",
"1001045": "Update user group permissions",
"1001046": "Query User Group Permissions",
"1001047": "Query User Rights",
"1001048": "Create Role Rights",

"1101080": "The module does not exist, please refresh the page",
"":""

}


13 changes: 10 additions & 3 deletions src/common/definitions.go
@@ -1,15 +1,15 @@
/*
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

package common

const (
Expand Down Expand Up @@ -90,6 +90,13 @@ const (
BKInnerObjIDPlat = "plat"
)

// Revision
const (
RevisionEnterprise = "enterprise"
RevisionCommunity = "community"
RevisionOpensource = "opensource"
)

const (
// BKDBIN the db operator
BKDBIN = "$in"
Expand Down
9 changes: 3 additions & 6 deletions src/scene_server/admin_server/common/definitions.go
@@ -1,15 +1,15 @@
/*
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

package models

//common group
Expand All @@ -29,9 +29,6 @@ const (
//host group info

const (
HostTopology = "topo"
HostTopologyName = "拓扑"

HostAutoFields = "auto"
HostAutoFieldsName = "自动发现信息(需要安装agent)"
)
Expand Down
59 changes: 39 additions & 20 deletions src/scene_server/admin_server/migrate_service/ccapi.go
@@ -1,15 +1,15 @@
/*
* Tencent is pleased to support the open source community by making 蓝鲸 available.
* Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language governing permissions and
* either express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/

package ccapi

import (
Expand All @@ -20,6 +20,7 @@ import (
"configcenter/src/common/http/httpserver"
"configcenter/src/common/rdapi"
"configcenter/src/common/types"
"sync"
"time"
// migrateCommon "configcenter/src/scene_server/admin_server/common"
confCenter "configcenter/src/scene_server/admin_server/migrate_service/config"
Expand Down Expand Up @@ -80,21 +81,15 @@ func (ccAPI *CCAPIServer) Start() error {
errres := config["errors.res"]

// configure center
go func() {
err := ccAPI.cfCenter.Start(confDir, errres)
err := ccAPI.cfCenter.Start(confDir, errres)
if err != nil {
blog.Errorf("configure center module start failed!. err:%s", err.Error())
chErr <- err
}()
return err
}

//http server
ccAPI.initHttpServ()

go func() {
err := ccAPI.httpServ.ListenAndServe()
blog.Error("http listen and serve failed! err:%s", err.Error())
chErr <- err
}()

// load the errors resource
if errorres, ok := config["errors.res"]; ok {
if errif, err := errors.New(errorres); nil != err {
Expand All @@ -121,20 +116,44 @@ func (ccAPI *CCAPIServer) Start() error {
a.TopoAPI = rdapi.GetRdAddrSrvHandle(types.CC_MODULE_TOPO, a.AddrSrv)
a.ProcAPI = rdapi.GetRdAddrSrvHandle(types.CC_MODULE_PROC, a.AddrSrv)

go func() {
err := a.GetDataCli(config, "mongodb")
if err != nil {
blog.Error("connect mongodb error exit! err:%s", err.Error())
chErr <- err
}
}()
err = a.GetDataCli(config, "mongodb")
if err != nil {
blog.Error("connect mongodb error exit! err:%s", err.Error())
return err
}

go func() {
err := ccAPI.rd.Start()
blog.Errorf("rdiscover start failed! err:%s", err.Error())
chErr <- err
}()

waitfunc := func(f func() string, wg *sync.WaitGroup) {
for {
if f() != "" {
wg.Done()
return
}
time.Sleep(time.Millisecond * 500)
}
}
all := []string{
types.CC_MODULE_PROC,
types.CC_MODULE_TOPO,
}

wg := &sync.WaitGroup{}
for _, module := range all {
wg.Add(1)
go waitfunc(rdapi.GetRdAddrSrvHandle(module, a.AddrSrv), wg)
}

go func() {
wg.Wait()
err := ccAPI.httpServ.ListenAndServe()
blog.Error("http listen and serve failed! err:%s", err.Error())
chErr <- err
}()
select {
case err := <-chErr:
blog.Error("exit! err:%s", err.Error())
Expand Down

0 comments on commit 70c0db4

Please sign in to comment.