rvojcik / rt-server-client

Server discovery client for RackTables project. Do automatic server discovery and send information to racktables database.
GNU General Public License v3.0
27 stars 8 forks source link

DB Insertion Fails Foreign Key Constraint #18

Closed conseev closed 5 years ago

conseev commented 5 years ago

[DEBUG] Inserting CPU attribute information Traceback (most recent call last): File "./system-info.py", line 419, in rtobject.InsertAttribute(object_id,server_type_id,rtobject.GetAttributeId("CPUs Logical"),"NULL",cpu_logical_num,hostname) File "/usr/lib/python2.7/site-packages/rtapi/init.py", line 353, in InsertAttribute self.db_insert(sql) File "/usr/lib/python2.7/site-packages/rtapi/init.py", line 77, in db_insert self.dbresult.execute(sql) File "/usr/lib64/python2.7/site-packages/MySQLdb/cursors.py", line 205, in execute self.errorhandler(self, exc, value) File "/usr/lib64/python2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (inventor_rt.AttributeValue, CONSTRAINT AttributeValue-FK-map FOREIGN KEY (object_tid, attr_id) REFERENCES AttributeMap (objtype_id, attr_id))')

RackTables 0.20.11

conseev commented 5 years ago

I was able to get past this with:

ALTER TABLE AttributeValue DROP FOREIGN KEY AttributeValue-FK-map;

However, there still seems to be incompatibilities with this API and the version of RackTables. Output of the script with debug mode:

[DEBUG] STARTING MAIN DATABASE INSERTION/UPDATE [DEBUG] Service tag not exist in database [DEBUG] Added new object to database ['atl1kvm808', 4, '64902500753f', ''] with ID 523 [DEBUG] SW Type, searching for: centos%Core , Found: None, Updating: 4 [DEBUG] OS id not found in racktables [DEBUG] HW Type, searching for: Supermicro%X8DTL , Found: None, Updating: 2 [DEBUG] HW id not found in racktables [DEBUG] Inserting CPU attribute information [DEBUG] Hypervisor, searching for: Hypervisor , Found: 26 [DEBUG] Inserting installation date: 1572871262.27

RackTables object only ultimately contains:

Common name: atl1kvm808

Server 64902500753f Intel(R) Xeon(R) CPU E5645 @ 2.40GHz Yes

Most metadata never made it in even though the attributes were added in Configuration.

rvojcik commented 5 years ago

Hi, thank you for reaching out to me. I know about this. It's because you need add some attributes do racktables which not there by default. You have to add adribude in configuration and attach this attribute to the Server object. You will need at least this:

I want to create initialization script for this but I completely forgot.

On Mon, 4 Nov 2019 at 13:45, conseev notifications@github.com wrote:

I was able to get past this with:

ALTER TABLE AttributeValue DROP FOREIGN KEY AttributeValue-FK-map;

However, there still seems to be incompatibilities with this API and the version of RackTables. Output of the script with debug mode:

[DEBUG] STARTING MAIN DATABASE INSERTION/UPDATE [DEBUG] Service tag not exist in database [DEBUG] Added new object to database ['atl1kvm808', 4, '64902500753f', ''] with ID 523 [DEBUG] SW Type, searching for: centos%Core , Found: None, Updating: 4 [DEBUG] OS id not found in racktables [DEBUG] HW Type, searching for: Supermicro%X8DTL , Found: None, Updating: 2 [DEBUG] HW id not found in racktables [DEBUG] Inserting CPU attribute information [DEBUG] Hypervisor, searching for: Hypervisor , Found: 26 [DEBUG] Inserting installation date: 1572871262.27

RackTables object only ultimately contains: Common name: atl1kvm808 Server 64902500753f Intel(R) Xeon(R) CPU E5645 @ 2.40GHz Yes

Most metadata never made it in even though the attributes were added in Configuration.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rvojcik/rt-server-client/issues/18?email_source=notifications&email_token=AAIHYOKAOFAWAELSJIOFX2TQSAKOHA5CNFSM4JIL4NRKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC7DQ6Y#issuecomment-549337211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIHYOIJ3DEOYZR5LBXL2RDQSAKOHANCNFSM4JIL4NRA .

-- Róbert Vojčík email: robert@vojcik.net

rvojcik commented 5 years ago

I will prepare initialization script for whis. You run it once after you install racktables, and it's add all necessary attributes.

rvojcik commented 5 years ago

Example:

Selection_012

conseev commented 5 years ago

Yes, I think this will be necessary to have initialization script thanks,

rvojcik commented 5 years ago

I have a beta version of the script, but I decided to do bigger redesign od the SW. I think it maybe out during the week or two.

rvojcik commented 5 years ago

This is done, will be in release 0.3.0

Use system-info -d --init

rvojcik commented 5 years ago

Release is out. Use only python 3

pip3 install rt-server-client
<create configuration in /etc/rt-server-client/main.conf>
system-info -d --init
system-info -d