Added set/get/remove dispatcher hosts and profiles to console

This commit is contained in:
Tripon Alexandru-Ionut
2019-04-09 15:39:45 +03:00
committed by Dan Christian Bogos
parent d6399737f6
commit 64b5c62c49
11 changed files with 532 additions and 3 deletions

View File

@@ -42,7 +42,11 @@ func (apierV1 *ApierV1) GetDispatcherProfile(arg *utils.TenantID, reply *engine.
}
// GetDispatcherProfileIDs returns list of dispatcherProfile IDs registered for a tenant
func (apierV1 *ApierV1) GetDispatcherProfileIDs(tenant string, dPrfIDs *[]string) error {
func (apierV1 *ApierV1) GetDispatcherProfileIDs(tenantArg *utils.TenantArg, dPrfIDs *[]string) error {
if tenantArg.Tenant == "" {
return utils.NewErrMandatoryIeMissing(utils.Tenant)
}
tenant := tenantArg.Tenant
prfx := utils.DispatcherProfilePrefix + tenant + ":"
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
if err != nil {
@@ -127,7 +131,11 @@ func (apierV1 *ApierV1) GetDispatcherHost(arg *utils.TenantID, reply *engine.Dis
}
// GetDispatcherHostIDs returns list of dispatcherHost IDs registered for a tenant
func (apierV1 *ApierV1) GetDispatcherHostIDs(tenant string, dPrfIDs *[]string) error {
func (apierV1 *ApierV1) GetDispatcherHostIDs(tenantArg *utils.TenantArg, dPrfIDs *[]string) error {
if tenantArg.Tenant == "" {
return utils.NewErrMandatoryIeMissing(utils.Tenant)
}
tenant := tenantArg.Tenant
prfx := utils.DispatcherHostPrefix + tenant + ":"
keys, err := apierV1.DataManager.DataDB().GetKeysForPrefix(prfx)
if err != nil {

View File

@@ -150,7 +150,7 @@ func testDispatcherSGetDispatcherProfileIDs(t *testing.T) {
var result []string
expected := []string{"Dsp1"}
if err := dispatcherRPC.Call("ApierV1.GetDispatcherProfileIDs",
dispatcherProfile.Tenant, &result); err != nil {
utils.TenantArg{Tenant: dispatcherProfile.Tenant}, &result); err != nil {
t.Error(err)
} else if len(result) != len(expected) {
t.Errorf("Expecting : %+v, received: %+v", expected, result)

65
console/dispatcherhost.go Normal file
View File

@@ -0,0 +1,65 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetDispatcherHost{
name: "dispatcherhost",
rpcMethod: utils.ApierV1GetDispatcherHost,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetDispatcherHost struct {
name string
rpcMethod string
rpcParams *utils.TenantID
*CommandExecuter
}
func (self *CmdGetDispatcherHost) Name() string {
return self.name
}
func (self *CmdGetDispatcherHost) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetDispatcherHost) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantID)
}
return self.rpcParams
}
func (self *CmdGetDispatcherHost) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetDispatcherHost) RpcResult() interface{} {
var s engine.DispatcherHost
return &s
}

View File

@@ -0,0 +1,64 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetDispatcherHostIDs{
name: "dispatcherhost_ids",
rpcMethod: utils.ApierV1GetDispatcherHostIDs,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetDispatcherHostIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArg
*CommandExecuter
}
func (self *CmdGetDispatcherHostIDs) Name() string {
return self.name
}
func (self *CmdGetDispatcherHostIDs) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetDispatcherHostIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantArg)
}
return self.rpcParams
}
func (self *CmdGetDispatcherHostIDs) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetDispatcherHostIDs) RpcResult() interface{} {
var s []string
return &s
}

View File

@@ -0,0 +1,64 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdRemoveDispatcherHost{
name: "dispatcherhost_remove",
rpcMethod: utils.ApierV1RemoveDispatcherHost,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdRemoveDispatcherHost struct {
name string
rpcMethod string
rpcParams *utils.TenantIDWrapper
*CommandExecuter
}
func (self *CmdRemoveDispatcherHost) Name() string {
return self.name
}
func (self *CmdRemoveDispatcherHost) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdRemoveDispatcherHost) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantIDWrapper)
}
return self.rpcParams
}
func (self *CmdRemoveDispatcherHost) PostprocessRpcParams() error {
return nil
}
func (self *CmdRemoveDispatcherHost) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -0,0 +1,65 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdSetDispatcherHost{
name: "dispatcherhost_set",
rpcMethod: utils.ApierV1SetDispatcherHost,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSetDispatcherHost struct {
name string
rpcMethod string
rpcParams *v1.DispatcherHostWrapper
*CommandExecuter
}
func (self *CmdSetDispatcherHost) Name() string {
return self.name
}
func (self *CmdSetDispatcherHost) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetDispatcherHost) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(v1.DispatcherHostWrapper)
}
return self.rpcParams
}
func (self *CmdSetDispatcherHost) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetDispatcherHost) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -0,0 +1,65 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetDispatcherProfile{
name: "dispatcherprofile",
rpcMethod: utils.ApierV1GetDispatcherProfile,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetDispatcherProfile struct {
name string
rpcMethod string
rpcParams *utils.TenantID
*CommandExecuter
}
func (self *CmdGetDispatcherProfile) Name() string {
return self.name
}
func (self *CmdGetDispatcherProfile) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetDispatcherProfile) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantID)
}
return self.rpcParams
}
func (self *CmdGetDispatcherProfile) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetDispatcherProfile) RpcResult() interface{} {
var s engine.DispatcherProfile
return &s
}

View File

@@ -0,0 +1,64 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdGetDispatcherProfileIDs{
name: "dispatcherprofile_ids",
rpcMethod: utils.ApierV1GetDispatcherProfileIDs,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdGetDispatcherProfileIDs struct {
name string
rpcMethod string
rpcParams *utils.TenantArg
*CommandExecuter
}
func (self *CmdGetDispatcherProfileIDs) Name() string {
return self.name
}
func (self *CmdGetDispatcherProfileIDs) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdGetDispatcherProfileIDs) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantArg)
}
return self.rpcParams
}
func (self *CmdGetDispatcherProfileIDs) PostprocessRpcParams() error {
return nil
}
func (self *CmdGetDispatcherProfileIDs) RpcResult() interface{} {
var s []string
return &s
}

View File

@@ -0,0 +1,64 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdRemoveDispatcherProfile{
name: "dispatcherprofile_remove",
rpcMethod: utils.ApierV1RemoveDispatcherProfile,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdRemoveDispatcherProfile struct {
name string
rpcMethod string
rpcParams *utils.TenantIDWrapper
*CommandExecuter
}
func (self *CmdRemoveDispatcherProfile) Name() string {
return self.name
}
func (self *CmdRemoveDispatcherProfile) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdRemoveDispatcherProfile) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(utils.TenantIDWrapper)
}
return self.rpcParams
}
func (self *CmdRemoveDispatcherProfile) PostprocessRpcParams() error {
return nil
}
func (self *CmdRemoveDispatcherProfile) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -0,0 +1,65 @@
/*
Real-time Online/Offline Charging System (OCS) for Telecom & ISP environments
Copyright (C) ITsysCOM GmbH
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package console
import (
v1 "github.com/cgrates/cgrates/apier/v1"
"github.com/cgrates/cgrates/utils"
)
func init() {
c := &CmdSetDispatcherProfile{
name: "dispatcherprofile_set",
rpcMethod: utils.ApierV1SetDispatcherProfile,
}
commands[c.Name()] = c
c.CommandExecuter = &CommandExecuter{c}
}
// Commander implementation
type CmdSetDispatcherProfile struct {
name string
rpcMethod string
rpcParams *v1.DispatcherWithCache
*CommandExecuter
}
func (self *CmdSetDispatcherProfile) Name() string {
return self.name
}
func (self *CmdSetDispatcherProfile) RpcMethod() string {
return self.rpcMethod
}
func (self *CmdSetDispatcherProfile) RpcParams(reset bool) interface{} {
if reset || self.rpcParams == nil {
self.rpcParams = new(v1.DispatcherWithCache)
}
return self.rpcParams
}
func (self *CmdSetDispatcherProfile) PostprocessRpcParams() error {
return nil
}
func (self *CmdSetDispatcherProfile) RpcResult() interface{} {
var s string
return &s
}

View File

@@ -708,7 +708,12 @@ const (
ApierV1Ping = "ApierV1.Ping"
ApierV1SetDispatcherProfile = "ApierV1.SetDispatcherProfile"
ApierV1GetDispatcherProfile = "ApierV1.GetDispatcherProfile"
ApierV1GetDispatcherProfileIDs = "ApierV1.GetDispatcherProfileIDs"
ApierV1RemoveDispatcherProfile = "ApierV1.RemoveDispatcherProfile"
ApierV1SetDispatcherHost = "ApierV1.SetDispatcherHost"
ApierV1GetDispatcherHost = "ApierV1.GetDispatcherHost"
ApierV1GetDispatcherHostIDs = "ApierV1.GetDispatcherHostIDs"
ApierV1RemoveDispatcherHost = "ApierV1.RemoveDispatcherHost"
ApierV1GetResource = "ApierV1.GetResource"
ApierV1GetEventCost = "ApierV1.GetEventCost"
ApierV1LoadTariffPlanFromFolder = "ApierV1.LoadTariffPlanFromFolder"