Skip to content
This repository has been archived by the owner on Apr 27, 2022. It is now read-only.

Client Library HIL | query calls #617

Merged
merged 84 commits into from
Apr 24, 2017

Conversation

SahilTikale
Copy link
Contributor

Current PR, includes the basic code structure required to built a client library for HIL.
It also includes client library support for all query calls.

Still pending:
Unit tests for the new code.
Making correspondng cli calls to go via Client library.

@zenhack
Copy link
Contributor

zenhack commented Jul 8, 2016

@SahilTikale, you'll need to work in the changes from #618.

Also, could you go over this for style issues? Lots of PEP8/PEP257 violations here. please make sure you've read those documents and understood them, and follow the guidelines. The codebase is full of deviations in general, but let's not make it worse.

Additionally, if you're using vim, I reccomend python-mode, which will warn you about a lot of these issues, plus things like unused imports, and will add other nice python-aware stuff to your editor as well:

https://github.com/klen/python-mode

@gsilvis, @henn, can we prioritize the pep8 testing soonish?

@shuwens
Copy link
Contributor

shuwens commented Jul 9, 2016

I would point out that Emacs users could adopt py-yapf and YAPF is also interesting to look into.

@zenhack
Copy link
Contributor

zenhack commented Jul 10, 2016

yapf looks interesting; my experience with gofmt has been excellent, it would be great to have something like that for us. It's says the thing is still fairly immature though, so I'm worried about upgrading versions and then have my editor accidentally change a bunch of formatting without me having actually made any meaningful changes to the file. Even worse would be if two developers were using different versions of the tool, and kept thrashing, making surrious changes to the source...

I gave it a try and it made a few odd choices, e.g.

-        return model.NetworkAttachment.query.filter(
-            model.NetworkAttachment.nic == nic,
-            query,
-        ).count() != 0
+        return model.NetworkAttachment.query.filter(model.NetworkAttachment.nic
+                                                    == nic,
+                                                    query, ).count() != 0

...but nothing I think not worth tolerating to just not spend review time on formatting issues at all.

I'd want to verify we can rely on consistent output from release to release, but given that I love the idea of instituting this.

	1. Configure haas.cfg
	2. Instantiate the database
	3. Populate the database using dummy objects via restful requests
	4. Tear down the setup in a clean fashion.
@SahilTikale SahilTikale self-assigned this Aug 8, 2016
q = requests.get(url, headers={"Authorization": "Basic %s" %self.auth})
return q.json()


Copy link
Contributor

Choose a reason for hiding this comment

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

blank lines

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed it.

Copy link
Contributor

@shuwens shuwens left a comment

Choose a reason for hiding this comment

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

I go through the test/client file and it looks ok.

However, when I was trying to deploy it and use it in devhaas, I hit this error:

(.venv)[shwsun@hack-n-hil: haas (HILclientlib-querycalls)]$ ./devhaas 
+ haas switch_register dell-247 powerconnect55xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:5050 "PUT /switch/dell-247 HTTP/1.1" 200 0

+ haas switch_register cisco-1 nexus xxxxxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:5050 "PUT /switch/cisco-1 HTTP/1.1" 200 0

+ haas node_register sun-20 ipmi xxxxxxxxxxxxxxxxxxxxxxxxxxx
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:5050 "PUT /node/sun-20 HTTP/1.1" 200 0

+ haas port_register dell-247 gi1/0/21
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): 127.0.0.1
Error: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url: /switch/dell-247/port/gi1/0/21 (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x3cee990>: Failed to establish a new connection: [Errno 111] Connection refused',))

I also tried the currect haas and it is fine

def make_config():
""" This function creates haas.cfg with desired options
and writes to a temporary directory.
It returns a tuple where (tmpdir, cwd) = ('location of haas.cfg', 'pwdd')
Copy link
Contributor

Choose a reason for hiding this comment

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

typo pwdd

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like your configuration has some problems.
Is the server running on port 5000 or port 5050

DEBUG:requests.packages.urllib3.connectionpool:http://127.0.0.1:5050
or
Error: HTTPConnectionPool(host='127.0.0.1', port=5000): Max retries exceeded with url...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Create an init_client file with correct values for following parameters.

export HAAS_ENDPOINT=http://<ip address + port no. where haas server is running>
export HAAS_USERNAME=<authorized username>
export HAAS_PASSWORD=<password for that username>

source this init_client file in your environment as we normally do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching the typo, next commit fixes it.

@naved001
Copy link
Contributor

@shwsun you should edit your comment to hide login details in the error log. this page is public.

@shuwens
Copy link
Contributor

shuwens commented Apr 14, 2017

@naved001 good catch, thank you!

@zenhack
Copy link
Contributor

zenhack commented Apr 18, 2017

@naved001, @shwsun, I didn't catch what it was that got leaked, and I'm sure this goes without saying, but if there were credentials in there, change them.

… to the top of test file. corrects a typo in comment.
@SahilTikale
Copy link
Contributor Author

@zenhack, I believe I have addressed all your comments, let me know if anything else is needed.

@shuwens
Copy link
Contributor

shuwens commented Apr 18, 2017

@naved001, @shwsun, I didn't catch what it was that got leaked, and I'm sure this goes without saying, but if there were credentials in there, change them.

@zenhack The thing that naved pointed out were some ip addr/passwd that I included previously in my comment, those sensitive info were already gotten rid of.

time.sleep(1)
else:
break
return que
return timeout
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just raise an exception here (of a newly-declared type, which denotes a timeout), and get rid of the if/else checks elsewhere.

@zenhack
Copy link
Contributor

zenhack commented Apr 20, 2017

@SahilTikale, travis is failing. Given that it's just postgres I'm wondering whether 10 seconds is enough to be reliable, but I'm not totally sure what's going on.

Other than that I'm happy; get the tests passing reliably again and I'll approve.

@SahilTikale
Copy link
Contributor Author

@zenhack passes all the tests.
Time out is not a problem. sometimes it is not able to spin up the server on the designated port and that causes failures.

@SahilTikale
Copy link
Contributor Author

@shwsun only your approval is pending.

Let me know if you need me to address any issues.

@shuwens
Copy link
Contributor

shuwens commented Apr 21, 2017

@SahilTikale I see, could you be around sometime tmr? I still have some questions on deployment

@naved001
Copy link
Contributor

@SahilTikale The tests are failing again. Probably due to the race condition thing you mentioned, it might even pass if we re-run this.

socket.error: [Errno 98] Address already in use

But I think we should reliably fix that test here, otherwise we would have a tough time with CI failing on future PRs.

@zenhack
Copy link
Contributor

zenhack commented Apr 21, 2017

@SahilTikale, I agree with @naved001; the tests need to pass reliably.

@SahilTikale
Copy link
Contributor Author

SahilTikale commented Apr 22, 2017

@naved001 the race condition was a different problem. There is a function that solves it reliably.
This is a different issue of not being able to find the port no to spin up the server and it is not that frequent.

@zenhack there is nothing to worry.

@SahilTikale
Copy link
Contributor Author

@shwsun I have addressed the issue we were discussing today.
Let me know if anything else is needed.

@SahilTikale
Copy link
Contributor Author

@shwsun I would like to get this PR merged if there is nothing else that you would want me to change.

Let me know if you need anything else.

@shuwens
Copy link
Contributor

shuwens commented Apr 24, 2017

I dont think I have any other more concerns. +1

@SahilTikale
Copy link
Contributor Author

SahilTikale commented Apr 24, 2017

@zenhack would you merge it (Yeahh, finally !!) or should I do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants