Skip to content

Commit 1d7a4d7

Browse files
author
David Linko
committed
fixing generaing ari with nested components
1 parent 23e27a7 commit 1d7a4d7

File tree

12 files changed

+66
-68
lines changed

12 files changed

+66
-68
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,2 @@
1-
[
2-
{
3-
"name": "UDP CL",
4-
"parameter": ["hostname", "port"],
5-
"command": [
6-
"ari:/IANA:ion_bp_admin/CTRL.outduct_add(\"udp\",\"<hostname>:<port>\",\"udpclo\", 0)",
7-
"ari:/IANA:ion_bp_admin/CTRL.outduct_start(\"udp\",\"<hostname>:<port>\")",
8-
"ari:/IANA:ion_bp_admin/CTRL.egress_plan_add(\"<eid>\", \"udp\", \"<hostname>:<port>\")",
9-
"ari:/IANA:ion_bp_admin/CTRL.egress_plan_start(\"<eid>\", \"<hostname>:<port>\")"
10-
]}
11-
]
1+
[]
122

anms-core/anms/routes/ARIs/reports.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ async def report_def_by_id(agent_id: str):
8181
correlator_nonce = res.correlator_nonce
8282
stmt = select(ExecutionSet).where(and_(ExecutionSet.agent_id == agent_id, ExecutionSet.correlator_nonce == correlator_nonce) )
8383
result: Result = await session.scalars(stmt)
84-
res = result.one_or_none()
85-
ari_val = ""
86-
if(res):
87-
ari_val = await transcoder.transcoder_put_cbor_await("ari:0x"+res.entries.hex())
88-
logger.info(ari_val)
89-
ari_val = ari_val['data']
90-
addition = {'exec_set': ari_val,'correlator_nonce':correlator_nonce}
91-
if addition not in final_res:
92-
final_res.append(addition)
84+
exc_set = result.all()
85+
for res in exc_set:
86+
ari_val = ""
87+
if(res):
88+
ari_val = await transcoder.transcoder_put_cbor_await("0x"+res.entries.hex())
89+
ari_val = ari_val['data']
90+
addition = {'exec_set': ari_val,'correlator_nonce':correlator_nonce}
91+
if addition not in final_res:
92+
final_res.append(addition)
9393

9494
return final_res
9595

@@ -122,7 +122,6 @@ async def report_ac(agent_id: str, correlator_nonce: int):
122122

123123
# current ARI should be an exection set
124124
if ari:
125-
logger.info(ari)
126125
if type(ari.value) == ace.ari.ExecutionSet:
127126
try:
128127
enc = ace.ari_text.Encoder()
@@ -166,7 +165,6 @@ async def report_ac(agent_id: str, correlator_nonce: int):
166165

167166
# current ARI should be an report set
168167
if ari:
169-
logger.info(ari)
170168
if type(ari.value) == ace.ari.ReportSet:
171169
for rpt in ari.value.reports:
172170
try:

anms-core/anms/routes/transcoder.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ async def transcoder_put_cbor_await(cbor: str):
9898
transcoder_log_id = None
9999
with get_session() as session:
100100
curr_uri = TranscoderLog.query.filter(or_(TranscoderLog.input_string==cbor, TranscoderLog.cbor==cbor)).first()
101-
102101
if curr_uri is None:
103102
c1 = TranscoderLog(input_string=cbor, parsed_as='pending')
104103
session.add(c1)

anms-ui/public/app/components/adm/Adm.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
data() {
8282
return {
8383
file: null,
84-
allowUploadTypes: ["application/json"]
84+
allowUploadTypes: ["yang"]
8585
};
8686
},
8787
computed: {
@@ -103,7 +103,7 @@ export default {
103103
return this.adms.length > 0;
104104
},
105105
hasValidFile() {
106-
return (!_.isNull(this.file) && _.includes(this.allowUploadTypes, this.file.type));
106+
return (!_.isNull(this.file) );
107107
},
108108
},
109109
async mounted() {

anms-ui/public/app/components/management/agents/reports.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
<script>
3535
import api from '../../../shared/api'
36+
import toastr from "toastr";
3637
3738
export default {
3839
name: "reports",
@@ -66,6 +67,7 @@ export default {
6667
// handle error
6768
console.error("reports error", error);
6869
console.info("error obj:", error);
70+
toastr.error("reports error: " + error)
6971
});
7072
7173
this.loading = false;

anms-ui/public/app/components/management/builder/ActionParameter.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div>
3-
<label>{{name}}:</label>
4-
{{ count }}
3+
<label>{{name}}({{ type }}):</label>
54
<div>
65
<b-form-group>
76
<v-select v-model="ariKey"
@@ -86,7 +85,6 @@ export default {
8685
let value = result[0].value;
8786
let head = value.includes("ari") ? "" : "ari://";
8887
let realIndex = this.keysRealIndex[index];
89-
9088
this.currAc[realIndex] = head + value;
9189
this.submitAC();
9290
},
@@ -110,6 +108,7 @@ export default {
110108
}
111109
});
112110
this.currAc = currAc;
111+
113112
this.submitAC();
114113
},
115114
},

anms-ui/public/app/components/management/builder/ParameterView.vue

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export default {
8080
generateParameters() {
8181
parameter_builder.methods.genParms(this.ariKey, this.ARIs).then(response => {
8282
this.parameters = response[0];
83-
8483
this.description = response[1];
8584
this.finResult = response[2];
8685
this.finResultBase = this.finResult;
@@ -106,69 +105,72 @@ export default {
106105
107106
let testResult = [];
108107
if (this.ariKey.actual) {
109-
this.$emit("updateResult", [{ type: "/ARITYPE/OBJECT", value: this.ariKey.display }]);
108+
this.$emit("updateResult", [{ type: "OBJECT", value: this.ariKey.display }]);
110109
this.finResult = this.finResultBase;
111110
} else {
112111
this.finResult.forEach((element) => {
113112
let type = element["type"];
114113
let value = element["value"];
115114
let currValue = [];
116115
switch (type) {
117-
case "/ARITYPE/TEXTSTR":
118-
testResult.push(encodeURIComponent(JSON.stringify(value)));
116+
case "TEXTSTR":
117+
testResult.push(JSON.stringify(value));
119118
break;
120-
case "/ARITYPE/BYTESTR":
121-
testResult.push(encodeURIComponent(JSON.stringify(value)));
119+
case "BYTESTR":
120+
testResult.push(JSON.stringify(value));
122121
break;
123-
case "/ARITYPE/BYTE":
124-
testResult.push(encodeURIComponent(JSON.stringify(value)));
122+
case "BYTE":
123+
testResult.push(JSON.stringify(value));
125124
break;
126-
case "/ARITYPE/INT":
127-
testResult.push(encodeURIComponent(JSON.stringify(value).replaceAll('"', "")));
125+
case "INT":
126+
testResult.push(JSON.stringify(value).replaceAll('"', ""));
128127
break;
129-
case "/ARITYPE/UINT":
130-
testResult.push(encodeURIComponent(JSON.stringify(value).replaceAll('"', "")));
128+
case "UINT":
129+
testResult.push(JSON.stringify(value).replaceAll('"', ""));
131130
break;
132-
case "/ARITYPE/VAST":
133-
testResult.push(encodeURIComponent(JSON.stringify(value).replaceAll('"', "")));
131+
case "VAST":
132+
testResult.push(JSON.stringify(value).replaceAll('"', ""));
134133
break;
135-
case "/ARITYPE/UVAST":
134+
case "UVAST":
136135
testResult.push(
137-
encodeURIComponent(JSON.stringify(value).replaceAll('"', ""))
136+
JSON.stringify(value).replaceAll('"', "")
138137
);
139138
break;
140-
case "/ARITYPE/REAL32":
139+
case "REAL32":
141140
testResult.push(
142-
encodeURIComponent(JSON.stringify(value).replaceAll('"', ""))
141+
JSON.stringify(value).replaceAll('"', "")
143142
);
144143
break;
145-
case "/ARITYPE/REAL64":
144+
case "REAL64":
146145
testResult.push(
147-
encodeURIComponent(JSON.stringify(value).replaceAll('"', ""))
146+
JSON.stringify(value).replaceAll('"', "")
148147
);
149148
break;
150-
case "/ARITYPE/TP":
151-
testResult.push(encodeURIComponent(JSON.stringify(value).replaceAll('"', "")));
149+
case "TP":
150+
testResult.push(JSON.stringify(value).replaceAll('"', ""));
152151
break;
153-
case "/ARITYPE/TD":
154-
testResult.push(encodeURIComponent(JSON.stringify(value).replaceAll('"', "")));
152+
case "TD":
153+
testResult.push(JSON.stringify(value).replaceAll('"', ""));
155154
break;
156-
case "/ARITYPE//ARITYPE/OBJECT": //ari
155+
case "OBJECT": //ari
157156
let head = value.includes("ari:/") ? "" : "ari://";
158157
159158
testResult.push(JSON.stringify(head + value).replaceAll('"', ""));
160159
break;
161-
case "/ARITYPE/AC": //ac
162-
currValue = [];
160+
case "AC": //ac
161+
let curr_str= ""
162+
currValue = [];
163163
value.forEach((ari) => {
164-
currValue.push(ari.replaceAll('"', "'"));
164+
currValue.push(ari.replaceAll('"', ""));
165165
});
166-
167-
testResult.push(JSON.stringify(currValue).replaceAll('"', "").replaceAll("'",'"'));
168-
166+
if(currValue.length = 1 ){
167+
testResult.push(currValue[0])
168+
}else{
169+
testResult.push("/AC/("+currValue.join(",")+")");
170+
}
169171
break;
170172
171-
case "/ARITYPE/EXPR": //ac
173+
case "EXPR": //ac
172174
currValue = [];
173175
var parts = value.split("%")
174176
parts[1].split(',').forEach((ari) => {
@@ -180,8 +182,10 @@ export default {
180182
break;
181183
default:
182184
if (type.includes("TYPEDEF")){
183-
testResult.push(JSON.stringify(ari[0]));
184-
}else{testResult.push((JSON.stringify(value)));}
185+
testResult.push(value[0]);
186+
}else{
187+
188+
testResult.push((value));}
185189
186190
break;
187191
}
@@ -203,6 +207,8 @@ export default {
203207
// if using in agentModal adding ari:/EXECSET/ portion
204208
if(typeof this.nonce !== 'undefined'){
205209
// correlator_nonc
210+
// TODO currently random mayube make it increment or a choice
211+
// let nonce = Math.floor(Math.random() * 99999) + 1;
206212
this.finResultStr = "ari:/EXECSET/n=" + this.nonce + ";(" + this.finResultStr +")";
207213
}
208214
this.$emit("updateResult", [{ type: "ARI", value: this.finResultStr }]);

anms-ui/public/app/components/management/builder/ariBuilder.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ export default {
139139
});
140140
break;
141141
case "/ARITYPE/BOOL":
142-
finResult.push({ "index": index, "type": "/ARITYPE/BOOl", "value": 0 })
143-
typeLabel = "BOOl";
142+
finResult.push({ "index": index, "type": "/ARITYPE/BOOL", "value": " " })
143+
typeLabel = "BOOL";
144144
distParms.push({
145145
type: prim_parameter,// TODO update to its own
146146
parameter: { index: index, result: "", name: name, type: typeLabel },
@@ -156,7 +156,7 @@ export default {
156156
break;
157157
case "/ARITYPE/TD":
158158
finResult.push({ "index": index, "type": "/ARITYPE/TD", "value": 0 });
159-
typeLabel = "TS";
159+
typeLabel = "TD";
160160
distParms.push({
161161
type: prim_parameter,
162162
parameter: { index: index, result: "", name: name, type: typeLabel },

anms-ui/public/app/components/management/builder/primParameter.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export default {
2525
methods: {
2626
updateResults() {
2727
this.result["type"] = this.type;
28-
this.result["value"] = this.value;
28+
this.result["value"] = "/"+this.type.replace("/ARITYPE/","/")+"/"+this.value;
2929
this.$emit("updateResult", this.result);
3030
},
3131
},

anms-ui/public/app/components/management/monitor/Monitor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="container">
33
<!-- incoming messages -->
4-
<iframe src="/grafana/d-solo/x5LAIuA7z/agents-copy?orgId=1&from=now-48h&to=now&panelId=10" width="100%" height="250" frameborder="0"></iframe>
4+
<iframe src="/grafana/d-solo/x5LAIuA7z/agents-copy?orgId=1&from=now-48h&to=now&panelId=11" width="100%" height="250" frameborder="0"></iframe>
55
<!-- reports -->
66
<iframe src="/grafana/d-solo/oZ7xupanz/reports?orgId=1&from=now-48h&to=now&panelId=123129" width="100%" height="250" frameborder="0"></iframe>
77
<!-- aris -->

0 commit comments

Comments
 (0)