utils: net_policy_join.py script is broken

Bug #1406857 reported by Hampapur Ajay
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Juniper Openstack
Fix Committed
Undecided
Hampapur Ajay

Bug Description

Reported by Aki-san:

Hello Experts,

I had a query from one of our partner asking for how to create and assign policy to existing virtual networks from CLI.
I found /opt/contrail/ net_policy_join.py and tested by running it alone from linux command prompt. It did not work with contrail 1.2 Icehouse environment.
Correct me if I am wrong but the below is the change I made to avoid errors.

Error indicates the policy name contains characters that is not allowed.
In the following line, get_fq_name_str() returns ‘:’ separated fqn and it causes the error.

'policy-%s-%s-any' % (net1.get_fq_name_str(), net2.get_fq_name_str()),

So, I took only network name part like below.
net1.get_fq_name_str().rsplit(':',1)[-1]

The next issue is what I am not confident at all because I ran it alone from linux prompt by providing network UUID, not called from other python program that contains contrail project information.
After fixing the above, found one more issue that the policy was created in default-domain:default-project.
It is because
pol1 = vnc_api.NetworkPolicy(
does not provide domain as its parameter.

So, I added it like below and it worked fine finally.
pol1 = vnc_api.NetworkPolicy(
    'policy-%s-%s-any' % (net1_name, net2_name), vnc_lib.project_read(fq_name = net1.get_parent_fq_name()),

It looks ok though, but I am not confident since I am very new to API and even python, so would like to ask experts for verification.

Best Regards,
Aki

Hampapur Ajay (hajay)
Changed in juniperopenstack:
assignee: nobody → Hampapur Ajay (hajay)
Revision history for this message
OpenContrail Admin (ci-admin-f) wrote : A change has been merged

Reviewed: https://review.opencontrail.org/5979
Committed: http://github.org/Juniper/contrail-controller/commit/055238c4475064cb4c1204c55ba2d9bf12b1cc83
Submitter: Zuul
Branch: master

commit 055238c4475064cb4c1204c55ba2d9bf12b1cc83
Author: Hampapur Ajay <email address hidden>
Date: Wed Dec 31 23:18:09 2014 -0800

Fix script to deal with multi-tenancy and use just net names in policy.

Assumes net1/net2 are in same project.

Change-Id: I84fd054fafae018837ecd2609d677a410c363e53
Closes-Bug: #1406857

Changed in juniperopenstack:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.