[PATCH] Recipes and sourced bits can now be represented by HTTP urls
by Jan Tluka
The change allows a user to specify both local file and http urls as
recipe and sourced recipe bits (using 'source' attribute). Relative
paths are automagically resolved. See usage below in tested scenarios.
Tested for following use cases:
1. url supplied to controller on command line
# nettestctl.py -c http://somedomain.com/jtluka/rhel63-tests/bond-tests/bond-mode5-scenario1...
# run
2. relative local file path supplied to controller
# nettestctl.py -c ./rhel63-tests/bond-tests/bond-mode5-scenario1.xml
# run
3. relative local directory path supplied to controller
# nettestctl.py -c ./rhel63-tests/bond-tests/ run
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
Common/XmlProcessing.py | 13 +++++++------
NetTest/NetTestParse.py | 7 +++++--
nettestctl.py | 2 +-
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Common/XmlProcessing.py b/Common/XmlProcessing.py
index 5aa7ccd..2ae5f4c 100644
--- a/Common/XmlProcessing.py
+++ b/Common/XmlProcessing.py
@@ -15,6 +15,7 @@ import logging
from xml.dom.minidom import parseString
from xml import sax
from Common.XmlTemplates import XmlTemplates, XmlTemplateError
+from Common.RecipePath import RecipePath
class XmlProcessingError(Exception):
@@ -281,14 +282,17 @@ class RecipeParser(XmlParser):
old_include_root = None
if self._has_attribute(node, "source"):
source = self._get_attribute(node, "source")
- file_path = self._get_referenced_xml_path(source)
+
+ source_rp = RecipePath(self._include_root, source)
old_include_root = self._include_root
- self._include_root = os.path.dirname(file_path)
+ self._include_root = source_rp.get_root()
+ xmlstr = source_rp.to_str()
dom_init = XmlDomTreeInit()
try:
- dom = dom_init.parse_file(file_path)
+ dom = dom_init.parse_string(xmlstr,
+ filename=source_rp.abs_path())
except IOError, err:
msg = "Unable to resolve include: %s" % str(err)
raise XmlProcessingError(msg, node)
@@ -361,6 +365,3 @@ class RecipeParser(XmlParser):
self._template_proc.define_alias(name, value)
except XmlTemplateError, err:
raise XmlProcessingError(str(err), node)
-
- def _get_referenced_xml_path(self, filename):
- return os.path.normpath(os.path.join(self._include_root, os.path.expanduser(filename)))
diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py
index 76068dd..bdf1721 100644
--- a/NetTest/NetTestParse.py
+++ b/NetTest/NetTestParse.py
@@ -18,20 +18,23 @@ from Common.XmlProcessing import XmlDomTreeInit
from Common.XmlProcessing import XmlProcessingError
from Common.NetUtils import normalize_hwaddr
from Common.Utils import bool_it
+from Common.RecipePath import RecipePath
class NetTestParse(RecipeParser):
def __init__(self, recipe_filepath):
super(NetTestParse, self).__init__()
self._filepath = recipe_filepath
- self._include_root = os.path.dirname(recipe_filepath)
+ self._rp = RecipePath(None, self._filepath)
+ self._include_root = self._rp.get_root()
self._recipe = {}
self._template_proc.set_definitions({"recipe": self._recipe})
def parse_recipe(self):
dom_init = XmlDomTreeInit()
- xml_dom = dom_init.parse_file(self._filepath)
+ rp = self._rp
+ xml_dom = dom_init.parse_string(rp.to_str(), rp.abs_path())
self._parse(xml_dom)
def _parse(self, xml_dom):
diff --git a/nettestctl.py b/nettestctl.py
index bc79398..f9973e4 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -47,7 +47,7 @@ def usage():
def process_recipe(action, file_path, remoteexec, cleanup,
res_serializer, packet_capture, config):
- nettestctl = NetTestController(os.path.realpath(file_path),
+ nettestctl = NetTestController(file_path,
remoteexec=remoteexec, cleanup=cleanup,
res_serializer=res_serializer,
config=config)
--
1.7.7.6
11 years, 7 months
[PATCH] Adding RecipePath module to handle both local and http paths
by Jan Tluka
RecipePath module is an abstraction over paths that can be specified on
command line and inside recipe files. Currently module supports local
files and HTTP urls but it's possible to extend the functionality for
other, e.g. FTP.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
Common/RecipePath.py | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 115 insertions(+), 0 deletions(-)
create mode 100644 Common/RecipePath.py
diff --git a/Common/RecipePath.py b/Common/RecipePath.py
new file mode 100644
index 0000000..b5f650c
--- /dev/null
+++ b/Common/RecipePath.py
@@ -0,0 +1,115 @@
+"""
+This module contains code code for LNST recipe paths and references.
+
+Copyright 2012 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+jtluka(a)redhat.com (Jan Tluka)
+"""
+
+import os
+from urlparse import urljoin
+from urllib2 import urlopen
+
+def get_recipepath_class(root, path):
+ if root == None:
+ if path.startswith('http'):
+ return HttpRecipePath(root, path)
+ else:
+ if os.access(path, os.R_OK):
+ return FileRecipePath(root, path)
+ else:
+ raise Exception("Recipe path does not exist \"%s\"!" % path)
+
+ if root.startswith('http'):
+ return HttpRecipePath(root, path)
+ elif os.access(root, os.R_OK):
+ return FileRecipePath(root, path)
+ else:
+ raise Exception("Could not recognize recipe path type \"%s\"" % path)
+
+class RecipePath:
+ def __init__(self, root, path):
+ self._recipepath_class = get_recipepath_class(root, path)
+
+ def get_root(self):
+ return self._recipepath_class.get_root()
+
+ def abs_path(self):
+ return self._recipepath_class.abs_path()
+
+ def to_str(self):
+ return self._recipepath_class.to_str()
+
+class RecipePathGeneric:
+ def __init__(self, root, path):
+ self._root = root
+ self._path = path
+ self._data = None
+
+ def get_root(self):
+ pass
+
+ def abs_path(self):
+ pass
+
+ def to_str(self):
+ pass
+
+class FileRecipePath(RecipePathGeneric):
+ def _load_file(self):
+ f = open(self.abs_path(),'r')
+ self._data = f.read()
+ f.close()
+
+ def to_str(self):
+ if not self._data:
+ self._load_file()
+
+ return self._data
+
+ def _append_path(self, path):
+ basedir = os.path.dirname(self._path)
+ return os.path.join(basedir, path)
+
+ def abs_path(self):
+ if self._root:
+ return os.path.normpath(os.path.join(self._root,
+ os.path.expanduser(self._path)))
+ else:
+ return os.path.normpath(os.path.expanduser(self._path))
+
+ def get_root(self):
+ return os.path.dirname(self.abs_path())
+
+class HttpRecipePath(RecipePathGeneric):
+ def _get_url(self):
+ url = self.abs_path()
+
+ try:
+ f = urlopen(url)
+ self._data = f.read()
+ except IOError, err:
+ msg = "Unable to resolve path: %s (%s)" % (url, str(err))
+ raise Exception(msg)
+
+ f.close()
+
+ def to_str(self):
+ if not self._data:
+ self._get_url()
+
+ return self._data
+
+ def abs_path(self):
+ if self._root:
+ return urljoin(self._root + '/', self._path)
+ else:
+ return self._path
+
+ def get_root(self):
+ url = self.abs_path()
+ return url.rpartition('/')[0]
--
1.7.7.6
11 years, 7 months
[lnst trac] #29: add documentation to project wiki
by fedora-badges
#29: add documentation to project wiki
------------------------+-----------------------
Reporter: jtluka | Owner: somebody
Type: task | Status: new
Priority: major | Milestone:
Component: component1 | Version:
Keywords: | Blocked By: 27
Blocking: |
------------------------+-----------------------
We'd like to impress LNST users with fancy looking wiki page. This ticket
is blocked by current documentation update tracked in separate ticket.
--
Ticket URL: <https://fedorahosted.org/lnst/ticket/29>
lnst <http://example.org/>
My example project
11 years, 7 months
[lnst] XmlProccessing: no password bug fix
by Jiří Pírko
commit 28dede0a27e81a38965ab937b9a2481ef4ffba15
Author: Ondrej Lichtner <olichtne(a)redhat.com>
Date: Mon Sep 24 09:13:21 2012 +0200
XmlProccessing: no password bug fix
Machine passwords are optional, however not specifying one causes the
controller crash with an undescriptive error message. This is caused by
the fact that in these cases None value is used instead of the password.
This commit changes that by using an empty string as the password when
it isn't specified in the recipe.
I also changed the error message for failed password authentification,
so that it is more clear that the password failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
Common/SshUtils.py | 7 ++++---
NetTest/NetTestController.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/Common/SshUtils.py b/Common/SshUtils.py
index 340f119..f44f603 100644
--- a/Common/SshUtils.py
+++ b/Common/SshUtils.py
@@ -58,7 +58,8 @@ class SCPError(Exception):
self.output = output
def __str__(self):
- return "%s (output: %r)" % (self.msg, self.output)
+ indented = "\n".join((4 * " ") + i for i in self.output.splitlines())
+ return "%s%s" % (self.msg, indented)
class SCPAuthenticationError(SCPError):
@@ -127,7 +128,7 @@ def _remote_login(session, username, password, prompt, timeout=10):
password_prompt_count += 1
continue
else:
- raise LoginAuthenticationError("Got password prompt twice",
+ raise LoginAuthenticationError("Invalid password",
text)
elif match == 2: # "login:"
if login_prompt_count == 0 and password_prompt_count == 0:
@@ -294,7 +295,7 @@ def _remote_scp(session, password_list, transfer_timeout=600, login_timeout=10):
authentication_done = True
continue
else:
- raise SCPAuthenticationError("Got password prompt twice",
+ raise SCPAuthenticationError("Invalid password",
text)
elif match == 2: # "lost connection"
raise SCPError("SCP client said 'lost connection'", text)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 526a3e7..e9735b4 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -227,7 +227,7 @@ class NetTestController:
if "rootpass" in info:
passwd = info["rootpass"]
else:
- passwd = None
+ passwd = ''
logging.info("Remote app exec on machine %s", hostname)
port = "22"
11 years, 7 months
[PATCH] XmlProccessing: no password bug fix
by Ondrej Lichtner
From: Ondrej Lichtner <olichtne(a)redhat.com>
Machine passwords are optional, however not specifying one causes the
controller crash with an undescriptive error message. This is caused by
the fact that in these cases None value is used instead of the password.
This commit changes that by using an empty string as the password when
it isn't specified in the recipe.
I also changed the error message for failed password authentification,
so that it is more clear that the password failed.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
Common/SshUtils.py | 7 ++++---
NetTest/NetTestController.py | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Common/SshUtils.py b/Common/SshUtils.py
index 340f119..f44f603 100644
--- a/Common/SshUtils.py
+++ b/Common/SshUtils.py
@@ -58,7 +58,8 @@ class SCPError(Exception):
self.output = output
def __str__(self):
- return "%s (output: %r)" % (self.msg, self.output)
+ indented = "\n".join((4 * " ") + i for i in self.output.splitlines())
+ return "%s%s" % (self.msg, indented)
class SCPAuthenticationError(SCPError):
@@ -127,7 +128,7 @@ def _remote_login(session, username, password, prompt, timeout=10):
password_prompt_count += 1
continue
else:
- raise LoginAuthenticationError("Got password prompt twice",
+ raise LoginAuthenticationError("Invalid password",
text)
elif match == 2: # "login:"
if login_prompt_count == 0 and password_prompt_count == 0:
@@ -294,7 +295,7 @@ def _remote_scp(session, password_list, transfer_timeout=600, login_timeout=10):
authentication_done = True
continue
else:
- raise SCPAuthenticationError("Got password prompt twice",
+ raise SCPAuthenticationError("Invalid password",
text)
elif match == 2: # "lost connection"
raise SCPError("SCP client said 'lost connection'", text)
diff --git a/NetTest/NetTestController.py b/NetTest/NetTestController.py
index 526a3e7..e9735b4 100644
--- a/NetTest/NetTestController.py
+++ b/NetTest/NetTestController.py
@@ -227,7 +227,7 @@ class NetTestController:
if "rootpass" in info:
passwd = info["rootpass"]
else:
- passwd = None
+ passwd = ''
logging.info("Remote app exec on machine %s", hostname)
port = "22"
--
1.7.11.4
11 years, 7 months
[lnst] team: use teamdctl for adding/removing ports
by Jiří Pírko
commit 27e92ce2e8f0e0fd7edab3ef924e614fd526890b
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Fri Sep 21 09:00:09 2012 -0400
team: use teamdctl for adding/removing ports
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
NetConfig/NetConfigDevice.py | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/NetConfig/NetConfigDevice.py b/NetConfig/NetConfigDevice.py
index 1da5afa..0a2d5d4 100644
--- a/NetConfig/NetConfigDevice.py
+++ b/NetConfig/NetConfigDevice.py
@@ -16,7 +16,7 @@ import re
import sys
from Common.ExecCmd import exec_cmd
from NetConfigCommon import get_slaves, get_option
-from Common.Utils import kmod_in_use
+from Common.Utils import kmod_in_use, bool_it
class NetConfigDeviceGeneric:
'''
@@ -224,10 +224,9 @@ class NetConfigDeviceTeam(NetConfigDeviceGeneric):
_cleanupcmd = "killall -q teamd"
def _should_enable_dbus(self):
- for slave_id in get_slaves(self._netdev):
- port_netdev = self._config[slave_id]
- if get_option(port_netdev, "teamd_port_config"):
- return True
+ dbus_disabled = get_option(self._netdev, "dbus_disabled")
+ if not dbus_disabled or bool_it(dbus_disabled):
+ return True
return False
def _ports_down(self):
@@ -276,11 +275,12 @@ class NetConfigDeviceTeam(NetConfigDeviceGeneric):
teamd_port_config = prepare_json_str(teamd_port_config)
exec_cmd("teamdctl %s PortConfigUpdate %s \"%s\"" % (dev_name, port_name, teamd_port_config))
NetConfigDevice(port_netdev, self._config).down()
- exec_cmd("ip link set dev %s master %s" % (port_name, dev_name))
+ exec_cmd("teamdctl %s PortAdd %s" % (dev_name, port_name))
def slave_del(self, slaveid):
+ dev_name = self._netdev["name"]
port_name = self._config[slaveid]["name"]
- exec_cmd("ip link set dev %s nomaster" % (port_name))
+ exec_cmd("teamdctl %s PortRemove %s" % (dev_name, port_name))
type_class_mapping = {
"eth": NetConfigDeviceEth,
11 years, 7 months
[lnst] move bool_it and int_it into Common.Utils
by Jiří Pírko
commit 1ccb815a7ebe0d8376b72c128f1dc3d79cdff645
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Fri Sep 21 12:44:52 2012 -0400
move bool_it and int_it into Common.Utils
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
Common/Utils.py | 15 +++++++++++++++
NetTest/NetTestParse.py | 21 ++-------------------
2 files changed, 17 insertions(+), 19 deletions(-)
---
diff --git a/Common/Utils.py b/Common/Utils.py
index 5f3f251..bae3043 100644
--- a/Common/Utils.py
+++ b/Common/Utils.py
@@ -70,3 +70,18 @@ def kmod_in_use(modulename, tries = 1):
if (ret and tries):
return kmod_in_use(modulename, tries)
return ret
+
+def int_it(val):
+ try:
+ num = int(val)
+ except ValueError:
+ num = 0
+ return num
+
+def bool_it(val):
+ if isinstance(val, str):
+ if re.match("^\s*(?i)(true)", val):
+ return True
+ elif re.match("^\s*(?i)(false)", val):
+ return False
+ return True if int_it(val) else False
diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py
index 4f54624..76068dd 100644
--- a/NetTest/NetTestParse.py
+++ b/NetTest/NetTestParse.py
@@ -17,6 +17,7 @@ from Common.XmlProcessing import RecipeParser
from Common.XmlProcessing import XmlDomTreeInit
from Common.XmlProcessing import XmlProcessingError
from Common.NetUtils import normalize_hwaddr
+from Common.Utils import bool_it
class NetTestParse(RecipeParser):
def __init__(self, recipe_filepath):
@@ -428,7 +429,7 @@ class CommandParse(RecipeParser):
if self._has_attribute(node, "persistent"):
command["persistent"] = self._get_attribute(node, "persistent",
- self._bool_it)
+ bool_it)
else:
command["persistent"] = False
@@ -471,21 +472,3 @@ class CommandParse(RecipeParser):
else:
msg = "Unknown option type \"%s\"" % opt_type
raise XmlProcessingError(msg, node)
-
-
- @classmethod
- def _int_it(cls, val):
- try:
- num = int(val)
- except ValueError:
- num = 0
- return num
-
- @classmethod
- def _bool_it(cls, val):
- if isinstance(val, str):
- if re.match("^\s*(?i)(true)", val):
- return True
- elif re.match("^\s*(?i)(false)", val):
- return False
- return True if cls._int_it(val) else False
11 years, 7 months
[PATCH] Recipes and sourced bits can now be represented by HTTP url
by Jan Tluka
The change allows user to specify both local file and http urls as
recipe and sourced recipe bits (using 'source' attribute). Relative paths
are automagically resolved. See usage below in tested scenarios.
Tested for following use cases:
1. url supplied to controller on command line
# nettestctl.py -c http://somedomain.com/jtluka/rhel63-tests/bond-tests/bond-mode5-scenario1... run
2. relative local file path supplied to controller
# nettestctl.py -c ./rhel63-tests/bond-tests/bond-mode5-scenario1.xml run
3. relative local directory path supplied to controller
# nettestctl.py -c ./rhel63-tests/bond-tests/ run
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
Common/XmlProcessing.py | 14 ++++++++------
NetTest/NetTestParse.py | 6 ++++--
nettestctl.py | 2 +-
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/Common/XmlProcessing.py b/Common/XmlProcessing.py
index 5aa7ccd..396a172 100644
--- a/Common/XmlProcessing.py
+++ b/Common/XmlProcessing.py
@@ -15,6 +15,7 @@ import logging
from xml.dom.minidom import parseString
from xml import sax
from Common.XmlTemplates import XmlTemplates, XmlTemplateError
+from Common.RecipePath import RecipePath
class XmlProcessingError(Exception):
@@ -225,6 +226,8 @@ class RecipeParser(XmlParser):
else:
self._recipe = {}
self._template_proc = XmlTemplates()
+ # TODO: not sure what this could break ...
+ # include root for http recipe is not compatible with this
self._include_root = os.getcwd()
self._events_enabled = True
self._event_handlers = {}
@@ -281,14 +284,16 @@ class RecipeParser(XmlParser):
old_include_root = None
if self._has_attribute(node, "source"):
source = self._get_attribute(node, "source")
- file_path = self._get_referenced_xml_path(source)
+
+ source_rp = RecipePath(self._include_root, source)
old_include_root = self._include_root
- self._include_root = os.path.dirname(file_path)
+ self._include_root = source_rp.get_root()
+ xmlstr = source_rp.to_str()
dom_init = XmlDomTreeInit()
try:
- dom = dom_init.parse_file(file_path)
+ dom = dom_init.parse_string(xmlstr)
except IOError, err:
msg = "Unable to resolve include: %s" % str(err)
raise XmlProcessingError(msg, node)
@@ -361,6 +366,3 @@ class RecipeParser(XmlParser):
self._template_proc.define_alias(name, value)
except XmlTemplateError, err:
raise XmlProcessingError(str(err), node)
-
- def _get_referenced_xml_path(self, filename):
- return os.path.normpath(os.path.join(self._include_root, os.path.expanduser(filename)))
diff --git a/NetTest/NetTestParse.py b/NetTest/NetTestParse.py
index 4f54624..94e5502 100644
--- a/NetTest/NetTestParse.py
+++ b/NetTest/NetTestParse.py
@@ -17,20 +17,22 @@ from Common.XmlProcessing import RecipeParser
from Common.XmlProcessing import XmlDomTreeInit
from Common.XmlProcessing import XmlProcessingError
from Common.NetUtils import normalize_hwaddr
+from Common.RecipePath import RecipePath
class NetTestParse(RecipeParser):
def __init__(self, recipe_filepath):
super(NetTestParse, self).__init__()
self._filepath = recipe_filepath
- self._include_root = os.path.dirname(recipe_filepath)
+ self._rp = RecipePath(None, self._filepath)
+ self._include_root = self._rp.get_root()
self._recipe = {}
self._template_proc.set_definitions({"recipe": self._recipe})
def parse_recipe(self):
dom_init = XmlDomTreeInit()
- xml_dom = dom_init.parse_file(self._filepath)
+ xml_dom = dom_init.parse_string(self._rp.to_str())
self._parse(xml_dom)
def _parse(self, xml_dom):
diff --git a/nettestctl.py b/nettestctl.py
index bc79398..f9973e4 100755
--- a/nettestctl.py
+++ b/nettestctl.py
@@ -47,7 +47,7 @@ def usage():
def process_recipe(action, file_path, remoteexec, cleanup,
res_serializer, packet_capture, config):
- nettestctl = NetTestController(os.path.realpath(file_path),
+ nettestctl = NetTestController(file_path,
remoteexec=remoteexec, cleanup=cleanup,
res_serializer=res_serializer,
config=config)
--
1.7.7.6
11 years, 7 months
[PATCH] Adding RecipePath module to handle both local and http paths
by Jan Tluka
RecipePath module is an abstraction over paths that can be specified on
command line and inside recipe files. Currently module supports local files
and HTTP urls but it's possible to extend the functionality for other,
e.g. FTP.
Signed-off-by: Jan Tluka <jtluka(a)redhat.com>
---
Common/RecipePath.py | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 115 insertions(+), 0 deletions(-)
create mode 100644 Common/RecipePath.py
diff --git a/Common/RecipePath.py b/Common/RecipePath.py
new file mode 100644
index 0000000..b5f650c
--- /dev/null
+++ b/Common/RecipePath.py
@@ -0,0 +1,115 @@
+"""
+This module contains code code for LNST recipe paths and references.
+
+Copyright 2012 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+jtluka(a)redhat.com (Jan Tluka)
+"""
+
+import os
+from urlparse import urljoin
+from urllib2 import urlopen
+
+def get_recipepath_class(root, path):
+ if root == None:
+ if path.startswith('http'):
+ return HttpRecipePath(root, path)
+ else:
+ if os.access(path, os.R_OK):
+ return FileRecipePath(root, path)
+ else:
+ raise Exception("Recipe path does not exist \"%s\"!" % path)
+
+ if root.startswith('http'):
+ return HttpRecipePath(root, path)
+ elif os.access(root, os.R_OK):
+ return FileRecipePath(root, path)
+ else:
+ raise Exception("Could not recognize recipe path type \"%s\"" % path)
+
+class RecipePath:
+ def __init__(self, root, path):
+ self._recipepath_class = get_recipepath_class(root, path)
+
+ def get_root(self):
+ return self._recipepath_class.get_root()
+
+ def abs_path(self):
+ return self._recipepath_class.abs_path()
+
+ def to_str(self):
+ return self._recipepath_class.to_str()
+
+class RecipePathGeneric:
+ def __init__(self, root, path):
+ self._root = root
+ self._path = path
+ self._data = None
+
+ def get_root(self):
+ pass
+
+ def abs_path(self):
+ pass
+
+ def to_str(self):
+ pass
+
+class FileRecipePath(RecipePathGeneric):
+ def _load_file(self):
+ f = open(self.abs_path(),'r')
+ self._data = f.read()
+ f.close()
+
+ def to_str(self):
+ if not self._data:
+ self._load_file()
+
+ return self._data
+
+ def _append_path(self, path):
+ basedir = os.path.dirname(self._path)
+ return os.path.join(basedir, path)
+
+ def abs_path(self):
+ if self._root:
+ return os.path.normpath(os.path.join(self._root,
+ os.path.expanduser(self._path)))
+ else:
+ return os.path.normpath(os.path.expanduser(self._path))
+
+ def get_root(self):
+ return os.path.dirname(self.abs_path())
+
+class HttpRecipePath(RecipePathGeneric):
+ def _get_url(self):
+ url = self.abs_path()
+
+ try:
+ f = urlopen(url)
+ self._data = f.read()
+ except IOError, err:
+ msg = "Unable to resolve path: %s (%s)" % (url, str(err))
+ raise Exception(msg)
+
+ f.close()
+
+ def to_str(self):
+ if not self._data:
+ self._get_url()
+
+ return self._data
+
+ def abs_path(self):
+ if self._root:
+ return urljoin(self._root + '/', self._path)
+ else:
+ return self._path
+
+ def get_root(self):
+ url = self.abs_path()
+ return url.rpartition('/')[0]
--
1.7.7.6
11 years, 7 months
[lnst] team recipes: add two lacp ones for configuration
by Jiří Pírko
commit 07b91594eca3007879b843c71c674d833fc1a738
Author: Jiri Pirko <jiri(a)resnulli.us>
Date: Thu Sep 20 16:39:18 2012 +0200
team recipes: add two lacp ones for configuration
Signed-off-by: Jiri Pirko <jiri(a)resnulli.us>
recipes/team/netconfig-team_lacp_passive.xml | 38 +++++++++++++++++++++++++
recipes/team/netconfig-team_lacp_slowrate.xml | 38 +++++++++++++++++++++++++
recipes/team/recipey_lacp_passive.xml | 21 +++++++++++++
recipes/team/recipey_lacp_slowrate.xml | 21 +++++++++++++
4 files changed, 118 insertions(+), 0 deletions(-)
---
diff --git a/recipes/team/netconfig-team_lacp_passive.xml b/recipes/team/netconfig-team_lacp_passive.xml
new file mode 100644
index 0000000..ef4cf91
--- /dev/null
+++ b/recipes/team/netconfig-team_lacp_passive.xml
@@ -0,0 +1,38 @@
+<netconfig>
+ <interface id="1" phys_id="1" type="eth">
+ <options>
+ <option name="teamd_port_config">
+ {
+ "prio": -10
+ }
+ </option>
+ </options>
+ </interface>
+ <interface id="2" phys_id="2" type="eth"/>
+ <interface id="3" phys_id="3" type="eth"/>
+ <interface id="testiface" type="team">
+ <options>
+ <option name="teamd_config">
+ {
+ "hwaddr": "00:11:22:33:44:55",
+ "runner": {
+ "name": "lacp",
+ "active": false,
+ "fast_rate": true,
+ "tx_hash": ["eth", "ipv4", "ipv6"]
+ },
+ "link_watch": {"name": "ethtool"}
+ }
+ </option>
+ </options>
+ <slaves>
+ <slave id="1"/>
+ <slave id="2"/>
+ <slave id="3"/>
+ </slaves>
+ <addresses>
+ <address value="{$testip}"/>
+ <address value="{$testip6}"/>
+ </addresses>
+ </interface>
+</netconfig>
diff --git a/recipes/team/netconfig-team_lacp_slowrate.xml b/recipes/team/netconfig-team_lacp_slowrate.xml
new file mode 100644
index 0000000..c90fece
--- /dev/null
+++ b/recipes/team/netconfig-team_lacp_slowrate.xml
@@ -0,0 +1,38 @@
+<netconfig>
+ <interface id="1" phys_id="1" type="eth">
+ <options>
+ <option name="teamd_port_config">
+ {
+ "prio": -10
+ }
+ </option>
+ </options>
+ </interface>
+ <interface id="2" phys_id="2" type="eth"/>
+ <interface id="3" phys_id="3" type="eth"/>
+ <interface id="testiface" type="team">
+ <options>
+ <option name="teamd_config">
+ {
+ "hwaddr": "00:11:22:33:44:55",
+ "runner": {
+ "name": "lacp",
+ "active": true,
+ "fast_rate": false,
+ "tx_hash": ["eth", "ipv4", "ipv6"]
+ },
+ "link_watch": {"name": "ethtool"}
+ }
+ </option>
+ </options>
+ <slaves>
+ <slave id="1"/>
+ <slave id="2"/>
+ <slave id="3"/>
+ </slaves>
+ <addresses>
+ <address value="{$testip}"/>
+ <address value="{$testip6}"/>
+ </addresses>
+ </interface>
+</netconfig>
diff --git a/recipes/team/recipey_lacp_passive.xml b/recipes/team/recipey_lacp_passive.xml
new file mode 100644
index 0000000..5e88fdf
--- /dev/null
+++ b/recipes/team/recipey_lacp_passive.xml
@@ -0,0 +1,21 @@
+<nettestrecipe>
+ <machines>
+ <define>
+ <alias name="testip" value="192.168.111.1/24"/>
+ <alias name="testip6" value="fe01::1/64"/>
+ </define>
+ <machine id="1">
+ <machineconfig source="machineconfig-peanut.xml"/>
+ <netconfig source="netconfig-team_lacp_passive.xml"/>
+ </machine>
+ <define>
+ <alias name="testip" value="192.168.111.2/24"/>
+ <alias name="testip6" value="fe01::2/64"/>
+ </define>
+ <machine id="2">
+ <machineconfig source="machineconfig-dhcp-37-128.xml"/>
+ <netconfig source="netconfig-bond_lacp.xml"/>
+ </machine>
+ </machines>
+ <command_sequence source="sequence_ping_simple.xml"/>
+</nettestrecipe>
diff --git a/recipes/team/recipey_lacp_slowrate.xml b/recipes/team/recipey_lacp_slowrate.xml
new file mode 100644
index 0000000..1daead2
--- /dev/null
+++ b/recipes/team/recipey_lacp_slowrate.xml
@@ -0,0 +1,21 @@
+<nettestrecipe>
+ <machines>
+ <define>
+ <alias name="testip" value="192.168.111.1/24"/>
+ <alias name="testip6" value="fe01::1/64"/>
+ </define>
+ <machine id="1">
+ <machineconfig source="machineconfig-peanut.xml"/>
+ <netconfig source="netconfig-team_lacp_slowrate.xml"/>
+ </machine>
+ <define>
+ <alias name="testip" value="192.168.111.2/24"/>
+ <alias name="testip6" value="fe01::2/64"/>
+ </define>
+ <machine id="2">
+ <machineconfig source="machineconfig-dhcp-37-128.xml"/>
+ <netconfig source="netconfig-bond_lacp.xml"/>
+ </machine>
+ </machines>
+ <command_sequence source="sequence_ping_simple.xml"/>
+</nettestrecipe>
11 years, 7 months