PyContracts error

789 views
Skip to first unread message

Raphael Ribeiro

unread,
Jun 11, 2015, 8:47:16 PM6/11/15
to opensta...@googlegroups.com
Hi Anton, can you help me with this error?

it happens when I try start neat services


./all-start.sh

Traceback (most recent call last):
  File "./compute-data-collector-start.py", line 17, in <module>
    from neat.config import *
  File "/root/openstack-neat/neat/config.py", line 19, in <module>
    from contracts import contract
ImportError: cannot import name contract
Starting openstack-neat-global-manager (via systemctl):    [  OK  ]
Starting openstack-neat-db-cleaner (via systemctl):        [  OK  ]
Traceback (most recent call last):
  File "./compute-local-manager-start.py", line 17, in <module>
    from neat.config import *
  File "/root/openstack-neat/neat/config.py", line 19, in <module>
    from contracts import contract
ImportError: cannot import name contract


PyContracts INSTALLED: 1.7.6 (latest)


Thanks!


--
Raphael Pereira Ribeiro

Anton Beloglazov

unread,
Jun 12, 2015, 12:41:57 AM6/12/15
to opensta...@googlegroups.com
Hi Raphael,

Please check that PyContracts is installed for Python 2, as there can be two Python versions installed at the same time. OpenStack Neat uses Python 2. The error clearly says that the PyContracts is unavailable for import on that machine for whatever reason.

Best regards,
Anton 

--
You received this message because you are subscribed to the Google Groups "OpenStack Neat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openstack-nea...@googlegroups.com.
Visit this group at http://groups.google.com/group/openstack-neat.
For more options, visit https://groups.google.com/d/optout.

Raphael Ribeiro

unread,
Jun 13, 2015, 12:27:03 AM6/13/15
to opensta...@googlegroups.com
Hi Anton, thanks for help. I solved the problem by uninstalling and installing PyContracts as follows:

pip uninstall PyContracts
pip2 install PyContracts

(CentOS 7)

But there was another problem:

# cat /var/log/neat/global-manager-service.log 
...
File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1045, "Access denied for user 'neat'@'10.0.4.254' (using password: YES)"

(https://gist.github.com/raphapr/b1fb42df59c552ee227c)

neat.conf:

sql_connection = mysql://neat:pass...@10.0.4.254/neat

I tried with "root:password@localhost/neat", "neat:password@controller/neat" and other variations.

do you have any idea for this problem? thanks!

--
Raphael Pereira Ribeiro
Instituto de Computação - IC/UFAL
Graduando em Ciências da Computação

Raphael Ribeiro

unread,
Jun 13, 2015, 6:12:18 PM6/13/15
to opensta...@googlegroups.com
after do this, that error occurs:

sqlalchemy.exc.OperationalError: (_mysql_exceptions.OperationalError) (1050, "Table 'host_states' already exists") [SQL: u'\nCREATE TABLE host_states (\n\tid INTEGER NOT NULL AUTO_INCREMENT, \n\thost_id INTEGER NOT NULL, \n\ttimestamp DATETIME, \n\tstate INTEGER NOT NULL, \n\tPRIMARY KEY (id), \n\tFOREIGN KEY(host_id) REFERENCES hosts (id)\n)\n\n']

(https://gist.github.com/raphapr/b1fb42df59c552ee227c#file-neat-log-2)

Anton Beloglazov

unread,
Jun 13, 2015, 9:51:04 PM6/13/15
to opensta...@googlegroups.com
Hi Raphael,


Best regards,
Anton

Raphael Ribeiro

unread,
Jun 14, 2015, 2:21:15 PM6/14/15
to opensta...@googlegroups.com
Hi Anton,

I dont know what I did, the error disappeared when I reboot all machines. But a new problem was appeared


cat /var/log/neat/global-manager-service.log


Traceback (most recent call last):
  File "/usr/bin/neat-global-manager", line 9, in <module>
    load_entry_point('openstack-neat==0.1', 'console_scripts', 'neat-global-manager')()
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/globals/manager.py", line 178, in start
    state['compute_hosts'])
  File "<string>", line 2, in switch_hosts_on
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/globals/manager.py", line 892, in switch_hosts_on
    db.insert_host_states(dict((x, 1) for x in hosts))
  File "<string>", line 2, in insert_host_states
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/db.py", line 320, in insert_host_states
    for k, v in hosts.items()]
KeyError: 'compute02'

neat.conf line:

compute_hosts = compute01, compute02, compute03

I tried to put them in quotes, but nothing changes.

Thanks!

Anton Beloglazov

unread,
Jun 17, 2015, 10:06:34 PM6/17/15
to opensta...@googlegroups.com
Hi Raphael,

This might happen if the global manager is started before the data collectors. Try to start all the data collectors and local managers first, so that the information about the compute hosts is added to the DB. Then, start the global manager. Sorry, this is not robust and definitely can be improved.

Best regards,
Anton

Raphael Ribeiro

unread,
Jun 18, 2015, 1:58:11 PM6/18/15
to opensta...@googlegroups.com
Hi Anton,

I started the services as follows:

./compute-data-collector-start.py
./compute-local-manager-start.py
python start-global-manager.py (or: service openstack-neat-global-manager start)

but still same error.

the error may be related to OpenStack configuration? I used packstack to install OpenStack and didn't use hostnames in config files, only ip address.

Anyway, here is my /etc/hosts:

------

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# controller
10.0.4.188     controller

# compute01
10.0.4.229     compute01 compute01.novalocal

# compute02
10.0.4.232     compute02 compute02.novalocal

# compute03
10.0.4.233     compute03 compute03.novalocal

-------


the other neat services seem to start well, I'm having only problems with global manager.

I would like to know what CentOS version you used to neat.

Thanks for help!

Raphael Ribeiro

unread,
Jun 23, 2015, 1:35:46 AM6/23/15
to opensta...@googlegroups.com
Hi Anton, I reinstalled openstack and openstack-neat several times and the error is always the same:


cat /var/log/neat/global-manager-service.log
Traceback (most recent call last):
  File "/usr/bin/neat-global-manager", line 9, in <module>
    load_entry_point('openstack-neat==0.1', 'console_scripts', 'neat-global-manager')()
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/globals/manager.py", line 178, in start
    state['compute_hosts'])
  File "<string>", line 2, in switch_hosts_on
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/globals/manager.py", line 892, in switch_hosts_on
    db.insert_host_states(dict((x, 1) for x in hosts))
  File "<string>", line 2, in insert_host_states
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/db.py", line 320, in insert_host_states
    for k, v in hosts.items()]
KeyError: 'compute03'

looking at the database, I found it:

+----+---------------------+---------+-----------+------+
| id | hostname | cpu_mhz | cpu_cores | ram  |
+----+---------------------+---------+-----------+------+
|  1 | compute01                |   11700 |          4 | 7824 |
|  2 | compute02                |   11700 |          4 | 7824 |
|  3 | compute03.novalocal |   11700 |          4 | 7824 |
+----+---------------------+---------+-----------+------+

However, this is my neat config line:


compute_hosts = compute01, compute02, compute03

I didn't understand why the neat took the host "compute03.novalocal" instead "compute03", do you know?

Maybe the neat is not configured to handle dots in hostnames? If not, can you patch it?

Thank you for the patience!

Anton Beloglazov

unread,
Jun 23, 2015, 1:42:26 AM6/23/15
to opensta...@googlegroups.com
Hi Raphael,

This table is populated based on the real hostnames obtain from the machines themselves. The fact that for your compute03 host the entry is compute03.novalocal means that this is the real hostname of that machine. Try to run "hostname" on your compute03. If it outputs "compute03.novalocal", you should then just update your /etc/hostname config on that machine to set it to compute03.

Best regards,
Anton

Raphael Ribeiro

unread,
Jun 23, 2015, 3:17:33 AM6/23/15
to opensta...@googlegroups.com
Thanks Anton!! It works!

How I solved:

packstack changes compute hostnames, respectively, to compute01.novalocal,  compute02.novalocal and compute03.novalocal. So I change /etc/hostname and /etc/nova/nova.conf for each compute node:

Example:

/etc/hostname
compute01

/etc/nova/nova.conf
vncserver_proxyclient_address=compute01



Anton Beloglazov

unread,
Jun 23, 2015, 3:24:27 AM6/23/15
to opensta...@googlegroups.com
Great! I'm glad you've solved it!

Best regards,
Anton

Raphael Ribeiro

unread,
Jun 24, 2015, 2:55:33 AM6/24/15
to opensta...@googlegroups.com
Hi Anton, do you know this error?

it happens when I create an instance on any compute node.

cat /var/log/neat/local-manager-service.log

Traceback (most recent call last):
  File "/usr/bin/neat-local-manager", line 9, in <module>
    load_entry_point('openstack-neat==0.1', 'console_scripts', 'neat-local-manager')()
  File "<string>", line 2, in start

  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/locals/manager.py", line 142, in start
    int(interval))
  File "<string>", line 2, in start

  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/common.py", line 63, in start
    state = execute(config, state)
  File "<string>", line 2, in execute

  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/locals/manager.py", line 264, in execute
    overload_detection_params])
  File "<string>", line 2, in call_function_by_name

  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 280, in contracts_checker
    result = function_(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/common.py", line 225, in call_function_by_name
    m = __import__(module, fromlist=fromlist)
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/locals/overload/mhod/core.py", line 23, in <module>
    import neat.locals.overload.mhod.bruteforce as bruteforce
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/locals/overload/mhod/bruteforce.py", line 22, in <module>
    import nlp
  File "/usr/lib/python2.7/site-packages/openstack_neat-0.1-py2.7.egg/neat/locals/overload/mhod/nlp.py", line 28, in <module>
    @contract
  File "/usr/lib/python2.7/site-packages/contracts/__init__.py", line 24, in contract
    return contract_decorator(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 146, in contract_decorator
    return contracts_decorate(function, **kwargs)
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 236, in contracts_decorate
    accepts_dict, returns = parse_contracts_from_docstring(function_)
  File "/usr/lib/python2.7/site-packages/contracts/main.py", line 405, in parse_contracts_from_docstring
    raise ContractException(msg)
contracts.interface.ContractException: A contract was specified for argument 'state-vector' which I cannot find in my list of arguments (['ls', 'state_vector', 'p']

Anton Beloglazov

unread,
Jun 29, 2015, 3:27:02 PM6/29/15
to opensta...@googlegroups.com
Hi Raphael,

Could you please try renaming all occurrences of 'state-vector' to 'state_vector' in neat/locals/overload/mhod/nlp.py? I think that should fix the problem.

Thanks,
Anton

Anton Beloglazov

unread,
Jul 21, 2015, 2:25:29 PM7/21/15
to opensta...@googlegroups.com
Hi Raphael,

I've a made a change that should fix that last issues with contracts.

Cheers,
Anton

Raphael Ribeiro

unread,
Jul 26, 2015, 11:16:44 PM7/26/15
to opensta...@googlegroups.com
Thanks Anton!
Reply all
Reply to author
Forward
0 new messages