DynamicVeiw Topics¶
DynamicView uses similar concepts from Impact. As you have seen the DynamicView and impact adatpers can be defined in a unified way.
In this section we only use ZPL: https://zenpack-sdk.zenoss.com/en/latest/ implementation.
Adjusting Order of Component Diagrams¶
Sometimes your DyanamicView diagrams will not be ordered properly from right to left. In order to get the proper order you can set dynamicview_weight on each component class:
dynamicview_weight: 220
dynamicview_relations:
impacted_by: [k8sNamespace]
Make sure you order your weights from low to high corresponding to least impacted to most impacted components. For example, your device would probably be the most impacted object, and thus have the highest weight.
Creating a Device-Level DynamicView Diagram¶
Normally when you select the DynamicView link on the Navigation panel, you would only see the device object in isolation. This is because it isn’t usually impacted by any of its components.
In order to see all objects that impact the device, you have to do two things:
- Add JavaScript at the device-level that defines links and views
- Adjust your zenpack.yaml file
- Restart Zope to test
Add JavaScript at the device-level that defines links and views¶
Inside of your device-level anonymous function add the following adjustProjectDynamicView() method to the global context, and then activate it in the Ext.onReady(function() method:
(function () {
/**
* Adjust device-level DynamicView.
*
* We want to use k8s_view/k8s_link instead of service_view/impacted_by.
* Otherwise the project-level Dynamic View would be just the boring
* project node because it isn't impacted by anything.
*/
function adjustProjectDynamicView() {
var COMPONENT_VIEW_ID = "component_view";
Zenoss.nav.onAvailable("Device", function(collection) {
if (collection.containsKey(COMPONENT_VIEW_ID)) {
// Handle when component_view is added before we run.
collection.replace(COMPONENT_VIEW_ID, {
id: "component_view",
text: _t('Dynamic View'),
xtype: 'dynamicview',
relationshipFilter: 'k8s_link',
viewName: 'k8s_view'
});
} else {
// Handle when component_view is added after we run.
collection.addListener("add", function(index, object, key){
if (key == COMPONENT_VIEW_ID) {
object.viewName = "k8s_view";
object.relationshipFilter = "k8s_link";
}
});
}
});
}
// Other definitions etc...
Ext.onReady(function(){
// Use k8s_view/k8s_link for device-level Dynamic View.
adjustProjectDynamicView();
// Other component level Ext.* methods.
});
}());
Adjust your zenpack.yaml¶
Now comes the easy part where you add some entries to your YAML. Note that we’ll be adding entries for the link called k8s_link and a view for the k8s_view. Each visible component and device in DV must be part of the k8s_view:
classes:
K8sCluster:
label: Kubernetes Cluster
properties:
cluster_uid:
label: UID
dynamicview_views: [service_view, k8s_view]
dynamicview_weight: 240
dynamicview_relations:
impacts: [k8sNodes, k8sNamespaces, gcp_cluster]
k8s_link: [k8sNodes, k8sNamespaces]
K8sNamespace:
label: NameSpace
properties:
namespace_uid:
label: UID
dynamicview_views: [service_view, k8s_view]
dynamicview_weight: 225
dynamicview_relations:
impacted_by: [k8sCluster]
impacts: [k8sPods, k8sServices, k8sPersistentVolumes]
k8s_link: [k8sServices]
K8sService:
label: Service
properties:
service_uid:
label: UID
dynamicview_views: [service_view, k8s_view]
dynamicview_weight: 215
dynamicview_relations:
impacts: [k8sPods]
impacted_by: [k8sNamespace]
Note
Note that K8sService, while not defining any k8s_link, is referenced by K8sNamespace and thus needs the dynamicview_views line to allow K8sService to be visible in the DV display.
- Now you can restart Zope to test your setup.
Troubleshooting: You see a DV component that looks out of sorts!¶
If you see a component that looks like its out of place or wrong, it could be that its Plural Label matches that of another device or component. If so, you can set a unique plural label in ZPL like this:
K8sContainer:
label: Container
plural_short_label: K8s Containers
In this example we know that there are several ZenPacks with a component whose label is called Container, which could cause DV to render that object instead of the intended K8s entity. Adding the plural_short_label fixes this problem.