https://github.com/mirantis/ifmap-python-client
https://github.com/mirantis/ifmap-python-client
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/mirantis/ifmap-python-client
- Owner: Mirantis
- License: other
- Created: 2017-01-23T14:10:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-02-26T12:08:17.000Z (about 5 years ago)
- Last Synced: 2025-01-17T12:17:48.335Z (4 months ago)
- Language: Python
- Size: 49.8 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.txt
- License: LICENSE
Awesome Lists containing this project
README
Copyright 2011, Infoblox, Inc. All Rights Reserved
Released under BSD, see LICENSE
IF-MAP Python Client Library
============================This is a Python library for building IF-MAP clients.
It supports the Trusted Computing Group IF-MAP protocol v.2.0
There is no support for IF-MAP 1.0 or 1.1 and there are no plans to support those versions.Currently Implemented:
* Session: newSession, endSession, renewSession
* Publish: Update, Notify, Delete
* Identities: IP, MAC, Device, Access Request, Identity, Custom Identifier
* Metadata: IF-MAP metadata and custom namespace metadata
* Search: Search on all of the above IDs
* Subscribe: SubscribeUpdate, SubscribeDelete
* Purge: PurgeRequest
* Poll: PollRequestTODO:
* Implement XML schema validation (as optional)Installation
------------Get the python library from github:
$ git clone git://github.com/IF-MAP/ifmap-python-client.gitOr download as a zip file and unzip:
https://github.com/IF-MAP/ifmap-python-client/zipball/masterRequirements
------------The main library has no python requirements, except for ifmap.response (response.py) which uses xlm.etree to parse results.
You can implement the client entirely without response.py and parse your own responses in anyway you like.
If you do not use response.py, then you do not need any Python libraries. If you use it, you need xml.etree.Library Structure
-----------------* ifmap - the directory containing the library components
* testmap.py - a test script showing example codeCode Example
-------
An example of working code:from xml.etree import ElementTree # Only needed to parse results
from ifmap.client import client, namespaces
from ifmap.request import NewSessionRequest, RenewSessionRequest, EndSessionRequest, PublishRequest, SearchRequest
from ifmap.id import IPAddress, MACAddress, Device, AccessRequest, Identity, CustomIdentity
from ifmap.operations import PublishUpdateOperation, PublishNotifyOperation, PublishDeleteOperation
from ifmap.util import attr, link_ids
from ifmap.response import Response, newSessionResult
from ifmap.metadata import Metadatamapclient = client("https://127.0.0.1:8443", 'test', 'test', namespaces)
result = mapclient.call('newSession', NewSessionRequest())
mapclient.set_session_id(newSessionResult(result).get_session_id())
mapclient.set_publisher_id(newSessionResult(result).get_publisher_id())meta = str(Metadata('role', 'employee', {'ifmap-cardinality':'multiValue'}))
pubreq = PublishRequest(mapclient.get_session_id(), str(PublishUpdateOperation(id1=str(IPAddress("10.0.0.1")), metadata=meta, lifetime='forever')))
result = mapclient.call('publish', pubreq)
print Response(result)searchreq = SearchRequest(mapclient.get_session_id(), str(IPAddress("10.0.0.1")), validation="None")
result = mapclient.call('search', searchreq)