Merge branch 'dev'
This commit is contained in:
commit
5df75815b5
|
|
@ -71,7 +71,7 @@ This repository aims to promote the development of a multi-vendor management pla
|
||||||
Run app using <u><b>Docker Compose</b></u>:
|
Run app using <u><b>Docker Compose</b></u>:
|
||||||
<pre>
|
<pre>
|
||||||
user@user-laptop:~$ cd oktopus/deploy/compose
|
user@user-laptop:~$ cd oktopus/deploy/compose
|
||||||
user@user-laptop:~/oktopus/deploy/compose$ COMPOSE_PROFILES=nats,controller,mqtt,stomp,ws,adapter,frontend,portainer docker compose up -d
|
user@user-laptop:~/oktopus/deploy/compose$ COMPOSE_PROFILES=nats,controller,cwmp,mqtt,stomp,ws,adapter,frontend,portainer docker compose up -d
|
||||||
</pre>
|
</pre>
|
||||||
Oktopus deployment in <u><b>Kubernetes</b></u> still is in beta phase: <a href="https://github.com/OktopUSP/oktopus/blob/main/deploy/kubernetes/README.md"> Instructions for Kubernetes deployment</a><p></p>
|
Oktopus deployment in <u><b>Kubernetes</b></u> still is in beta phase: <a href="https://github.com/OktopUSP/oktopus/blob/main/deploy/kubernetes/README.md"> Instructions for Kubernetes deployment</a><p></p>
|
||||||
UI will open at port 3000:
|
UI will open at port 3000:
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ func main() {
|
||||||
|
|
||||||
natsActions := nats.StartNatsClient(c.Nats)
|
natsActions := nats.StartNatsClient(c.Nats)
|
||||||
|
|
||||||
h := handler.NewHandler(natsActions.Publish, natsActions.Subscribe)
|
h := handler.NewHandler(natsActions.Publish, natsActions.Subscribe, c.Acs)
|
||||||
|
|
||||||
b := bridge.NewBridge(
|
b := bridge.NewBridge(
|
||||||
natsActions.Publish,
|
natsActions.Publish,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/joho/godotenv"
|
"github.com/joho/godotenv"
|
||||||
)
|
)
|
||||||
|
|
@ -24,9 +25,11 @@ type Acs struct {
|
||||||
Tls bool
|
Tls bool
|
||||||
TlsPort bool
|
TlsPort bool
|
||||||
NoTls bool
|
NoTls bool
|
||||||
|
KeepAliveInterval time.Duration
|
||||||
Username string
|
Username string
|
||||||
Password string
|
Password string
|
||||||
Route string
|
Route string
|
||||||
|
DebugMode bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
|
@ -44,6 +47,8 @@ func NewConfig() *Config {
|
||||||
natsVerifyCertificates := flag.Bool("nats_verify_certificates", lookupEnvOrBool("NATS_VERIFY_CERTIFICATES", false), "verify validity of certificates from nats server")
|
natsVerifyCertificates := flag.Bool("nats_verify_certificates", lookupEnvOrBool("NATS_VERIFY_CERTIFICATES", false), "verify validity of certificates from nats server")
|
||||||
acsPort := flag.String("acs_port", lookupEnvOrString("ACS_PORT", ":9292"), "port for acs server")
|
acsPort := flag.String("acs_port", lookupEnvOrString("ACS_PORT", ":9292"), "port for acs server")
|
||||||
acsRoute := flag.String("acs_route", lookupEnvOrString("ACS_ROUTE", "/acs"), "route for acs server")
|
acsRoute := flag.String("acs_route", lookupEnvOrString("ACS_ROUTE", "/acs"), "route for acs server")
|
||||||
|
acsKeepAliveInterval := flag.Int("acs_keep_alive_interval", lookupEnvOrInt("KEEP_ALIVE_INTERVAL", 300), "keep alive interval in seconds for acs server")
|
||||||
|
cwmpDebugMode := flag.Bool("debug_mode", lookupEnvOrBool("CWMP_DEBUG", false), "enable or disable cwmp logs in debug mode")
|
||||||
flHelp := flag.Bool("help", false, "Help")
|
flHelp := flag.Bool("help", false, "Help")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -72,6 +77,8 @@ func NewConfig() *Config {
|
||||||
Acs: Acs{
|
Acs: Acs{
|
||||||
Port: *acsPort,
|
Port: *acsPort,
|
||||||
Route: *acsRoute,
|
Route: *acsRoute,
|
||||||
|
KeepAliveInterval: time.Duration(*acsKeepAliveInterval),
|
||||||
|
DebugMode: *cwmpDebugMode,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +106,17 @@ func lookupEnvOrString(key string, defaultVal string) string {
|
||||||
return defaultVal
|
return defaultVal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func lookupEnvOrInt(key string, defaultVal int) int {
|
||||||
|
if val, _ := os.LookupEnv(key); val != "" {
|
||||||
|
v, err := strconv.Atoi(val)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("LookupEnvOrInt[%s]: %v", key, err)
|
||||||
|
}
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return defaultVal
|
||||||
|
}
|
||||||
|
|
||||||
func lookupEnvOrBool(key string, defaultVal bool) bool {
|
func lookupEnvOrBool(key string, defaultVal bool) bool {
|
||||||
if val, _ := os.LookupEnv(key); val != "" {
|
if val, _ := os.LookupEnv(key); val != "" {
|
||||||
v, err := strconv.ParseBool(val)
|
v, err := strconv.ParseBool(val)
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,10 @@ func (h *Handler) CwmpHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
tmp, _ := ioutil.ReadAll(r.Body)
|
tmp, _ := ioutil.ReadAll(r.Body)
|
||||||
body := string(tmp)
|
body := string(tmp)
|
||||||
|
|
||||||
|
if h.acsConfig.DebugMode {
|
||||||
|
log.Println("Received message: ", body)
|
||||||
|
}
|
||||||
|
|
||||||
var envelope cwmp.SoapEnvelope
|
var envelope cwmp.SoapEnvelope
|
||||||
xml.Unmarshal(tmp, &envelope)
|
xml.Unmarshal(tmp, &envelope)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"oktopUSP/backend/services/acs/internal/config"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/nats-io/nats.go"
|
"github.com/nats-io/nats.go"
|
||||||
|
|
@ -56,6 +57,7 @@ type Handler struct {
|
||||||
pub func(string, []byte) error
|
pub func(string, []byte) error
|
||||||
sub func(string, func(*nats.Msg)) error
|
sub func(string, func(*nats.Msg)) error
|
||||||
Cpes map[string]CPE
|
Cpes map[string]CPE
|
||||||
|
acsConfig config.Acs
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -64,10 +66,15 @@ const (
|
||||||
NATS_ADAPTER_SUBJECT_PREFIX = "adapter.v1."
|
NATS_ADAPTER_SUBJECT_PREFIX = "adapter.v1."
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewHandler(pub func(string, []byte) error, sub func(string, func(*nats.Msg)) error) *Handler {
|
func NewHandler(
|
||||||
|
pub func(string, []byte) error,
|
||||||
|
sub func(string, func(*nats.Msg)) error,
|
||||||
|
cAcs config.Acs,
|
||||||
|
) *Handler {
|
||||||
return &Handler{
|
return &Handler{
|
||||||
pub: pub,
|
pub: pub,
|
||||||
sub: sub,
|
sub: sub,
|
||||||
Cpes: make(map[string]CPE),
|
Cpes: make(map[string]CPE),
|
||||||
|
acsConfig: cAcs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,19 +5,13 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: make these consts dynamic via config
|
|
||||||
const (
|
|
||||||
CHECK_STATUS_INTERVAL = 10 * time.Second
|
|
||||||
KEEP_ALIVE_INTERVAL = 600 * time.Second
|
|
||||||
)
|
|
||||||
|
|
||||||
func (h *Handler) handleCpeStatus(cpe string) {
|
func (h *Handler) handleCpeStatus(cpe string) {
|
||||||
for {
|
for {
|
||||||
if time.Since(h.Cpes[cpe].LastConnection) > KEEP_ALIVE_INTERVAL {
|
if time.Since(h.Cpes[cpe].LastConnection) > h.acsConfig.KeepAliveInterval {
|
||||||
delete(h.Cpes, cpe)
|
delete(h.Cpes, cpe)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
time.Sleep(CHECK_STATUS_INTERVAL)
|
time.Sleep(h.acsConfig.KeepAliveInterval)
|
||||||
}
|
}
|
||||||
log.Println("CPE", cpe, "is offline")
|
log.Println("CPE", cpe, "is offline")
|
||||||
h.pub("cwmp.v1."+cpe+".status", []byte("0"))
|
h.pub("cwmp.v1."+cpe+".status", []byte("0"))
|
||||||
|
|
|
||||||
|
|
@ -186,6 +186,7 @@ services:
|
||||||
networks:
|
networks:
|
||||||
usp_network:
|
usp_network:
|
||||||
ipv4_address: 172.16.235.16
|
ipv4_address: 172.16.235.16
|
||||||
|
profiles: [cwmp]
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
usp_network:
|
usp_network:
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ export const OverviewLatestOrders = (props) => {
|
||||||
</SeverityPill>
|
</SeverityPill>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell>
|
<TableCell>
|
||||||
<SvgIcon
|
{ order.Status == 2 && (order.Mqtt == 0 && order.Websockets == 0 && order.Stomp == 0) ? <span></span>: <SvgIcon
|
||||||
fontSize="small"
|
fontSize="small"
|
||||||
sx={{cursor: order.Status == 2 && 'pointer'}}
|
sx={{cursor: order.Status == 2 && 'pointer'}}
|
||||||
onClick={()=>{
|
onClick={()=>{
|
||||||
|
|
@ -108,7 +108,7 @@ export const OverviewLatestOrders = (props) => {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ArrowTopRightOnSquareIcon />
|
<ArrowTopRightOnSquareIcon />
|
||||||
</SvgIcon>
|
</SvgIcon>}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user