Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - nso-nipap rewrite #1049

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open

Conversation

fredsod
Copy link
Member

@fredsod fredsod commented Sep 20, 2016

This is almost a complete rewrite of the nso-nipap cdb subscriber.

Todo:

  • Add tests
  • Add support for remove from-prefix-requests
  • Add README
  • Add static methods for prefix requests (API)

Copy link
Member

@plajjan plajjan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the indent. It's difficult to follow the code flow when I have to compensate for incorrect indent. I'll review more once that is fixed :)

private int th = -1;
private NavuContainer ncsRoot;
private NavuContainer operRoot;
private int th = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent?

*
* @param path Path to the prefix request
* @param parentPrefix From prefix
* @throws Exception
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we be a bit more specific about the exceptions?

try {

AddPrefixOptions child_opts = new AddPrefixOptions();
child_opts.put("prefix_length", "32");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 sounds like IPv4... shouldn't this at least be based on AFI?

{
Prefix p = oldPrefix;

if (maapi.exists(th, attributePath + "/" + nipap._customer_id_)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent here seems real messed up

/**
* Fetch attributes and returns the populated prefix object
*
* @param oldPrefix Used if you already have a prefix object
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the deal with oldPrefix ? Why is this used? Why do we ever want reuse of these objects?

ConfUInt32 prefixIdValue = new ConfUInt32(prefix.id);
wsess.setElem(prefixIdValue, responsePath + "/" + nipap._prefix_id_);

if(prefix.customer_id != null){
Copy link
Member

@plajjan plajjan Sep 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

space between if and (
fix similar below

* @throws Exception
*/
protected int getPrefixId(String path) throws Exception {
return (int) ((ConfUInt32)wsess.getElem(path + "/" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loss of precision here, right? Why not use a long throughout?

poolSpec.put("name", poolName);
List poolRes = Pool.list(nipapCon, poolSpec);

if(poolRes.size() < 1){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for != 1. No risk of getting 2 or more now but if someone changes the poolSpec code above there is a risk. No reason not to check for exactly one.

try {

AddPrefixOptions child_opts = new AddPrefixOptions();
child_opts.put("prefix_length", "32");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably not hard-code prefix lengths to 32.

tailf:persistent true;
}

choice response-choice {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like somewhat of an anti-pattern to me. Better have a leaf for status, it can be an enum or something with "ok", "error" or whatever. Then you have a separate leaf that contains the error message. Right now you don't even have a leaf under the "ok" case so there's nothing there to read which is über weird ;) because you can't go to one single path and get the status, you have to probe around

fredsod and others added 3 commits January 23, 2017 09:28
Added templates for creating NIPAP allocation requests.
Added python helper functions for creating NIPAP requests.
Python helpers for creating NIPAP requests
attributes['node'] if 'node' in attributes else '-1')

template_vars.add('ORDER_ID',
attributes['order_id'] if 'order_id' in attributes else '-1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

attributes['description'] if 'description' in attributes else '-1')

template_vars.add('NODE',
attributes['node'] if 'node' in attributes else '-1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

attributes['customer_id'] if 'customer_id' in attributes else '-1')

template_vars.add('DESCRIPTION',
attributes['description'] if 'description' in attributes else '-1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

"""

template_vars.add('CUSTOMER_ID',
attributes['customer_id'] if 'customer_id' in attributes else '-1')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

if from_prefix_allocation_name not in alloc.from_prefix_request:
return None

from_pref_alloc = alloc.from_prefix_request[from_prefix_allocation_name]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (80 > 79 characters)

Arguments:
root -- a maagic root for the current transaction
pool_name -- name of pool to request from
main_allocation_name -- name of allocation which the from-prefix allocation belongs to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (94 > 79 characters)

return None


def from_prefix_read(root, pool_name, main_allocation_name, from_prefix_allocation_name):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (89 > 79 characters)

Arguments:
service -- the requesting service node
pool_name -- name of pool to request from
main_allocation_name -- name of main allocation which the from-prefix is appended to

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (92 > 79 characters)



def from_prefix_request(service, pool_name, main_allocation_name,
from_pref_allocation_name, prefix_attributes=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent



def prefix_request(service, svc_xpath, pool_name, allocation_name,
prefix_length, family=4, prefix_attributes=None):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line under-indented for visual indent

garberg and others added 5 commits April 5, 2017 08:53
Improve error handling in nso-nipap to avoid locking CDB on certain
failures, for example when unable to communicate with the NIPAP backend.
Certain errors caused exceptions to be thrown which were not handled
within the request loop which caused sub.sync() to never be run.
Improve error handling to avoid CDB lockup
Pass the path to re-deploy as a ConfPath-object rather than as a String.
From some reason the string, which is extracted directly from CDB, can't
be parsed by the ConfPath-constructor.
nso-nipap: Pass re-deploy path as ConfPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants