[Ovirt-devel] [PATCH] The server was rewritten in Ruby. The managed node side was rewritten in Python.
Perry N. Myers
pmyers at redhat.com
Tue Jun 3 03:19:37 UTC 2008
Darryl L. Pierce wrote:
> I'm at a point now where I'm pretty close, but starting to stumble a little with the keytab stuff.
> Also, the persistence seems to not work but it could be my environment. I'm on around 5:45a EST if
> anybody wants to ping me to lend a hand.
I'll let more accomplished coders make the important comments, but I have
a few comments...
> ---
> ovirt-host-creator/common-post.ks | 8 +
> ovirt-host-creator/identify-node.py | 94 ++++++++
> wui/src/host-browser/Makefile | 12 -
> wui/src/host-browser/dbwriter.rb | 66 ------
> wui/src/host-browser/host-browser.c | 286 ------------------------
> wui/src/host-browser/ruby-host-browser.rb | 220 ++++++++++++++++++
> wui/src/host-browser/test-ruby-host-browser.rb | 219 ++++++++++++++++++
> 7 files changed, 541 insertions(+), 364 deletions(-)
> create mode 100755 ovirt-host-creator/identify-node.py
> delete mode 100644 wui/src/host-browser/Makefile
> delete mode 100755 wui/src/host-browser/dbwriter.rb
> delete mode 100644 wui/src/host-browser/host-browser.c
> create mode 100755 wui/src/host-browser/ruby-host-browser.rb
> create mode 100755 wui/src/host-browser/test-ruby-host-browser.rb
>
> diff --git a/ovirt-host-creator/common-post.ks b/ovirt-host-creator/common-post.ks
> index 088f920..621776f 100644
> --- a/ovirt-host-creator/common-post.ks
> +++ b/ovirt-host-creator/common-post.ks
> @@ -12,6 +12,14 @@ cat > /etc/sysconfig/iptables << \EOF
> COMMIT
> EOF
>
> +# TODO copy script into this place
> +echo "Writing ovirt-identify-node script"
> +cat > /sbin/ovirt-identify-node
> +
> +EOF
> +
> +chmod +x /sbin/ovirt-identify-node
> +
Hmm. I think we should create an ovirt-node rpm file where we can stick
things like this, and some of the other things that have been crammed into
the kickstart post files. So if you want to create this rpm and throw
some stuff in there (like this and the below python script) that would be
a good thing.
> echo "Writing ovirt-functions script"
> # common functions
> cat > /etc/init.d/ovirt-functions << \EOF
> diff --git a/ovirt-host-creator/identify-node.py b/ovirt-host-creator/identify-node.py
> new file mode 100755
> index 0000000..1c23d3f
> --- /dev/null
> +++ b/ovirt-host-creator/identify-node.py
> @@ -0,0 +1,94 @@
> +#!/usr/bin/python -Wall
> +#
> +# Copyright (C) 2008 Red Hat, Inc.
> +# Written by Darryl L. Pierce <dpierce at redhat.com>
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; version 2 of the License.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program; if not, write to the Free Software
> +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> +# MA 02110-1301, USA. A copy of the GNU General Public License is
> +# also available at http://www.gnu.org/copyleft/gpl.html.
> +
> +import socket
> +
> +
> +class IdentifyNode:
> + """This class allows the managed node to connect to the WUI host
> + and notify it that the node is awake and ready to participate."""
> +
> + def __init__(self):
> + self.hostname = 'localhost'
> + self.server_name = 'localhost'
> + self.server_port = 12120
server name and server port should be obtained from DNS SRV records. This
should be easy to get in python... python has an API for everything,
right? :)
> + self.host_info = {
> + "UUID" : "1148fdf8-961d-11dc-9387-001558c41534",
> + "HOSTNAME" : "localhost",
> + "NUMCPUS" : "4",
> + "CPUSPEED" : "2.4",
> + "ARCH" : "kvm",
> + "MEMSIZE" : "16384" }
Obviously a place holder for use later.
> + self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> + self.socket.connect((self.server_name,self.server_port))
> + self.input = self.socket.makefile('rb', 0)
> + self.output = self.socket.makefile('wb', 0)
> +
> + def start_conversation(self):
> + print("Connecting to server")
> +
> + response = self.input.readline().strip()
> + if response == 'HELLO?':
> + self.output.write("HELLO!\n")
> + else:
> + raise TypeError, "Received invalid conversation starter: %s" % response
> +
> + def send_host_info(self):
> + print("Starting information exchange...")
> +
> + response = self.input.readline().strip()
> + if response == 'INFO?':
> + for name in self.host_info.keys():
> + self.send_host_info_element(name,self.host_info[name])
> + else:
> + raise TypeError, "Received invalid info marker: %s" % response
> +
> + print("Ending information exchange...")
> + self.output.write("ENDINFO\n")
> + response = self.input.readline().strip()
> +
> + if response[1:3] == 'KVNO':
> + self.keytab = response[:5]
> + else:
> + raise TypeError, "Did not receive a keytab response: '%s'" % response
> +
> + def send_host_info_element(self,key,value):
> + print("Sending: " + key + "=" + value)
> + self.output.write(key + "=" + value + "\n")
> + response = self.input.readline().strip()
> +
> + if response != "ACK " + key:
> + raise TypeError, "Received bad acknolwedgement for field: %s" % key
Heh... Spell check :) acknowledgement...
> + def get_keytab(self,tabfile):
> + print("Retrieving keytab information: %s" % self.keytab)
> +
> + def end_conversation(self):
> + print("Disconnecting from server")
> +
> +
> +if __name__ == '__main__':
> + identifier = IdentifyNode()
> +
> + identifier.start_conversation()
> + identifier.send_host_info()
> + identifier.get_keytab()
> + identifier.end_conversation()
The rest is Ruby and I need to get more familiar with it before I am able
to make coherent comments on syntax stuff... I'll let some of the other
folks contribute here.
Perry
More information about the ovirt-devel
mailing list