Skip to content

Commit

Permalink
Add more documentation and update install for changes in EQM 7.3+ (#6)
Browse files Browse the repository at this point in the history
fix update #5
  • Loading branch information
pokornyIt authored Oct 3, 2023
1 parent cfab778 commit 840ed99
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
Binary file modified CUCM_User_import_into_QM.pdf
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ System support configuration file in JSON or YAML format. Options are same in bo
"dbServer": "pm028.pm.zoomint.com",
"dbPort": 5432,
"dbUser": "axluser",
"dbPassword": "a4lUs3r."
"dbPassword": "a4lUs3r.",
"javaXTerm": "/opt/zqm-axl/jmxterm-1.0.1-uber.jar",
"javaFlush": "/opt/zqm-axl/flush_sc_cache.txt",
"newApi": false
},
"log": {
"level": "TRACE",
Expand Down
3 changes: 2 additions & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"dbUser": "axluser",
"dbPassword": "a4lUs3r.",
"javaXTerm": "/opt/zqm-axl/jmxterm-1.0.1-uber.jar",
"javaFlush": "/opt/zqm-axl/flush_sc_cache.txt"
"javaFlush": "/opt/zqm-axl/flush_sc_cache.txt",
"newApi": false
},
"log": {
"level": "INFO",
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ zqm:
dbPassword: a4lUs3r.
javaXTerm: '/opt/zqm-axl/jmxterm-1.0.1-uber.jar'
javaFlush: '/opt/zqm-axl/flush_sc_cache.txt'
newApi: false
log:
level: INFO
fileName: '/opt/callrec/logs/zqm-axl-importer.log'
Expand Down
42 changes: 32 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

const (
applicationName = "ZQM AXL Importer 2.2.1" // application name
applicationName = "ZQM AXL Importer 2.3.0" // application name
letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" // map for random string
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
Expand Down Expand Up @@ -157,15 +157,37 @@ func refreshCache() {
log.WithField("process", "Clear cache").Trace("not clean cache configured")
return
}
log.WithField("process", "Clear cache").Trace("start run clean tomcat cache")
cmd := exec.Command("java", "-jar", config.Zqm.JavaXTerm, "java", "--url", "localhost:8765", "-i", config.Zqm.JavaFlush)
out, err := cmd.CombinedOutput()
if err != nil {
log.WithFields(log.Fields{"process": "Clear cache", "error": err.Error()}).Errorf("cache clean command ends with error %s", err)
return
}
if out != nil {
log.WithFields(log.Fields{"process": "Clear cache", "output": fmt.Sprintf(string(out))}).Debugf("return for command")
if config.Zqm.NewApi {
log.WithField("process", "Clear cache").Trace("start run clean tomcat cache from API")
cmd := exec.Command("curl", "http://localhost:8080/qm/flush-ibatis-cache")
cmd2 := exec.Command("curl", "http://localhost:8080/qm/flush-role-rights-chache")
out, err := cmd.CombinedOutput()
if err != nil {
log.WithFields(log.Fields{"process": "Clear cache", "error": err.Error()}).Errorf("Ibats cache clean command ends with error %s", err)
return
}
if out != nil {
log.WithFields(log.Fields{"process": "Clear cache", "output": fmt.Sprintf(string(out))}).Debugf("return for command %s", cmd.String())
}
out, err = cmd2.CombinedOutput()
if err != nil {
log.WithFields(log.Fields{"process": "Clear cache", "error": err.Error()}).Errorf("role rights cache clean command ends with error %s", err)
return
}
if out != nil {
log.WithFields(log.Fields{"process": "Clear cache", "output": fmt.Sprintf(string(out))}).Debugf("return for command %s", cmd2.String())
}
} else {
log.WithField("process", "Clear cache").Trace("start run clean tomcat cache")
cmd := exec.Command("java", "-jar", config.Zqm.JavaXTerm, "java", "--url", "localhost:8765", "-i", config.Zqm.JavaFlush)
out, err := cmd.CombinedOutput()
if err != nil {
log.WithFields(log.Fields{"process": "Clear cache", "error": err.Error()}).Errorf("cache clean command ends with error %s", err)
return
}
if out != nil {
log.WithFields(log.Fields{"process": "Clear cache", "output": fmt.Sprintf(string(out))}).Debugf("return for command")
}
}
log.WithFields(log.Fields{"process": "Clear cache"}).Info("success clear cache")
}
Expand Down
13 changes: 8 additions & 5 deletions parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"gopkg.in/alecthomas/kingpin.v2"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"path"
"regexp"
Expand Down Expand Up @@ -55,6 +54,7 @@ type ConfigZqm struct {
DbPassword string `json:"dbPassword" yaml:"dbPassword"` // Database password
JavaXTerm string `json:"javaXTerm" yaml:"javaXTerm"` // Full path to JAVA-Xterm jar
JavaFlush string `json:"javaFlush" yaml:"javaFlush"` // Full path command line for terminal
NewApi bool `json:"newApi" yaml:"newApi"` // Use new API
}

type ConfigLog struct {
Expand Down Expand Up @@ -114,6 +114,7 @@ func NewConfig() *Config {
DbPassword: "",
JavaXTerm: "",
JavaFlush: "",
NewApi: false,
},
Log: ConfigLog{
Level: "INFO",
Expand All @@ -139,16 +140,14 @@ func NewConfig() *Config {
}

func (c *Config) LoadFile(filename string) (err error) {
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
if err != nil {
return err
}
return c.ProcessLoadFile(content)
}

/*
Process config content
*/
// ProcessLoadFile Process config content from file
func (c *Config) ProcessLoadFile(content []byte) (err error) {
err = yaml.UnmarshalStrict(content, c)
if err != nil {
Expand Down Expand Up @@ -238,6 +237,9 @@ func (a *ConfigZqm) Validate() (err error) {
}

func (a *ConfigZqm) IsCleanCache() bool {
if a.NewApi {
return true
}
if len(a.JavaXTerm) < 0 {
return false
}
Expand Down Expand Up @@ -356,6 +358,7 @@ func (a *ConfigZqm) Print() string {
o = fmt.Sprintf("%s\t- DB User %s\r\n", o, a.DbUser)
o = fmt.Sprintf("%s\t- JAVAX-Xterm %s\r\n", o, a.JavaXTerm)
o = fmt.Sprintf("%s\t- Java Flush command %s\r\n", o, a.JavaFlush)
o = fmt.Sprintf("%s\t- Java Flush command %t\r\n", o, a.NewApi)
return o
}

Expand Down

0 comments on commit 840ed99

Please sign in to comment.