Support Support Downloads Knowledge Base Apex Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[Contrail] How to list all VN under specific projects using query parameters

0

0

Article ID: KB37209 KB Last Updated: 01 Aug 2021Version: 1.0
Summary:

Contrail API provides many query parameters which allows flexibility while running a query with a curl command. This article explains how this works. 

Symptoms:

Listing all VNs in Contrail is easy. However, VNs from all projects are mixed. When the configuration data grows, it is difficult to count VNs by project names.

user@testABC:~# curl -su admin:Juniper "localhost:8095/virtual-networks" | python -mjson.tool
{
    "virtual-networks": [
        {
            "fq_name": [
                "default-domain",
                "demo",
                "demo-vn"
            ],
            "href": "http://localhost:8095/virtual-network/19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e",
            "uuid": "19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e"
        },
        {
            "fq_name": [
                "default-domain",
                "default-project",
                "ip-fabric"
            ],
            "href": "http://localhost:8095/virtual-network/6f68790a-a6cd-4c5b-8649-5040d0d5d095",
            "uuid": "6f68790a-a6cd-4c5b-8649-5040d0d5d095"
        },
        {
            "fq_name": [
                "default-domain",
                "default-project",
                "default-virtual-network"
            ],
            "href": "http://localhost:8095/virtual-network/73058b51-9e49-4305-ba0f-941f57ee896e",
            "uuid": "73058b51-9e49-4305-ba0f-941f57ee896e"
        },
        {
            "fq_name": [
                "default-domain",
                "default-project",
                "__link_local__"
            ],
            "href": "http://localhost:8095/virtual-network/79e4eae3-aa83-4e1a-9530-bdd374fc1620",
            "uuid": "79e4eae3-aa83-4e1a-9530-bdd374fc1620"
        },
        {
            "fq_name": [
                "default-domain",
                "demo",
                "shared-vn"
            ],
            "href": "http://localhost:8095/virtual-network/805a59f8-53d0-4e20-958e-921df7860e38",
            "uuid": "805a59f8-53d0-4e20-958e-921df7860e38"
        }
    ]
}
Solution:

Add 'parent_fq_name_str' and 'parent_type' parameters into a query to filter the output. Then VNs can be seen under specific projects.

The value of parameter 'parent_fq_name_str' should be fqname of the project, and the value of 'parent_type' should be 'project'.

Example:

user@testABC:~# curl -su admin:Juniper "localhost:8095/virtual-networks?parent_fq_name_str=default-domain:demo&parent_type=project" | python -mjson.tool
{
    "virtual-networks": [
        {
            "fq_name": [
                "default-domain",
                "demo",
                "demo-vn"
            ],
            "href": "http://localhost:8095/virtual-network/19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e",
            "uuid": "19a47c0e-6b40-4ff6-9e1a-8c7c21af4c8e"
        },
        {
            "fq_name": [
                "default-domain",
                "demo",
                "shared-vn"
            ],
            "href": "http://localhost:8095/virtual-network/805a59f8-53d0-4e20-958e-921df7860e38",
            "uuid": "805a59f8-53d0-4e20-958e-921df7860e38"
        }
    ]
}
Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search