// 2020 Rackspace, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // 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 limitations // under the License. package ecm import ( "fmt" "github.rackspace.com/DCM/discover/cmdb" "github.rackspace.com/DCM/discover/log" "github.rackspace.com/DCM/discover/network" "github.rackspace.com/gorax/passkey" ) const ( // DCX is a reference for the New function to specify that we // are going to implement the EM, NA, and IPAdmin toolsets. DCXTools ECM = iota ) type ( // ECM represents the types of systems where we will store system Environment Configuration Management elements // for the record we discovered data on. This will typically be something like Environment Manager, // Network-Architect, and IPAdmin, but could be the CMDB itself or any other system that implements // the CM interface. ECM int // Updater interface is the implementation of methods used to update a system of record with the // data discovered in the data Record. Updater implements the Update method. Updater interface { Build(records []cmdb.Model, switchCtx map[string]network.Switch) (Config, error) Update(config Config, modify bool) log.Collector } ) // New function will take a credential to create a discover client func New(key *passkey.Client, system ECM) (Updater, error) { // Perform a switch on the type of system that is passed in to initialize the // correct implementation of the CMDB system. switch system { case DCXTools: // If the system is the DCX tooling, initialize the clients we'll need, // then return the DCX implementation back as the Updater interface return dcxECM(key) default: return nil, fmt.Errorf("%d system is not supported", system) } }