Skip to content

Commit

Permalink
rel2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
wisotzky committed Jul 2, 2024
1 parent 13b495d commit 30377d7
Show file tree
Hide file tree
Showing 35 changed files with 3,316 additions and 43 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,13 @@ Updates:
* Audit report format: For misaligned object entries with isConfigured equals false use different color
* Command `setPassword` can now be triggered from other extensions while passing the new password.
* Updated badges/tooltips/colors in FileSystemProvider (Explorer View)
* Explorer view now shows if vsCode is connected to Intent Manager. Tooltips provide extra information.
* Explorer view now shows if vsCode is connected to Intent Manager. Tooltips provide extra information.

## [2.5.0]

Updates:
* Workspace entry Intent Manager tooltip include details when not connected / connection errors
to replace error dialogue. Results in better user experience, especially when multiple NSP
extensions are installed.
* Show NSP version as {major}.{minor}. With this "24.4.0" is displayed now as "24.4".
* New IPL!nk template for next-gen JavaScript engine (GraalJS)
26 changes: 19 additions & 7 deletions media/report.html.njk
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@
};
function clickFirstTab() {
document.getElementById("select_tab1").click();
{% if report["misaligned-attribute"] %}
document.getElementById("select_tab1").click();
{% elif report["misaligned-object"] %}
document.getElementById("select_tab2").click();
{% else %}
document.getElementById("select_tab3").click();
{% endif %}
}
</script>
Expand All @@ -115,11 +121,18 @@
</div>

<div class="tab">
{% if report["misaligned-attribute"] %}
<button class="tablinks" id="select_tab1" onclick="openTab(event, 'tab1')">MISALIGNED ATTRIBUTES</button>
{% endif %}
{% if report["misaligned-object"] %}
<button class="tablinks" id="select_tab2" onclick="openTab(event, 'tab2')">MISSING OBJECTS</button>
{% endif %}
{% if report["undesired-object"] %}
<button class="tablinks" id="select_tab3" onclick="openTab(event, 'tab3')">UNDESIRED OBJECTS</button>
{% endif %}
</div>

{% if report["misaligned-attribute"] %}
<div id="tab1" class="tabcontent">
<table>
<tr>
Expand All @@ -128,7 +141,6 @@
<th>Desired Value</th>
<th>Observed Value</th>
</tr>
{% if report["misaligned-attribute"] %}
{% for entry in report["misaligned-attribute"] %}
<tr>
<td>{{ entry["device-name"] }}</td>
Expand All @@ -137,17 +149,17 @@
<td>{{ entry["actual-value"] }}</td>
</tr>
{% endfor %}
{% endif %}
</table>
</div>
{% endif %}

{% if report["misaligned-object"] %}
<div id="tab2" class="tabcontent">
<table>
<tr>
<th>Site</th>
<th>Path</th>
</tr>
{% if report["misaligned-object"] %}
{% for entry in report["misaligned-object"] %}
<tr>
<td>{{ entry["device-name"] }}</td>
Expand All @@ -158,17 +170,17 @@
{% endif %}
</tr>
{% endfor %}
{% endif %}
</table>
</div>
{% endif %}

{% if report["undesired-object"] %}
<div id="tab3" class="tabcontent">
<table>
<tr>
<th>Site</th>
<th>Path</th>
</tr>
{% if report["undesired-object"] %}
{% for entry in report["undesired-object"] %}
<tr>
<td>{{ entry["device-name"] }}</td>
Expand All @@ -179,8 +191,8 @@
{% endif %}
</tr>
{% endfor %}
{% endif %}
</table>
</div>
{% endif %}
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nokia-intent-manager",
"displayName": "NOKIA_IM",
"description": "NOKIA IM vsCode Developer Plugin",
"version": "2.4.0",
"version": "2.5.0",
"icon": "media/NSP_Logo.png",
"publisher": "Nokia",
"repository": "http://github.com/nokia/vscode-intent-manager",
Expand Down
48 changes: 39 additions & 9 deletions src/providers/IntentManagerProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ const COLOR_CUSTOMIZATION = new vscode.ThemeColor('list.highlightForeground'); /
const COLOR_WARNING = new vscode.ThemeColor('list.warningForeground');
const COLOR_ERROR = new vscode.ThemeColor('list.errorForeground');

const DECORATION_INITIAL = { badge: '❗', tooltip: 'Disconnected', color: COLOR_ERROR }; // should become codicon $(warning)
const DECORATION_CONNECTED = { badge: '✔', tooltip: 'Connected...', color: COLOR_OK }; // should become codicon $(vm-active)
const DECORATION_SIGNED = { badge: '🔒', tooltip: 'IntentType: Signed', color: COLOR_READONLY};
const DECORATION_DISCONNECTED = { badge: '❗', tooltip: 'Not connected!', color: COLOR_ERROR }; // should become codicon $(warning)
const DECORATION_CONNECTED = { badge: '✔', tooltip: 'Connecting...', color: COLOR_OK }; // should become codicon $(vm-active)
const DECORATION_SIGNED = { badge: '🔒', tooltip: 'IntentType: Signed', color: COLOR_READONLY};

const DECORATION_VIEWS = { tooltip: 'UI Form Customization', color: COLOR_CUSTOMIZATION };
const DECORATION_INTENTS = { tooltip: 'Intents', color: COLOR_CUSTOMIZATION };
Expand Down Expand Up @@ -190,7 +190,10 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
setTimeout(() => this._revokeAuthToken(), 600000); // automatically revoke token after 10min
} else {
this.pluginLogs.warn("NSP response:", response.status, json.error);
vscode.window.showErrorMessage("NSP Authentication Error");

DECORATION_DISCONNECTED.tooltip = "Authentication failure (user:"+this.username+", error:"+json.error+")!";
this._eventEmiter.fire(vscode.Uri.parse('im:/'));

this.authToken = undefined; // Reset authToken on error
reject("Authentication Error!");
}
Expand All @@ -200,7 +203,9 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
else
this.pluginLogs.error("Getting authToken failed with", error.message);

vscode.window.showErrorMessage("NSP is not reachable");
DECORATION_DISCONNECTED.tooltip = this.nspAddr+" unreachable!";
this._eventEmiter.fire(vscode.Uri.parse('im:/'));

this.authToken = undefined; // Reset authToken on error
resolve(undefined);
});
Expand Down Expand Up @@ -368,7 +373,9 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
if (!response.ok)
this._raiseRestconfError("Getting NSP release failed!", await response.json());
let json : any = await response.json();
this.nspVersion = json.response.data.nspOSVersion.match(/\d+\.\d+\.\d+/)[0];
this.nspVersion = json.response.data.nspOSVersion.match(/\d+\.\d+(?=\.\d+)/)[0];

this._eventEmiter.fire(vscode.Uri.parse('im:/'));

this.pluginLogs.info("Requesting OSD version");
response = await this._callNSP("/logviewer/api/status", {method: "GET"});
Expand All @@ -382,7 +389,6 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
this.osdVersion = json.version.number;

vscode.window.showInformationMessage("Connected to "+this.nspAddr+", NSP version: "+this.nspVersion+", OSD version: "+this.osdVersion);
this._eventEmiter.fire(vscode.Uri.parse('im:/'));
}

/**
Expand Down Expand Up @@ -1295,8 +1301,9 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
this.pluginLogs.debug("provideFileDecoration(im:/)");
if (this.nspVersion) {
DECORATION_CONNECTED.tooltip = "Connected to "+this.username+"@"+this.nspAddr+" (Release: "+this.nspVersion+")";
DECORATION_DISCONNECTED.tooltip = "Not connected!"; // revert to original text
return DECORATION_CONNECTED;
} else return DECORATION_INITIAL;
} else return DECORATION_DISCONNECTED;
}

if (parts[0]==="im:" && pattern.test(parts[1])) {
Expand Down Expand Up @@ -1374,6 +1381,10 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
this.port = port;
this.nspVersion = undefined;
this.osdVersion = undefined;

DECORATION_CONNECTED.tooltip = "Connecting..."; // revert to original text
DECORATION_DISCONNECTED.tooltip = "Not connected!"; // revert to original text

this._eventEmiter.fire(vscode.Uri.parse('im:/'));
}

Expand Down Expand Up @@ -2432,7 +2443,7 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
// merge common resources

if (fs.existsSync(vscode.Uri.joinPath(templatePath, "merge_common_resources").fsPath)) {
const commonsPath = vscode.Uri.joinPath(this.extensionUri, 'templates', 'common-resources');
const commonsPath = vscode.Uri.joinPath(this.extensionUri, 'templates', 'common_resources');
const j2resources = nunjucks.configure(commonsPath.fsPath);

// @ts-expect-error fs.readdirSync() returns string[] for utf-8 encoding (default)
Expand All @@ -2448,6 +2459,25 @@ export class IntentManagerProvider implements vscode.FileSystemProvider, vscode.
meta.resource.push({name: filename, value: j2resources.render(filename, data)});
});
}

if (fs.existsSync(vscode.Uri.joinPath(templatePath, "merge_common_resources_graaljs").fsPath)) {
const commonsPath = vscode.Uri.joinPath(this.extensionUri, 'templates', 'common_resources_graaljs');
const j2resources = nunjucks.configure(commonsPath.fsPath);

// @ts-expect-error fs.readdirSync() returns string[] for utf-8 encoding (default)
fs.readdirSync(commonsPath.fsPath, {recursive: true}).forEach((filename: string) => {
const fullpath = vscode.Uri.joinPath(commonsPath, filename).fsPath;
if (!fs.lstatSync(fullpath).isFile())
this.pluginLogs.info("ignore "+filename+" (not a file)");
else if (filename.startsWith('.') || filename.includes('/.'))
this.pluginLogs.info("ignore hidden file/folder "+filename);
else if (resourcefiles.includes(filename))
this.pluginLogs.info(filename+" (common) skipped, overwritten in template");
else
meta.resource.push({name: filename, value: j2resources.render(filename, data)});
});
}


// Intent-type "meta" may contain the parameter "intent-type"
// RESTCONF API required parameter "name" instead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
},
"health": {}
},

"[${site.ne\-name}] ISIS INTERFACE ${site.port\-id}": {
"config": {
"target": "Cisco-IOS-XR-um-router-isis-cfg:/router/isis/processes/process=isis/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -47,7 +46,6 @@
},
"health": {}
},

"[${site.ne\-name}] LDP INTERFACE ${site.port\-id}": {
"config": {
"target": "Cisco-IOS-XR-um-mpls-ldp-cfg:/mpls/ldp/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -61,4 +59,4 @@
},
"health": {}
}
}
}
5 changes: 1 addition & 4 deletions templates/SRX24 iplink/intent-type-resources/JunOS.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
},
"health": {}
},

"[${site.ne\-name}] LLDP INTERFACE ${site.port\-id}": {
"config": {
"target": "junos-conf-root:/configuration/protocols/lldp/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -44,7 +43,6 @@
},
"health": {}
},

"[${site.ne\-name}] ISIS INTERFACE ${site.port\-id}.1": {
"config": {
"target": "junos-conf-root:/configuration/protocols/isis/interface=${site.port\-id?url('ISO-8859-1')}.1",
Expand All @@ -59,7 +57,6 @@
},
"health": {}
},

"[${site.ne\-name}] LDP INTERFACE ${site.port\-id}.1": {
"config": {
"target": "junos-conf-root:/configuration/protocols/ldp/interface=${site.port\-id?url('ISO-8859-1')}.1",
Expand All @@ -73,4 +70,4 @@
},
"health": {}
}
}
}
9 changes: 1 addition & 8 deletions templates/SRX24 iplink/intent-type-resources/OpenConfig.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
}
}
},

"[${site.ne\-name}] LLDP INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-lldp:/lldp/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -91,7 +90,6 @@
}
}
},

"[${site.ne\-name}] NETWORK INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-network-instance:/network-instances/network-instance=Base/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -109,7 +107,6 @@
}
}
},

"[${site.ne\-name}] ISIS INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-network-instance:/network-instances/network-instance=Base/protocols/protocol=ISIS,0/isis/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand Down Expand Up @@ -156,7 +153,6 @@
}
}
},

"health": {
<#-- SR OS MDC OpenConfig adaptor does not cover levels/level/adjacencies
"openconfig-network-instance:/network-instances/network-instance=Base/protocols/protocol=ISIS,0/isis/interfaces/interface=${site.port\-id?url('ISO-8859-1')}/levels/level=1/adjacencies": {
Expand All @@ -172,7 +168,6 @@
-->
}
},

"[${site.ne\-name}] MPLS INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-network-instance:/network-instances/network-instance=Base/mpls/global/interface-attributes/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -193,7 +188,6 @@
}
}
},

"[${site.ne\-name}] TE INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-network-instance:/network-instances/network-instance=Base/mpls/te-interface-attributes/interface=${site.port\-id?url('ISO-8859-1')}",
Expand All @@ -214,7 +208,6 @@
}
}
},

"[${site.ne\-name}] LDP INTERFACE ${site.port\-id}": {
"config": {
"target": "openconfig-network-instance:/network-instances/network-instance=Base/mpls/signaling-protocols/ldp/interface-attributes/interfaces/interface=${site.port\-id?url('ISO-8859-1')}",
Expand Down Expand Up @@ -246,4 +239,4 @@
}
}
}
}
}
9 changes: 3 additions & 6 deletions templates/SRX24 iplink/intent-type-resources/SR OS.ftl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<#setting number_format="computer">
<#assign ifname="${target}_${site['ne-name']}_to_${site.peer['ne-name']}">
<#assign ifname="${site['ne-name']}_to_${site.peer['ne-name']}">
{
"[${site.ne\-name}] PORT ${site.port\-id}": {
"[${site.ne\-name}] PORT ${site.port\-id}": {
"config": {
"target": "nokia-conf:/configure/port=${site.port\-id?url('ISO-8859-1')}",
"operation": "replace",
Expand Down Expand Up @@ -60,7 +60,6 @@
}
}
},

"[${site.ne\-name}] IP INTERFACE ${ifname}": {
"config": {
"target": "nokia-conf:/configure/router=Base/interface=${ifname?url('ISO-8859-1')}",
Expand All @@ -86,7 +85,6 @@
}
}
},

"[${site.ne\-name}] ISIS INTERFACE ${ifname}": {
"config": {
"target": "nokia-conf:/configure/router=Base/isis=0/interface=${ifname?url('ISO-8859-1')}",
Expand Down Expand Up @@ -115,7 +113,6 @@
}
}
},

"[${site.ne\-name}] LDP INTERFACE ${ifname}": {
"config": {
"target": "nokia-conf:/configure/router=Base/ldp/interface-parameters/interface=${ifname?url('ISO-8859-1')}",
Expand Down Expand Up @@ -213,4 +210,4 @@

}
}
}
}
Loading

0 comments on commit 30377d7

Please sign in to comment.