Shahar Havivi has uploaded a new change for review.

Change subject: ruby: first commit
......................................................................

ruby: first commit

Change-Id: I3c7b84728e3b6d42dd0e662b903cbc2c737464ee
Signed-off-by: Shahar Havivi <[email protected]>
---
A ruby/README
A ruby/ovirt.conf.yml
A ruby/ovirtwrapper.rb
A ruby/webhandler.rb
4 files changed, 74 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/samples-portals refs/changes/37/11437/1

diff --git a/ruby/README b/ruby/README
new file mode 100644
index 0000000..b24351a
--- /dev/null
+++ b/ruby/README
@@ -0,0 +1,6 @@
+Perquisites:
+gem install rbovirt
+
+Run the server:
+ruby -rubygems webhandler.rb
+
diff --git a/ruby/ovirt.conf.yml b/ruby/ovirt.conf.yml
new file mode 100644
index 0000000..f62ebfa
--- /dev/null
+++ b/ruby/ovirt.conf.yml
@@ -0,0 +1,7 @@
+---
+ovirt:
+    baseurl: http://localhost:8700
+
+server:
+    host: 0.0.0.0
+    port: 8000
diff --git a/ruby/ovirtwrapper.rb b/ruby/ovirtwrapper.rb
new file mode 100644
index 0000000..9c59f3b
--- /dev/null
+++ b/ruby/ovirtwrapper.rb
@@ -0,0 +1,13 @@
+require 'yaml'
+
+class OVirtWrapper
+    def initialize()
+        conf = YAML.load_file('ovirt.conf.yml')
+        @baseUrl = conf['ovirt']['baseurl']
+
+    end
+
+    def login(username, password)
+        @client = ::OVIRT::Client.new(username, password, 
"http://localhost:8700/api";, nil, nil, true)
+    end
+end
diff --git a/ruby/webhandler.rb b/ruby/webhandler.rb
new file mode 100644
index 0000000..d7894c6
--- /dev/null
+++ b/ruby/webhandler.rb
@@ -0,0 +1,48 @@
+require 'sinatra'
+require 'yaml'
+
+require 'ovirtwrapper.rb'
+
+configure do
+    conf = YAML.load_file('ovirt.conf.yml')
+    set :bind, conf['server']['host']
+    set :port, conf['server']['port']
+end
+
+get '/' do
+    login()
+end
+
+get '*' do
+    login()
+end
+
+def login
+    message = ''
+    if params['username'] != nil and params['password'] != nil
+        wrapper = OVirtWrapper.new
+        wrapper.login(params['username'], params['password'])
+    end
+
+    '<html>
+    <body>
+    <center><br/><br/>
+    <form name="input" action="/" method="post">
+            <table>
+                <tr>
+                    <td>User name:</td>
+                    <td><input type="text" name="username" value=""/></td>
+                <tr>
+                    <td>Password:</td>
+                    <td><input type="password" name="password" value=""/></td>
+                <tr>
+                    <td/>
+                    <td align="right"><input type="submit" value="Login"/></td>
+                </tr>
+                <tr>
+                    <td colspan="2" style="color:red">%s</td>
+                </tr>
+        </form>
+    </body>
+    </html>' % message
+end


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c7b84728e3b6d42dd0e662b903cbc2c737464ee
Gerrit-PatchSet: 1
Gerrit-Project: samples-portals
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to