Code Monkey home page Code Monkey logo

infinisdk's Introduction

InfiniSDK

Build Status Build Status
Supported Versions Supported Versions
Latest Version Latest Version

Overview

InfiniSDK is the official Python SDK for INFINIDAT's products. It provides a clean interface for creating, deleting, querying and manipulating API objects.

Licence

BSD-3

infinisdk's People

Contributors

vmalloc avatar oren0e avatar yaelmi3 avatar infinidat-infradev avatar d1618033 avatar

Stargazers

 avatar  avatar Artyom V. avatar  avatar  avatar Itai Weisman avatar  avatar Daniel Rich avatar

Watchers

James Cloos avatar Ori Levi-Ganani avatar  avatar  avatar  avatar Dor Amarm avatar Vadim All avatar Kyle Button avatar Oz Hardoon avatar Sivan Becker avatar  avatar Daniel Ramos avatar Daniel Rich avatar Allan Reynolds avatar  avatar Jimmie Keyes avatar

infinisdk's Issues

Best way to create Disconnected Hosts List

Hi!

I was going over the host fields (SAN_Type), is there any way to query from the system all the hosts that are in a disconnected status + any host with one or more disconnected Ports (wwns) ?

Perform Query with single field which hits different values

Hello!

I am trying to create an automated unmapped reclamation script. Which would be schedule as a cronjob every week and use the epoch value and volume time_stamps so if it surpass the time threshold it can be automatically reclaimed.

I was able to create an script that works on that matter, but is taking a lot of time to complete, I think I can speed up the time If I merge the Event search.

The logic of the script is the following:
-Log into infinibox
-Retrieve the Volumes that are unmapped
-Search on the events for event.get_code()='HOST_UNMAPPED' which also contain the Volume name in the Description
-If there is no hit, then search by event.get_code()='VOLUME_CREATED' (In case volume was never unmapped)
-Retrieve User and Timestamp from event
-Convert to timestamp to epoch, substract and verify if condition is met

I know there is a cleaner search if I do a loop like: "for events in system.events.find(code='HOST_UNMAPPED') is there a way to combine those 2 search for host unmapped and volume created into a single one?

Here is the output and the time values of completion.
The Following Volumes are unmapped from: Infinibox_system

Volume Name: vol01
Owner: user@domain
Unmapped_Timestamp: 2018-09-05 13:37:16
Candidate for reclaiming
This Volume Has been Unmapped

Volume Name: testvol03
Owner: user@domain
Unmapped_Timestamp: 2018-11-13 20:16:21
Has not reached idle threshold
This Volume Has been Unmapped

Volume Name: testvol04
Owner: user@domain
Unmapped_Timestamp: 2018-11-13 20:28:53
Has not reached idle threshold
This Volume Has been Unmapped

real 5m15.482s
user 0m38.981s
sys 0m1.194s

Thanks a lot for your help!

Asyncio

Hi,

Im using your SDK to query hundreds of snapshots of thousands of volumes.
Its a long process as you may guess.
Is there by a chance an asyncio / requests_async implementation out there?
it would make the implementation fly and the effort to achieving this is negligible...

Thanks!

HTTP status 415 when calling "replicas/{id}/change_role"

I'm trying to recreate the "Change Role" menu option in the replication GUI in a script, either through an SDK function or manually. From what I can tell, the switch_role() function doesn't work for async (as the documentation states). So I tried to call the API through the SDK at api/rest/replicas/{id}/change_role, but that returns a 415. I can confirm that I receive the same result in Postman.

I don't claim to be a Python guru, so let me know if I'm doing something wrong in my script.

Script:

from infinisdk import InfiniBox

system = InfiniBox("hostname", auth=("user", "password"))
system.login()

replica_id = system.replicas.get(remote_entity_name = "content_library").get_id()

change_role = system.api.post('replicas/' + str(replica_id) + '/change_role')
change_role.get_result()

Response:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    change_role = system.api.post('replicas/' + str(test_replica.get_id()) + '/change_role')
  File "/usr/lib/python2.7/site-packages/infinisdk/core/api/api.py", line 34, in returned
    return self.request(http_method, path=path, **kwargs)
  File "/usr/lib/python2.7/site-packages/infinisdk/core/api/api.py", line 516, in request
    returned.assert_success()
  File "/usr/lib/python2.7/site-packages/infinisdk/core/api/api.py", line 655, in assert_success
    raise APICommandFailed.raise_from_response(self)
  File "/usr/lib/python2.7/site-packages/infinisdk/core/exceptions.py", line 83, in raise_from_response
    raise cls(response)
infinisdk.core.exceptions.APICommandFailed: API Command Failed
        Request: POST http://<hostname>:80/api/rest/replicas/93067/change_role?approved=true
        Request Timestamp: 2018-05-15T11:26:26.943272-04:00
        Response Timestamp: 2018-05-15T11:26:26.985322-04:00
        Data: <NOTHING>
        Status: 415
        Code: UNSUPPORTED_MEDIA_TYPE
        Message: The media type of the request is not supported
        Cookies: JSESSIONID=<nom_nom_cookies>

volume snapshots by volume

Hi,

How can I query all the snapshot of volume given I have its name only.

I have tries:

system.volumes.find(name=volume_name, type='snapshots')

and
volume = system.volumes.find(name==volume_name)
system.volumes.find(parent_id=volume.id, type='snapshots')

but couldnt get the list

can you please advise?

Error on Infinisdk Login while using pyinstaller to convert to Executable

Hi Folks!

I have a Working Script to perform Automated Provisioning on Infinidat. Script works good. However due to Automation Effort I need to Convert the Script into an Executable and I'm Using pyinstaller (Which allowed me to convert an SVC Provisioning Script to executable using Paramiko) It seems that while using pyinstaller something changed on how the infinisdk login is make.

I have Performed the following( from the Pyinstaller end)

Ran the analysis and check the warn log for module import missing.
Update the .spec file both with the --hidden-import Parameter and by updating the Spec file.
Update the .spec file with pyi-makespec --paths= with the Module Full Path name and also by updating the spec file manually
Re compile build by using the pyinstaller [file].spec.

I'm getting the following error every time. Have you seen dsomething similar?

Traceback (most recent call last):
File "LUN_Creation.py", line 3053, in
File "LUN_Creation.py", line 662, in host_ex_AMDC_ux
File "LUN_Creation.py", line 588, in infi_login ### Above my Script , Below Error###
File "site-packages\infinisdk\infinibox\infinibox.py", line 229, in login
File "site-packages\infinisdk\infinibox\infinibox.py", line 257, in get_clien
t_id
File "site-packages\pkg_resources_init.py", line 557, in get_distribution
File "site-packages\pkg_resources_init_.py", line 431, in get_provider
File "site-packages\pkg_resources_init_.py", line 967, in require
File "site-packages\pkg_resources_init_.py", line 853, in resolve
pkg_resources.DistributionNotFound: The 'infinisdk' distribution was not found a
nd is required by the application
[322136] Failed to execute script LUN_Creation

What is the proper way to enable certificate validation?

Hello,

We are using the python InfiniSDK and connecting with use_ssl=True.

The following warnings are received from urllib3. What is the proper way to enable certificate validation?

/opt/infiniglue/venv/lib/python2.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings

Thanks,

Scott

Error while trying to create Volumes on Defined Pool

I'm hitting this error while trying to create volumes in an already defined Pool. Have you seen something similar?
Traceback (most recent call last):
File "C:...\LUN_Creation.py", line 81, in
vols = system.volumes.create_many(pool=p, name=name, count=vol, size=siz)
File "C:\Python35\lib\site-packages\infinisdk\infinibox\dataset.py", line 52, in create_many
for i in range(1, count + 1)]
File "C:\Python35\lib\site-packages\infinisdk\infinibox\dataset.py", line 52, in
for i in range(1, count + 1)]
File "C:\Python35\lib\site-packages\infinisdk\core\type_binder.py", line 148, in create
return self.object_type.create(self.system, *args, **kwargs)
File "C:\Python35\lib\site-packages\infinisdk\infinibox\volume.py", line 75, in create
pool.invalidate_cache('allocated_physical_capacity', 'free_physical_capacity', 'free_virtual_capacity',
AttributeError: 'str' object has no attribute 'invalidate_cache'

I was able to use the infinisdk for authentication, Pool and Host Creation previously. Even while creating single volume I got the same error.

system = InfiniBox(ibox, auth=(username,password))
system.login()
<Response [200]>
p = "Storage_Pool"
v = system.volumes.create(pool=p, name='my_vol')
Traceback (most recent call last):
File "", line 1, in
File "C:\Python35\lib\site-packages\infinisdk\core\type_binder.py", line 148, in create
return self.object_type.create(self.system, *args, **kwargs)
File "C:\Python35\lib\site-packages\infinisdk\infinibox\volume.py", line 75, in create
pool.invalidate_cache('allocated_physical_capacity', 'free_physical_capacity', 'free_virtual_capacity',
AttributeError: 'str' object has no attribute 'invalidate_cache'

SSL recursion error with requests library on infinisdk 185.1.1

Operating System: Ubuntu 20.04.3 LTS
Kernel: Linux 5.4.0-81-generic

python3 -m pip install infinisdk==185.1.1

python3 -m pip show infinisdk | grep Location
Location: /usr/local/lib/python3.8/dist-packages

When connecting to infinibox (using openstack cinder infinibox driver) - we get error below:

2021-09-14 17:30:56.793 2194884 INFO cinder.volume.manager [req-df891849-4101-41b7-a680-908d41f234b5 - - - - -] Starting volume driver InfiniboxVolumeDriver (1.7)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager [req-df891849-4101-41b7-a680-908d41f234b5 - - - - -] Failed to initialize driver.: RecursionError: maximum recursion depth exceeded while calling a Python object
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager Traceback (most recent call last):
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3/dist-packages/cinder/volume/manager.py", line 466, in _init_host
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self.driver.do_setup(ctxt)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3/dist-packages/cinder/volume/drivers/infinidat.py", line 169, in do_setup
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self._system = (self._setup_and_get_system_object(
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3/dist-packages/cinder/volume/drivers/infinidat.py", line 156, in _setup_and_get_system_object
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager system.login()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/infinibox.py", line 252, in login
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager if self.compat.has_auth_sessions():
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 124, in has_auth_sessions
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self._has_feature('api_auth_sessions') or self._has_feature('api/auth_sessions')
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 91, in _has_feature
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self._get_feature_version(feature_key, NOTHING) is not NOTHING
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 84, in _get_feature_version
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self._init_features()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 72, in _init_features
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager resp = self.system.api.get("_features", assert_success=False)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 33, in returned
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.request(http_method, path=path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 511, in request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager returned = self._request(http_method, path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 327, in _request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self.system.check_version()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/infinibox.py", line 77, in check_version
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager if not self.compat.can_run_on_system():
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 37, in can_run_on_system
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager version_string = self.system.get_version().split('-', 1)[0]
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/infinibox.py", line 190, in get_version
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.get_system_info('version')
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/infinibox.py", line 155, in get_system_info
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.components.system_component.get_field(field_name, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/system_object.py", line 175, in get_field
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.get_fields([field_name], **kwargs)[field_name]
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/system_object.py", line 211, in get_fields
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager response = self.system.api.get(query)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 33, in returned
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.request(http_method, path=path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 511, in request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager returned = self._request(http_method, path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 340, in _request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self.system.compat.initialize()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 34, in initialize
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self._init_features()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/infinibox/compatibility.py", line 72, in _init_features
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager resp = self.system.api.get("_features", assert_success=False)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 33, in returned
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager return self.request(http_method, path=path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 511, in request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager returned = self._request(http_method, path, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/infinisdk/core/api/api.py", line 396, in _request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager response = self._session.send(prepared, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/requests/sessions.py", line 655, in send
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager r = adapter.send(request, **kwargs)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/requests/adapters.py", line 439, in send
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager resp = conn.urlopen(
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 699, in urlopen
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager httplib_response = self._make_request(
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 382, in _make_request
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self._validate_conn(conn)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/urllib3/connectionpool.py", line 1010, in validate_conn
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager conn.connect()
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/urllib3/connection.py", line 392, in connect
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager self.ssl_context = create_urllib3_context(
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/local/lib/python3.8/dist-packages/urllib3/util/ssl
.py", line 312, in create_urllib3_context
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager context.options |= options
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3.8/ssl.py", line 602, in options
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager super(SSLContext, SSLContext).options.set(self, value)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3.8/ssl.py", line 602, in options
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager super(SSLContext, SSLContext).options.set(self, value)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager File "/usr/lib/python3.8/ssl.py", line 602, in options
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager super(SSLContext, SSLContext).options.set(self, value)
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager [Previous line repeated 468 more times]
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager RecursionError: maximum recursion depth exceeded while calling a Python object
2021-09-14 17:30:56.797 2194884 ERROR cinder.volume.manager

This is being caused by the version of 'requests' library specified in infinisdk requirements.txt
requests-2.4.0 is installed

It appears to be related to this bug:
eventlet/eventlet#371

Upgrading to requests-2.22.0 fixes this issue.

Sort pools by free space

I would like to sort pools objects at the API level.

HTTP GET: api/rest/pools?sort=-free_virtual_space

Returns this:
{ "result": null, "error": { "code": "UNSUPPORTED_FIELD", "message": "The request contains an unsupported field ('free_virtual_space')", "reasons": [], "severity": "ERROR", "is_remote": false, "data": null }, "metadata": { "ready": true } }

Filtering wildcard support

Does the Infinibox API support wildcards?

I want to do something like this ?name=:like*vdi

I want to match stevevdi and not stevevdisteve

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.