Alon Bar-Lev has uploaded a new change for review. Change subject: bootstrap: allow customize bridge name for standard sequence ......................................................................
bootstrap: allow customize bridge name for standard sequence For gluster integration, we need bootstrap to be able to accept management bridge name within bootstrap and not relay on vdsm build time settings. As gluster only performs standard host bootstrap (as opposed to registration), the customization will be available only for this sequence. In future the registration sequence will be altered to match the standard sequence. Change-Id: I70c178de55e14ecdcff92270df489dc1415ef26f Signed-off-by: Alon Bar-Lev <[email protected]> Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=863717 --- M vds_bootstrap/setup M vds_bootstrap/vds_bootstrap.py M vdsm_reg/deployUtil.py.in 3 files changed, 57 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/88/8388/1 diff --git a/vds_bootstrap/setup b/vds_bootstrap/setup index b669743..685c92f 100755 --- a/vds_bootstrap/setup +++ b/vds_bootstrap/setup @@ -143,7 +143,7 @@ return fReturn -def runInstaller(bootstrap_interface_version, remote_nfs, orgName, systime, vds_config_str, url_rpm, vds_server, random_num, script, vds_complete, firewall_rules_file, engine_ssh_key, rebootAfterInstallation, installVirtualizationService, installGlusterService): +def runInstaller(bootstrap_interface_version, remote_nfs, orgName, systime, vds_config_str, url_rpm, vds_server, random_num, script, vds_complete, firewall_rules_file, engine_ssh_key, rebootAfterInstallation, installVirtualizationService, installGlusterService, bridgeName): """ -- Run VDS bootstrap scripts """ try: @@ -165,6 +165,8 @@ execfn += ["-f", firewall_rules_file] if engine_ssh_key: execfn += ["-S", engine_ssh_key] + if bridgeName: + execfn += ["-B", bridgeName] execfn += [url_rpm, vds_server, random_num] else: if vds_config_str: @@ -267,7 +269,7 @@ return ssh_result def main(): - """Usage: vds_installer.py [-c vds_config_str] [-v ver] [-m remote_nfs] [-r rev_num] [-O organizationName] [-t YYYY-MM-DDTHH:mm:SS_system_time] [-S engine-ssh-key] [-p engine_port] [-V] [-g] <url_bs> <url_rpm> <vds_server> <random_num> <vds_complete> + """Usage: vds_installer.py [-c vds_config_str] [-v ver] [-m remote_nfs] [-r rev_num] [-O organizationName] [-t YYYY-MM-DDTHH:mm:SS_system_time] [-S engine-ssh-key] [-p engine_port] [-B bridge_name] [-V] [-g] <url_bs> <url_rpm> <vds_server> <random_num> <vds_complete> url_bs - components url url_rpm - rpm download url random_num - random number for temp. file names generation @@ -275,6 +277,7 @@ vds_complete - to run first vds_bootstrap script = false to run second vds_bootstrap_complete script = true -v - interface version, default=2 + -B - bridge name, default is installation specific -V - don't install virutalization components on the host """ try: @@ -290,7 +293,8 @@ rebootAfterInstallation = False installVirtualizationService = True installGlusterService = False - opts, args = getopt.getopt(sys.argv[1:], "c:m:r:O:t:p:bf:S:gVv:") + bridgeName = False + opts, args = getopt.getopt(sys.argv[1:], "c:m:r:O:t:p:bf:S:gB:Vv:") for o,v in opts: if o == "-v": bootstrap_interface_version = int(v) @@ -312,6 +316,8 @@ engine_ssh_key = v if o == "-b": rebootAfterInstallation = True + if o == "-B": + bridgeName = v if o == "-V": installVirtualizationService = False if o == "-g": @@ -363,7 +369,8 @@ engine_ssh_key, rebootAfterInstallation, installVirtualizationService, - installGlusterService): + installGlusterService, + bridgeName): return False if firewall_rules_file is not None: diff --git a/vds_bootstrap/vds_bootstrap.py b/vds_bootstrap/vds_bootstrap.py index 56db478..867d6f4 100755 --- a/vds_bootstrap/vds_bootstrap.py +++ b/vds_bootstrap/vds_bootstrap.py @@ -247,6 +247,9 @@ """ This class holds the relevant functionality for vdsm deployment on RHEL. """ + def __init__(self, bridgeName=None): + self._bridgeName = bridgeName + def _xmlOutput(self, component, status, resultKey, result, msg, test=False): """ Internal: publish results to server and log. @@ -704,7 +707,11 @@ #add management bridge try: - fReturn = deployUtil.makeBridge(vdcName, VDSM_DIR) + fReturn = deployUtil.makeBridge( + vdcName, + VDSM_DIR, + bridgeName=self._bridgeName + ) if fReturn: #save current config by removing the undo files: if not vdcPort: vdcPort = 80 @@ -780,7 +787,7 @@ if rhel6based: deployUtil.setService("libvirtd", "start") - if deployUtil.preventDuplicate(): + if deployUtil.preventDuplicate(bridgeName=self._bridgeName): self.message = "Bridge management already exists. Skipping bridge creation." logging.debug(self.message) else: @@ -926,17 +933,17 @@ def VdsValidation(iurl, subject, random_num, rev_num, orgName, systime, firewallRulesFile, engine_ssh_key, installVirtualizationService, - installGlusterService, miniyum): + installGlusterService, bridgeName, miniyum): """ --- Check VDS Compatibility. """ - logging.debug("Entered VdsValidation(subject = '%s', random_num = '%s', rev_num = '%s', installVirtualizationService = '%s', installGlusterService = '%s')"%(subject, random_num, rev_num, installVirtualizationService, installGlusterService)) + logging.debug("Entered VdsValidation(subject = '%s', random_num = '%s', rev_num = '%s', installVirtualizationService = '%s', installGlusterService = '%s', bridgeName = '%s')"%(subject, random_num, rev_num, installVirtualizationService, installGlusterService, bridgeName)) if installGlusterService: if not rhel6based: logging.error('unsupported system for Gluster service') return False - oDeploy = Deploy() + oDeploy = Deploy(bridgeName=bridgeName) if systime: if not oDeploy.setSystemTime(systime): @@ -1055,7 +1062,8 @@ engine_ssh_key = None installVirtualizationService = True installGlusterService = False - opts, args = getopt.getopt(sys.argv[1:], "v:r:O:t:f:S:n:u:Vg") + bridgeName = None + opts, args = getopt.getopt(sys.argv[1:], "v:r:O:t:f:S:n:u:B:Vg") for o,v in opts: if o == "-v": deployUtil.setBootstrapInterfaceVersion(int(v)) @@ -1074,6 +1082,8 @@ NEEDED_SERVICES.append('iptables') elif o == '-S': engine_ssh_key = v + elif o == '-B': + bridgeName = v url = args[0] subject = args[1] @@ -1111,7 +1121,7 @@ url, subject, random_num, rev_num, orgName, systime, firewallRulesFile, engine_ssh_key, installVirtualizationService, installGlusterService, - miniyum + bridgeName, miniyum ) except: logging.error("VDS validation failed", exc_info=True) diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in index fc8fd08..d9a7ad2 100644 --- a/vdsm_reg/deployUtil.py.in +++ b/vdsm_reg/deployUtil.py.in @@ -454,17 +454,19 @@ logging.debug("getMGTIP: Host MGT IP=" + strReturn) return strReturn -def preventDuplicate(): +def preventDuplicate(bridgeName=None): """ This function checks if the needed bridge (@VDSMBRIDGE@) already exist. """ + if bridgeName is None: + bridgeName = MGT_BRIDGE_NAME fFound = False - if os.path.exists('/sys/class/net/' + MGT_BRIDGE_NAME): + if os.path.exists('/sys/class/net/' + bridgeName): fFound = True - logging.debug("Bridge " + MGT_BRIDGE_NAME + " already exists.") + logging.debug("Bridge %s already exists." % bridgeName) else: - logging.debug("Bridge " + MGT_BRIDGE_NAME + " not found, need to create it.") + logging.debug("Bridge %s not found, need to create it." % bridgeName) return fFound @@ -899,7 +901,7 @@ return vlan, bonding, nic -def _getRHELBridgeParams(mgtIface): +def _getRHELBridgeParams(mgtIface, bridgeName=None): """ This helper function extract the relevant parameters of the existing RHEL interface, in order to create a managment bridge. @@ -919,9 +921,14 @@ nic = mgtIface if nic in netinfo.bondings(): - logging.error("_getRHELBridgeParams Found bonding: " + str(nic) + \ - ". This network configuration is not" \ - "supported! Please configure " + MGT_BRIDGE_NAME + " bridge manually and re-install.") + logging.error( + ( + "_getRHELBridgeParams Found bonding: %s." + "This network configuration is not" + "supported! Please configure %s bridge" + "manually and re-install." + ) % (str(nic), bridgeName) + ) nic = None except: logging.error("_getRHELBridgeParams Failed to test for VLAN data") @@ -943,11 +950,13 @@ os.remove(f) -def makeBridge(vdcName, vdsmDir): +def makeBridge(vdcName, vdsmDir, bridgeName=None): """ Create (for RHEL) or rename (oVirt default bridge) to @VDSMBRIDGE@ bridge. """ logging.debug('makeBridge begin.') + if bridgeName is None: + bridgeName = MGT_BRIDGE_NAME try: vdsmImport("netinfo", vdsmDir) @@ -992,7 +1001,7 @@ if fIsOvirt: vlan, bonding, nic = _getOvirtBridgeParams(mgtBridge) else: - vlan, bonding, nic = _getRHELBridgeParams(mgtIface) + vlan, bonding, nic = _getRHELBridgeParams(mgtIface, bridgeName=bridgeName) fReturn = (nic is not None) #Delete existing bridge in oVirt @@ -1011,17 +1020,22 @@ fReturn = False logging.debug("makeBridge Failed to del existing bridge. out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret)) - #Add @VDSMBRIDGE@ bridge + #Add bridge if fReturn: try: lstBridgeOptions.append('blockingdhcp=true') - out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_ADD) , MGT_BRIDGE_NAME, vlan, bonding, nic] + lstBridgeOptions) + out, err, ret = _logExec([os.path.join(vdsmDir, SCRIPT_NAME_ADD) , bridgeName, vlan, bonding, nic] + lstBridgeOptions) if ret: - fReturn = False - logging.debug("makeBridge Failed to add " + MGT_BRIDGE_NAME + " bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret)) + raise Exception('Failed to add bridge') except: fReturn = False - logging.debug("makeBridge Failed to add " + MGT_BRIDGE_NAME + " bridge out=" + out + "\nerr=" + str(err) + "\nret=" + str(ret)) + logging.debug( + ( + "makeBridge Failed to add %s bridge out=%s\n" + "err=%s\n" + "ret=%s" + ) % (bridgeName, out, str(err), str(ret)) + ) #Save current config by removing the undo files: try: -- To view, visit http://gerrit.ovirt.org/8388 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I70c178de55e14ecdcff92270df489dc1415ef26f Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
