These are chat archives for allegro/ralph

28th
Sep 2016
Pete
@kasim1r
Sep 28 2016 08:58
trying "/api/base-objects/?limit=10&offset=0&sn__contains=91c471c8-234c-45d1" currently
always returns no results
Pete
@kasim1r
Sep 28 2016 09:04
does the sn field not support the __contains search?
Pete
@kasim1r
Sep 28 2016 09:11
__startswith also no success
OK, reading documents completely answers many question. using "__search" from now on :)
Pete
@kasim1r
Sep 28 2016 09:25
aaaaah, but hostname doesn't support __search
Mateusz Kurek
@mkurek
Sep 28 2016 09:28
but __contains should work (for both hostname and sn)
Pete
@kasim1r
Sep 28 2016 09:28
as I wrote above, __contains always return "count : 0"
for sn field
Pete
@kasim1r
Sep 28 2016 09:33
doesn't work for me
Mateusz Kurek
@mkurek
Sep 28 2016 09:33
do you have the newest version?
Pete
@kasim1r
Sep 28 2016 09:33
hm, how do i test?
Mateusz Kurek
@mkurek
Sep 28 2016 09:34
how did you install ralph?
Pete
@kasim1r
Sep 28 2016 09:35
like explained in the documentation, ubuntu 14.04 LTS
maybe apt-get upgrade?
Mateusz Kurek
@mkurek
Sep 28 2016 09:36
try dpkg -s ralph-core or sth like that
Pete
@kasim1r
Sep 28 2016 09:36
apt-get upgrade offers me a newer ralph-core, too.
bam, that failed
probably due to the damn environment variable thing?
Mateusz Kurek
@mkurek
Sep 28 2016 09:38
it's possible. what's the error?
Pete
@kasim1r
Sep 28 2016 09:38
Access denied for user 'ralph_ng'@'localhost
Mateusz Kurek
@mkurek
Sep 28 2016 09:39
hmm but upgrading ralph shouldn't require access to db
Pete
@kasim1r
Sep 28 2016 09:41
after appling environment variables, successful upgrade:
Setting up ralph-core (3.0.0-snapshot-20160923-7150) ...
Mateusz Kurek
@mkurek
Sep 28 2016 09:41
great
try api filtering now :)
Pete
@kasim1r
Sep 28 2016 09:42
folks, do you have a workin init script somewhere?
starting ralph with screen is somewhat... strange
Mateusz Kurek
@mkurek
Sep 28 2016 09:42
what do you mean by init?
oh i see
Pete
@kasim1r
Sep 28 2016 09:42
a startup script
that runs the daemon, at best not as "root", but regular user
Mateusz Kurek
@mkurek
Sep 28 2016 09:43
afair not, but any contribution here will be appreciated :)
Pete
@kasim1r
Sep 28 2016 09:49
no success :(
still count 0
GET /api/base-objects/?sn__contains=123
Mateusz Kurek
@mkurek
Sep 28 2016 09:50
try search by full sn first (?sn=xxxxx), then add __contains lookup (but still keeping full value) and see if it works
Pete
@kasim1r
Sep 28 2016 09:54
aha, searching for sn will find data center assets, but not VMs
although I tought that a virtual-server is also a base-object?
Mateusz Kurek
@mkurek
Sep 28 2016 09:57
yes - but the field is defined somewhere else than for data center asset - https://github.com/allegro/ralph/blob/ng/src/ralph/assets/api/views.py#L138 - sn field is looked up only for asset - maybe you could make PR with fix for virtual? probably need to add sth like virtualserver__sn to that list
Pete
@kasim1r
Sep 28 2016 10:25
what's a PR?
Mateusz Kurek
@mkurek
Sep 28 2016 10:27
pull request
Pete
@kasim1r
Sep 28 2016 10:27
don't know what that is ....
Pete
@kasim1r
Sep 28 2016 10:39
oh, I write code, then make a pull request, you look at the code and decide whether to pull the code or not?
`gee, I don't know... I'n not a developer, you know. Only a sysadmin
Mateusz Kurek
@mkurek
Sep 28 2016 10:40
exactly like you said :)
Pete
@kasim1r
Sep 28 2016 11:25
OK, once more... here's my problem.
I'm writing a search function that I'm calling from different points in my script
how do I build a search URL that ALWAYS works, with a fuzzy logic like "search" or "contains"
Do I have to try all searching logics for all object types?
then take not of these, in some sort of mathcing table?
like "searching for an ethernet -> use the mac, and use the contains logic."
"searching for a hypervisor -> use the hostname, use the search logic"
that's tedious
do you understand what I want to say?
Mateusz Kurek
@mkurek
Sep 28 2016 11:30
yes - and i'd use always __contains
Pete
@kasim1r
Sep 28 2016 11:31
I wanted to.
but for "ipaddresses", it doesn't work
GET /api/ipaddresses/?limit=10&offset=0&address__contains=10.13.53.61
returns 4 results
that's why I'm pulling my hair by now
Mateusz Kurek
@mkurek
Sep 28 2016 11:34
we could add __contains lookup to address
could you create an issue for that?
Pete
@kasim1r
Sep 28 2016 11:35
is this the piece of code that defines what I can search for?
Mateusz Kurek
@mkurek
Sep 28 2016 11:39
yes and no - here you define what fields do you want to filter by, but here you define lookups - and there is no lookup for ip address field
Pete
@kasim1r
Sep 28 2016 11:41
ok. when I started with the API, I understood that when I look at an object list, like /api/ipaddresses/, I can press the OPTIONS button, and will find the filter-able attributes at the bottom
(in the browser)
and OPTIONS /api/ipaddresses/ returns > "filtering": [
"status",
"is_public",
"networkaddress",
"ethernet
mac",
"hostname",
"ethernet__base_object",
"network",
"dhcp_expose",
"is_management",
"address"
]
Mateusz Kurek
@mkurek
Sep 28 2016 11:43
yes
Pete
@kasim1r
Sep 28 2016 11:43
so I thought, "address" is a field I use for searching. But I'm probably not comprehending the diefference between a lookup and a filter
Mateusz Kurek
@mkurek
Sep 28 2016 11:44
address is field, but contains is lookup
Pete
@kasim1r
Sep 28 2016 11:44
ah
Mateusz Kurek
@mkurek
Sep 28 2016 11:44
and you join it to get sth like address__contains
Pete
@kasim1r
Sep 28 2016 11:47
ok, so the only reliable thing that will really always work is the "=", without a lookup, but if people enter data incorretly, I might miss it while filtering, right?
cos that's why I started looking at __contains etc
Mateusz Kurek
@mkurek
Sep 28 2016 11:49
yes (but contains will not solve all your issues - it'll only match partial, but valid data - when someone make a typo the result will not be matched at all)
Pete
@kasim1r
Sep 28 2016 13:40
something different
pip install -r requirements/prod_ldap.txt
in the configuration document
Could not open requirements file: [Errno 2] No such file or directory: 'requirements/prod_ldap.txt'
prod_ldap.txt does not exist on my machine
Pete
@kasim1r
Sep 28 2016 13:45
where can I get that file
found it in your github
Pete
@kasim1r
Sep 28 2016 14:03
can you please adapt that part of the configuration document so that it reads
apt-get install libldap2-dev libsasl2-dev
pip install django-auth-ldap==1.2.7
also, that the settings file that needs to be changed is actually /opt/ralph/ralph-core/lib/python3.4/site-packages/django/conf/global_settings.py