A database of property objects or a group of objects

Started by Azix, March 04, 2024, 14:32:15 PM

Previous topic - Next topic

Azix

I am new to computer architecture, and I work for a company and i would like to do firewall flow rule mapping. And then thanks to the csv I will automate the creation of matrix and rules directly on the firewall.

For that I said to myself, I'm going to take node objects which will correspond to groups of objects like servers, user stations, networks or FQDNs.



For example in a Node I would have several objects:

Server1: 192.168.1.1
Server2: 192.168.2.2
www.google.com: 11.3.3.3, 88.2.2.2, 99.2.2.2



The problem is that I would like to make it like a database depending on the object type.

For example :

IPS network directory
IPS Host Directory
IPS FQDN directory
..

so for example the server Sevreur1 and Sevreur2 will be in the IPS Host Directory, and the www.google.com in the IPS FQDN Directory




So two solutions, either create property databases with not just name and value as for example with a directory as above,




or be able to make groups of objects and the objects are attached with different properties like the basic use of components.








could someone tell me how I can do it? Please


Azix

So, i would like to create firewall flow rules from an Archimate map. And then thanks to the Achimate csv I will automate the creation of flow matrix (like the attached excel) and the creation of rules directly on the firewall.

But I don't know how to do it because I have to create groups of objects without putting the objects in the view but only the groups which does not seem to be possible with Archimate.

Phil Beauvoir

Hi, I have to admit I don't understand what you're trying to do with Properties. There's nothing special about them, they're simply name/value pairs for each object, there's no hierarchy.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Quote from: Azix on March 04, 2024, 16:46:55 PMSo, i would like to create firewall flow rules from an Archimate map. And then thanks to the Achimate csv I will automate the creation of flow matrix (like the attached excel) and the creation of rules directly on the firewall.

That's easy but requires some jArchi scripts.

The best approach is very similar to one of your proposals:
- Use one "Node" (could also be "Device" but most of the time, "Node" is more generic and good-enough) per object (individual server, workstation, network equipment...). Keep track of object's IP in a property named "IP Address". If an object has multiple IP, then create multiple "IP Address" properties on the same node, one for each IP (in Archi the property's name does not have to be unique).
- If you also want to manage IPs ranges, then create "Communication Networks", and again, keep track of the network address in a property named "IP Network".
- Create resources groups using "Grouping" elements which aggregates "Nodes" and/or "Communication Networks". Create one or several views for this specific purpose.
- Model your network architecture with flows to/from "Nodes", "Communication Networks", and "Groupings". No need to add Groupings' content on each view (unless it is needed for people to better understand the context).
- Create a script which takes selected views as input and iterate on all flow relationships contained into these views. When the source or target of a flow is a Grouping, then navigate the model (not the views) to get the list of Nodes and Communication Network. Last, using the properties, generate the expected export file (start by exporting CSV-formatted text on the console, and when ok, use some javascript XLS library to generate a real XLS file).

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Azix

Thanks for the information I've already made a similar script but for example on my firewall I can make object groups.

for example serverweb_group which contains
Server1
Server2
Server3


If I want to make an element group named severweb_group with archimate without putting each object in the view because there can be more than 25 objects in a group. So I'm obliged to take a "Node" for each server and "communication network"? and place them in a Groupings one by one?


Azix

Hi, I'm trying to figure out how to use JArchi but I haven't found how to retrieve objects or flow relationships in a specific view... :

And how to do that :

- Use one "Node" (could also be "Device" but most of the time, "Node" is more generic and good-enough) per object (individual server, workstation, network equipment...). Keep track of object's IP in a property named "IP Address". If an object has multiple IP, then create multiple "IP Address" properties on the same node, one for each IP (in Archi the property's name does not have to be unique).
- If you also want to manage IPs ranges, then create "Communication Networks", and again, keep track of the network address in a property named "IP Network".
- Create resources groups using "Grouping" elements which aggregates "Nodes" and/or "Communication Networks". Create one or several views for this specific purpose.
- Model your network architecture with flows to/from "Nodes", "Communication Networks", and "Groupings". No need to add Groupings' content on each view (unless it is needed for people to better understand the context).
- Create a script which takes selected views as input and iterate on all flow relationships contained into these views. When the source or target of a flow is a Grouping, then navigate the model (not the views) to get the list of Nodes and Communication Network. Last, using the properties, generate the expected export file (start by exporting CSV-formatted text on the console, and when ok, use some javascript XLS library to generate a real XLS file).


Can someone explain or give me a piece of code to understand? please

Phil Beauvoir

@Azix I merged your latest topic into this one to keep everything together.

Regarding jArchi scripting, it would be easier to help you if you could take one simple problem at a time. Perhaps if you could explain what you have already tried, and then say where you are stuck. For example, "how to add a property to a concept?", "how to add a concept to a view?"

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Azix

Hi, I'm sorry, I'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?

how do I can retrieve the elements according to the view if they are not ?


function get_relationship_from_view(view,relationship_object){

var relationships = {}; // Objet pour stocker les relations

    $(view).children(relationship_object).each(function(obj) {
        relationships[obj.id] = {
            name: obj.name,
            type: obj.type,
            source: obj.source.id,
            target: obj.target.id,
            documentation: obj.documentation
        };
    });
    console.log(relationships);
    return relationships;
}

function get_object_from_model(model,object){
    var objects = {}; // Objet pour stocker les les variable de l'object

    $(model).filter(object).each(function(obj) {
        objects[obj.id] = {
            name: obj.name,
            type: obj.type,
            documentation: obj.documentation
        };
    });

    return objects;
}

function get_relation_from_model(model,object){
    var relationships = {}; // Objet pour stocker les relations

    $(model).each(function(obj) {
        relationships[obj.id] = {
            name: obj.name,
            type: obj.type,
            source: obj.source.id,
            target: obj.target.id,
            documentation: obj.documentation
        };
    });

    return relationships;
}



var relationships = get_relationship_from_view(".view matrix","flow-relationship");
var nodes = get_object_from_model("element","node");
var network = get_object_from_model("element","communication-network");
var groups = get_object_from_model("element","grouping");
var relationships_from_model = get_relation_from_model("flow-relationship","");

console.log("----------GET OBJECT NODE FROM MODEL-!!!!!!!!!!!!!!!!!!!!------------");


for (var id in nodes) {
    if (nodes.hasOwnProperty(id)) {
        var node = nodes[id];
        console.log("Node ID: " + id + ", Name: " + node.name + ", Type: " + node.type);
    }
}
console.log("\n");

console.log("----------GET OBJECT relationships_from_model FROM MODEL-------------");

for (var id in relationships_from_model) {
    if (relationships_from_model.hasOwnProperty(id)) {
        var relation = relationships_from_model[id];
        console.log("Relation ID: " + id + ", Name: " + relation.name + ", Type: " + relation.type + ", Source ID: " + relation.source + ", Target ID: " + relation.target);
    }
    console.log("\n");
}

console.log("----------GET OBJECT relationships_from_VIEW FROM MODEL-------------");


for (var id in relationships) {
    if (relationships.hasOwnProperty(id)) {
        var relation = relationships[id];
       
        var relation_name = relation.name;
        var sourceId = relation.source;
        var targetId = relation.target;

        // Trouver la source et la cible dans nodes, network ou groups
        var sourceElement = nodes[sourceId] || network[sourceId] || groups[sourceId];
        var targetElement = nodes[targetId] || network[targetId] || groups[targetId];

        console.log("Name: "+relation_name+" Relation ID: " + id + ", Source ID: " + sourceId + ", Target ID: " + targetId);

        if (sourceElement) {
            console.log("Source Element: " + sourceElement.name + " (" + sourceElement.type + ")");
        } else {
            console.log("Source element not found for ID: " + sourceId);
        }

        if (targetElement) {
            console.log("Target Element: " + targetElement.name + " (" + targetElement.type + ")");
        } else {
            console.log("Target element not found for ID: " + targetId);
        }
    }
    console.log("\n");
}

Phil Beauvoir

> I'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?

If you want to get the underlying concept for a visual object you can access it with:
object.concept
See https://github.com/archimatetool/archi-scripting-plugin/wiki/Visual-Objects#concept
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Ok, there is a fundamental misunderstanding on how jArchi API works, which lead to non-needed code and complexity (Btw, don't worry, such misunderstanding is quite frequent).

Most of your 'get_something_from_xxx' function are not needed because jArchi returns a collection which is itself a list of objects.

For example:
var nodes = get_object_from_model("element","node");
Is really only:
var nodes = $("node");
Which in turn makes it easy to rewrite this:
for (var id in nodes) {
    if (nodes.hasOwnProperty(id)) {
        var node = nodes[id];
        console.log("Node ID: " + id + ", Name: " + node.name + ", Type: " + node.type);
    }
}

to this:
nodes.each(function(node) {
  console.log("Node ID:" + node.id + ", Name: " + node.name + ", Type: " + node.type);
});

And because (in this example) node is really a collection (i.e. a list) of object, you can then use them to navigate the model. Based on the previous code sample, let's imagine you want, for each node, to list incoming flow relationships and print the other end, you'll end up with this:
nodes.each(function(node) {
  console.log("Node " + node.name + " has the following remote ends:");
  $(node).inRels("flow-relationship").sourceEnds().each(function(end) {
    console.log("- [" + end.id + "] " + end.name + " (" + end.type + ")");
  });
});

Quote from: Azix on April 03, 2024, 10:37:12 AMI'm trying to get the relationships from a view but how do I get the right ids between the view and the objects models?

When iterating on a view content, what you get is a collection of visual objects which have their own attributes (such as position and colors), but also act as a "pass-through" to access underlying model concept's type and properties. When navigating using such visual objects as input, the navigation is limited to the view. If you want to navigate the model, then you have to get the underlying concept using the ".concept" attribute of visual objects.

Here's an example based on previously shared code snippets... Let's imagine that the list of nodes doesn't come from the model but from a view, but you still want to list incoming relationships's ends as defined in the model (not the view):
var view = $("view.ViewName").first(); // Get view from its name (pick the first one if multiple views share the same name)
//var view = selection.parents().add(selection).filter("view").first(); // Another option: get the selected view, or the one containing the selected visual object

var nodes = $(view).find("node"); // Build a collection containing the view, and then get all nodes in this view. Note: 'nodes' is a collection of Visual Objects

nodes.each(function(node) { // Note: 'node' is a Visual Object
  console.log("Node " + node.name + " has the following remote ends:"); // we can still access the name attribute through the visual object
  $(node.concept).inRels("flow-relationship").sourceEnds().each(function(end) { // by using 'node.concept' we switch to the underlying model element
    console.log("- [" + end.id + "] " + end.name + " (" + end.type + ")");
  });
});


Hope this helps.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Azix

hi, ohhh I see a bit clearer, thanks for the examples ;D

I've started to do this, does it seem consistent with the view I have or can I simplify the code even more?

console.log("----------GET OBJECT NODE FROM MODEL------------");
var nodes = $("node");
console.log(nodes);

console.log("----------GET VIEW------------");
var view = $(".5-Prod").first(); // Get view from its name (pick the first one if multiple views share the same name)

var flowRelationship = $(view).find("flow-relationship"); // Build a collection containing the view, and then get all flow-relationship in this view.
var compositionRelationship = $(view).find("composition-relationship"); // Build a collection containing the composition-relationship, and then get all flow-relationship in this view.
console.log(flowRelationship);
flowRelationship.each(function(flowRelationship) {
console.log("Relation " + flowRelationship.concept.name + ""); // we can still access the name attribute through the visual object
console.log(flowRelationship.prop("port")); // get port of the relation
console.log(flowRelationship.concept.source.id); // get source id of the relation
console.log(flowRelationship.concept.target.id); // get target id of the relation
console.log(flowRelationship.concept.documentation); // get documentation of the relation
console.log("Source"+$("#"+flowRelationship.concept.source.id)); // get source object of the relation
console.log("Target"+$("#"+flowRelationship.concept.target.id)); // get target object of the relation

if ($("#"+flowRelationship.concept.source.id)
[o].type == "technology-interface") { // if source is a technology-interface
    compositionRelationship.each(function(compositionRelationship) { // get all composition-relationship
        if (compositionRelationship.concept.target.id == $("#"+flowRelationship.concept.source.id)
[o].concept.id) { // if target of the composition-relationship is the source of the flow-relationship
            console.log(" Source: " + compositionRelationship.concept.source.id + " Target: " + compositionRelationship.concept.target.id); // get source and target of the composition-relationship
            console.log($("#"+compositionRelationship.concept.source.id)
[o].name); // get name of the source of the composition-relationship
        }           
    }
    );
}

console.log("\n");
});