[node-patches] Change in ovirt-node[master]: registration: Remove registration dir
dougsland at redhat.com
dougsland at redhat.com
Mon May 25 02:16:02 UTC 2015
Douglas Schilling Landgraf has uploaded a new change for review.
Change subject: registration: Remove registration dir
......................................................................
registration: Remove registration dir
oVirt Node plugin vdsm now uses vdsm-tool register verb.
Based on this affirmation, removing the old registration
approach, no need to maintain the source. Thanks for serving until now.
Change-Id: I49242ae8b15f3886178de517dcad1fb9effcaf47
Signed-off-by: Douglas Schilling Landgraf <dougsland at redhat.com>
---
M Makefile.am
M configure.ac
M ovirt-node.spec.in
D registration/Makefile.am
D registration/example.json
D registration/ovirt-node-register
M src/Makefile.am
D src/ovirt/node/tools/registration.py
8 files changed, 1 insertion(+), 257 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/70/41370/1
diff --git a/Makefile.am b/Makefile.am
index 12930b5..caa6b27 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,7 +31,6 @@
logrotate \
plugins \
modules \
- registration \
tools \
tests
diff --git a/configure.ac b/configure.ac
index 7a988c4..a74d6b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,7 +118,6 @@
images/Makefile
hooks/Makefile
scripts/Makefile
- registration/Makefile
tools/Makefile
scripts/collectd.conf
src/Makefile
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index f1121d9..282a840 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -881,7 +881,6 @@
%files cli-tools
%{python_sitelib}/ovirt/node/tools/features.py*
-%{python_sitelib}/ovirt/node/tools/registration.py*
%{python_sitelib}/ovirt/node/tools/password.py*
%{python_sitelib}/ovirt/node/tools/__init__.py*
@@ -1043,7 +1042,6 @@
%{_sbindir}/persist
%{_sbindir}/unpersist
%{_sbindir}/ovirt-node-upgrade
-%{_sbindir}/ovirt-node-register
%{python_sitelib}/ovirt_config_setup
%exclude %{python_sitelib}/ovirt_config_setup/cim.py*
%exclude %{python_sitelib}/ovirt_config_setup/snmp.py*
diff --git a/registration/Makefile.am b/registration/Makefile.am
deleted file mode 100644
index 13fd866..0000000
--- a/registration/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2014 Red Hat, Inc.
-#
-# 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.
-
-dist_sbin_SCRIPTS = \
- ovirt-node-register
diff --git a/registration/example.json b/registration/example.json
deleted file mode 100644
index ac75d5f..0000000
--- a/registration/example.json
+++ /dev/null
@@ -1,66 +0,0 @@
-{
- "register": {
- "steps": [
- {
- "name": "get_ca",
- "action": "get",
- "parameters": {
- "uri": "engine.example.com/ovirt-engine",
- "url": "http://{uri}/services/host-register?version=1&cmd=get-pki-trust",
- "filename": "/etc/pki/ovirt-engine.key"
- }
- },
- {
- "name": "approve",
- "action": "ui",
- "parameters": {
- "key": "OVIRT_ENGINE_FINGERPRINT"
- }
- },
- {
- "name": "persist_ca",
- "action": "persist",
- "parameters": {
- "file": "/etc/pki/ovirt-engine.key"
- }
- },
- {
- "name": "get_ssh",
- "action": "get",
- "parameters": {
- "uri": "engine.example.com",
- "url": "http://{uri}/ovirt-engine/services/host-register?version=1&cmd=get-ssh-trust",
- "filename": "/tmp/ovirt-engine.key"
- }
- },
- {
- "name": "authorize",
- "action": "exec",
- "parameters": {
- "cmd": "cat /tmp/ovirt-engine.key >> /home/admin/.ssh/.authorized_keys"
- }
- },
- {
- "name": "persist_ssh",
- "action": "persist",
- "parameters": {
- "file": "/home/admin/.ssh/.authorized_keys"
- }
- },
- {
- "name": "finish",
- "action": "get",
- "parameters": {
- "uri": "engine.example.com/ovirt-engine",
- "url": "http://{uri}/services/host-register?version=1&cmd=register&name={name}&address={address}&uniqueId={uniqueId}&vdsPort={vdsPort}&sshUser={sshUser}&sshPort={sshPort}",
- "name": "node.example.com",
- "address": "10.0.0.1",
- "vdsPort": "54321",
- "sshUser": "admin",
- "sshPort": "22",
- "uniqueId": "DEADBEEF-UUID-1234-5678-09DEADBEEF00",
- }
- }
- ]
- }
-}
diff --git a/registration/ovirt-node-register b/registration/ovirt-node-register
deleted file mode 100755
index 2f2b3ac..0000000
--- a/registration/ovirt-node-register
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/bin/bash
-
-# A wrapper to launch the registration tool
-
-python -m ovirt.node.tools.registration "$@"
diff --git a/src/Makefile.am b/src/Makefile.am
index d2948d5..e20da2a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -132,8 +132,7 @@
pyovirt_node_tools_PYTHON = \
ovirt/node/tools/__init__.py \
ovirt/node/tools/password.py \
- ovirt/node/tools/features.py \
- ovirt/node/tools/registration.py
+ ovirt/node/tools/features.py
dist_pyovirt_node_tools_DATA = \
ovirt/node/tools/featured.xsl
diff --git a/src/ovirt/node/tools/registration.py b/src/ovirt/node/tools/registration.py
deleted file mode 100644
index e56f98e..0000000
--- a/src/ovirt/node/tools/registration.py
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# ovirt-node-registration.py - Copyright (C) 2014 Red Hat, Inc.
-# Written by Ryan Barry <rbarry 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 requests
-import json
-import logging
-import sys
-from optparse import OptionParser
-from ovirt.node.utils import AugeasWrapper, fs, process
-
-"""
-oVirt Node Generic Registration
-"""
-
-
-class Client:
- """ A simple class to map json to functions and execute.
-
- All functions take unlimited arguments for string formatting
- and other execution, but have one or two required arguments
- for basic operation.
- """
- parameters = {}
-
- def __init__(self, json_data, logger=None):
- if not logger:
- logging.basicConfig(
- filename="/tmp/ovirt-node-registration.log",
- filemode='a',
- format='%(levelname)10s %(asctime)s '
- '%(pathname)s:%(lineno)s:%(funcName)s %(message)s',
- level=logging.DEBUG
- )
- self.logger = logging.getLogger('ovirt-node-registration')
- else:
- self.logger = logger
-
- # A list of actions possible and their associated functions
- self.maps = {"get": self.get,
- "ui": self.ui,
- "persist": self.persist,
- "exec": self.run}
-
- self.data = json.loads(open(json_data).read())
-
- def perform(self, action, params=None):
- """ Executes the steps necessary to complete a given action
- required parameters: action
- """
-
- for x in self.data[action]["steps"]:
- args = x["parameters"] if x["parameters"] else {}
- if params:
- args.update(params)
- self.maps[x["action"]](**args)
-
- def get(self, *args, **kwargs):
- """ GETs a URL, optionally stores it as {filename}
- required parameter: url
- """
-
- if "url" not in kwargs:
- raise RuntimeError("A url is required for get()!")
-
- url = kwargs["url"].format(**kwargs)
- self.logger.debug("Getting %s" % url)
- if "filename" in kwargs:
- if not kwargs["filename"].startswith("/tmp"):
- self.persist(file=kwargs["filename"])
- with open(kwargs["filename"], "w") as f:
- response = requests.get(url, stream=True)
- if response.ok:
- for chunk in response.iter_content():
- f.write(chunk)
- else:
- self.logger.info("Failed to get %s" % url)
- else:
- r = requests.get(url)
- if not r.ok:
- self.logger.info("Failed to get %s" % url)
-
- def ui(self, *args, **kwargs):
- """ Sets a value in /etc/default/ovirt for the TUI to read
- required parameters: key, value
- """
-
- if "key" not in kwargs or "value" not in kwargs:
- raise RuntimeError("A key and value are required to prompt "
- "for UI interaction")
- aug = AugeasWrapper()
- aug.set("/files/etc/default/ovirt/%s" % kwargs["key"],
- kwargs["value"])
-
- def persist(self, *args, **kwargs):
- """ Persists a file
- required parameter: file
- """
-
- if "file" not in kwargs:
- raise RuntimeError("A file is required for persist()!")
-
- self.logger.debug("Persisting %s" % kwargs["file"])
- fs.Config().persist(kwargs["file"])
-
- def run(self, *args, **kwargs):
- """ Executes a commmand
- required parameter: cmd
- """
-
- if "cmd" not in kwargs:
- raise RuntimeError("A command is required for exec()!")
-
- cmd = kwargs["cmd"].format(**kwargs)
-
- self.logger.debug("Running %s" % cmd)
- output = process.check_output(cmd, shell=True)
- self.logger.debug("Output of %s was: %s" % cmd, output)
-
-
-def main():
- usage = "usage: %prog -a {action} -p foo=bar,x=y filename.json"
- parser = OptionParser(usage=usage)
- parser.add_option("-a", "--action", dest="action",
- help="action to execute")
- parser.add_option("-p", "--params", dest="params",
- help="list of comma-separated parameters in the form "
- "of 'foo=bar,x=y'")
- (options, args) = parser.parse_args()
-
- params = {}
-
- if options.params:
- for x in options.params.split(","):
- params[x.split('=')[0]] = x.split('=')[1]
-
- if len(args) < 1:
- print "Must provide a filename!"
- sys.exit(1)
-
- c = Client(args[0])
- c.perform(options.action, params)
-
-if __name__ == "__main__":
- main()
--
To view, visit https://gerrit.ovirt.org/41370
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I49242ae8b15f3886178de517dcad1fb9effcaf47
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Douglas Schilling Landgraf <dougsland at redhat.com>
More information about the node-patches
mailing list