Last active
September 29, 2016 15:22
-
-
Save ahsan518/dc99f01be3f450b15270c1631f39ddb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@vagrant-ubuntu-trusty-64:~/craton$ python craton/cmd/inventory-api.py --config-file=etc/inventory-api-conf.sample | |
2016-09-26 16:42:47.673 30307 INFO craton.api [-] Loading service with WSGI config: /home/vagrant/craton/etc/inventory-api-paste.ini | |
2016-09-26 16:42:47.738 30307 INFO __main__ [-] Starting API server in PID: 30307 | |
2016-09-26 16:42:50.088 30307 DEBUG oslo_db.api [-] Loading backend 'sqlalchemy' from 'craton.db.sqlalchemy.api' _load_backend /usr/local/lib/python2.7/dist-packages/oslo_db/api.py:238 | |
2016-09-26 16:42:50.274 30307 DEBUG passlib.utils.compat [-] loaded lazy attr 'SafeConfigParser': <class ConfigParser.SafeConfigParser at 0x7f6ef20a37a0> __getattr__ /usr/local/lib/python2.7/dist-packages/passlib/utils/compat.py:413 | |
2016-09-26 16:42:50.275 30307 DEBUG passlib.utils.compat [-] loaded lazy attr 'NativeStringIO': <built-in function StringIO> __getattr__ /usr/local/lib/python2.7/dist-packages/passlib/utils/compat.py:413 | |
2016-09-26 16:42:50.277 30307 DEBUG passlib.utils.compat [-] loaded lazy attr 'BytesIO': <built-in function StringIO> __getattr__ /usr/local/lib/python2.7/dist-packages/passlib/utils/compat.py:413 | |
2016-09-26 16:42:50.390 30307 DEBUG oslo_db.sqlalchemy.engines [-] MySQL server mode set to STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION _check_effective_sql_mode /usr/local/lib/python2.7/dist-packages/oslo_db/sqlalchemy/engines.py:261 | |
127.0.0.1 - - [26/Sep/2016 16:42:50] "GET /v1/regions HTTP/1.1" 200 58 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keystoneclient import session as ksc_session | |
from keystoneclient.auth.identity import v3 | |
from keystoneclient.v3 import client as keystone_v3 | |
from cratonclient.v1.client import Client | |
from cratonclient import session as c_session | |
auth = v3.Password(auth_url='http://10.0.2.15:5000/v3', username = 'admin', password = 'secret', project_name = 'admin', user_domain_id = 'default', project_domain_id = 'default') | |
session = ksc_session.Session(auth=auth) | |
craton = Client(session=c_session.Session(session), url='127.0.0.1:8083/v1/') | |
craton.inventory(1).hosts.create(**{'name':'test', 'project_id':1,'ip_address':'1.1.1.1', 'region_id':1, 'device_type':'test'}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@vagrant-ubuntu-trusty-64:~/python-cratonclient/cratonclient/shell$ sudo python sampl.py | |
Traceback (most recent call last): | |
File "sampl.py", line 8, in <module> | |
craton = Client(session=c_session.Session(session), url='127.0.0.1:8083/v1/') | |
File "/usr/local/lib/python2.7/dist-packages/cratonclient/session.py", line 65, in __init__ | |
old_user_agent = self._session.headers['User-Agent'] | |
AttributeError: 'Session' object has no attribute 'headers' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the Craton Host to run, i had to comment line 99-100 for craton/db/sqlalchemy/api.py i.e.
https://github.com/openstack/craton/blob/26c0dd5d8e5ea55c205ef0b325be3f0b43a6d871/craton/db/sqlalchemy/api.py
if project_only and not context.is_admin:
kwargs['project_id'] = context.tenant
Since, this i believe is cargo culted code.