rvojcik / rtapi Goto Github PK
View Code? Open in Web Editor NEWRacktables API
Home Page: https://rtapi.readthedocs.io
License: GNU General Public License v2.0
Racktables API
Home Page: https://rtapi.readthedocs.io
License: GNU General Public License v2.0
Great work so far, is there any plan to add the ability to link an object to rackspace?
Hi,
I really like the possibility to interact with the racktables database from Python.
However, I'm currently missing Location, Row and Rack data which are vital for the project I'm working on.
Would it be possible for you to add those?
Hope to hear from you,
Raymond
So I've installed racktables-api as shown:
lucas@lucas:~$ pip3 show racktables-api
Name: racktables-api
Version: 0.2.8
Summary: Simple racktables API
Home-page: https://github.com/rvojcik/rtapi
Author: Robert Vojcik
Author-email: [email protected]
License: GPLv2
Location: /usr/local/lib/python3.5/dist-packages
Requires:
Required-by:
However, cannot import it ...
lucas@lucas:~$ ipython3
Python 3.5.2 (default, Apr 16 2020, 17:47:17)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.9.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import rtapi
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-7c84d904841c> in <module>
----> 1 import rtapi
ImportError: No module named 'rtapi'
any hint? thanks!
There is type here causing this error:
_mysql_exceptions.ProgrammingError: (1146, "Table 'racktables.object' doesn't exist")
'object' should be capitalized -> 'Object' in the SQL query
def InsertOrUpdateAttribute(self, object_id, attr_id, new_value):
# Get the object type
sql = "SELECT objtype_id FROM object WHERE id = %d" % (object_id)
result = self.db_query_one(sql)
Hi!
I've seen there is a method called rt.GetObjectTags(id)
which provides all of the tags
assigned to a given object.
How difficult is it to implement the same but for the Attributes? The idea is to have a method that will list all of the attributes assigned to an object.
I have on my own some SQL queries that do the job. If interested, I can provide those ...
thanks!
If you accidentally try to put string data to uint attribute (or vice-versa) through InsertAttribute (new attribute, not existing one), it will happily pass it, put it in the DB, but you won't see it in the GUI so you can't remove it without touching the DB manually.
An attempt to rewrite it with the other type will fail, because it tries to detect based on the DB contents, so it will put it in the same wrong type. It needs some handling based on None in one of the two fields.
Hi!
Today I have some SQL queries that I use on my own to obtain one or all the objetcs that have such a tag
. Do you think it is feasible to implement it in the library? I can provide those queries if interested...
I've been seraching for the methods and I've found only rt.GetObjectTags(id)
. This would be the other way around: given a tag
obtain the list of object_id
.
thanks!
I tried the example code on the readme and I can't get it to work. Environment is:
Python 3.5.2
rtapi was installed via pip3
My file contains (credentials scrubbed):
import MySQLdb
import rtapi
# Create connection to database
try:
# Create connection to database
db = MySQLdb.connect(host='rthost',port=3306, passwd='passwd',db='racktables',user='rtuser')
except MySQLdb.Error:
e = sys.exc_info()[1]
print("Error %d: %s" % (e.args[0],e.args[1]))
sys.exit(1)
# Initialize rtapi with database connection
rt = rtapi.RTObject(db)
# List all objects from database
print rt.ListObjects()
The error I get is:
python3 ./sqltest.py
File "./sqltest.py", line 18
print rt.ListObjects()
^
SyntaxError: invalid syntax
I could really use some help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.