Noam Slomianko has uploaded a new change for review.

Change subject: External scheduler: real rest api example
......................................................................

External scheduler: real rest api example

- Added a usage example employing rest api calls

Signed-off-by: Noam Slomianko <nslom...@redhat.com>
Change-Id: I395774e95ae4481be03076c7250b776d5abb0d36
---
A plugins/example.py
1 file changed, 33 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-scheduler-proxy 
refs/changes/15/18415/1

diff --git a/plugins/example.py b/plugins/example.py
new file mode 100644
index 0000000..339f58f
--- /dev/null
+++ b/plugins/example.py
@@ -0,0 +1,33 @@
+from ovirtsdk.xml import params
+from ovirtsdk.api import API
+from ovirtsdk.infrastructure.errors import ConnectionError
+import sys
+
+
+#What are the values this module will accept, used to present
+#the user with options
+properties_validation = 'storage_type = ["NFS","ISCSI","LOCALFS"]'
+
+
+#A simple filter, checks if a hosts storage is of a certain type
+def do_filter(hosts_ids, vm_id, args_map):
+    try:
+        connection = API(url='http://host:port',
+                         username='user@domain', password='password')
+    except BaseException as ex:
+        #letting the external proxy know there was an error
+        print >> sys.stderr, sys.stderr
+        return
+
+    storage_type_allowed = args_map.get('storage_type')
+    if(not storage_type_allowed):
+        storage_type_allowed = 'NFS'
+
+    accepted_host_ids = []
+
+    for hosts_id in hosts_ids:
+        engine_host = connection.datacenters.get(id=hosts_id)
+        if(engine_host and engine_host.storage_type and
+                engine_host.storage_type.lower() == 
storage_type_allowed.lower()):
+            accepted_host_ids.append(hosts_id)
+    print accepted_host_ids
\ No newline at end of file


-- 
To view, visit http://gerrit.ovirt.org/18415
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I395774e95ae4481be03076c7250b776d5abb0d36
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-scheduler-proxy
Gerrit-Branch: master
Gerrit-Owner: Noam Slomianko <nslom...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to