def main(): if hooking.tobool(os.environ.get('ifacemacspoof')): domxml = hooking.read_domxml() interface, = domxml.getElementsByTagName('interface') removeMacSpoofingFilter(interface) hooking.write_domxml(domxml)
def _top_dev(network, attrs): if hooking.tobool(attrs.get('bridged')): return network # bridgeless nics, vlan, _, bonding = netinfo.cache.NetInfo( netswitch.configurator.netinfo()).getNicsVlanAndBondingForNetwork( network) return vlan or bonding or nics[0]
def hook(): import hooking if hooking.tobool(os.environ.get('kvmhidden')): try: domxml = hooking.read_domxml() domxml = kvmhidden(domxml) hooking.write_domxml(domxml) except: sys.stderr.write('kvmhidden: [unexpected error]: %s\n' % traceback.format_exc()) sys.exit(2)
def hook(): import hooking if hooking.tobool(os.environ.get('apicfeature')): try: domxml = hooking.read_domxml() domxml = apic_feature(domxml) hooking.write_domxml(domxml) except: sys.stderr.write('apic-feature: [unexpected error]: %s\n' % traceback.format_exc()) sys.exit(2)
def hook(): import hooking if hooking.tobool(os.environ.get('cpuhostmodelcheckpartial')): try: domxml = hooking.read_domxml() domxml = cpuhostmodelcheckpartial(domxml) hooking.write_domxml(domxml) except: sys.stderr.write( 'cpuhostmodelcheckpartial: [unexpected error]: %s\n' % traceback.format_exc()) sys.exit(2)
def main(vhostmd_conf): if hooking.tobool(os.environ.get("sap_agent", False)): domxml = hooking.read_domxml() subprocess.call(["/usr/bin/sudo", "-n", "/sbin/service", "vhostmd", "start"]) if VhostmdTransport.VBD in vhostmd_conf.transports: add_vbd_device(domxml, vhostmd_conf.vbd_path) if VhostmdTransport.VIRTIO in vhostmd_conf.transports: add_virtio_device(domxml) hooking.write_domxml(domxml)
def main(): """ Create lists of running networks and networks to be (un)configured as FCoE or removed. """ existing_fcoe_networks = _all_configured_fcoe_networks() changed_fcoe = {} changed_non_fcoe = {} removed_networks = {} custom_parameters = {} setup_nets_config = hooking.read_json() changed_all = setup_nets_config['request']['networks'] for net, net_attr in six.iteritems(changed_all): custom_parameters_string = net_attr.get('custom', {}).get('fcoe', '') custom_parameters[net] = _parse_custom(custom_parameters_string) if _has_fcoe(net_attr): changed_fcoe[net] = net_attr.get('nic') elif hooking.tobool(net_attr.get('remove')): removed_networks[net] = net_attr.get('nic') else: changed_non_fcoe[net] = net_attr.get('nic') removed_service_restart_required = _unconfigure_removed( existing_fcoe_networks, removed_networks ) non_fcoe_service_restart_required = _unconfigure_non_fcoe( existing_fcoe_networks, changed_non_fcoe ) reconfigure_service_restart_required = _reconfigure_fcoe( existing_fcoe_networks, changed_fcoe, custom_parameters ) if ( removed_service_restart_required or non_fcoe_service_restart_required or reconfigure_service_restart_required ): # TODO If services are failed to start restore previous configuration # and notify user ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'lldpad']) if ret: hooking.log('Failed to restart lldpad service. err = %s' % (err)) ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'fcoe']) if ret: hooking.log('Failed to restart fcoe service. err = %s' % (err))
def main(): """ Create lists of running networks and networks to be (un)configured as FCoE or removed. """ existing_fcoe_networks = _all_configured_fcoe_networks() changed_fcoe = {} changed_non_fcoe = {} removed_networks = {} custom_parameters = {} setup_nets_config = hooking.read_json() changed_all = setup_nets_config['request']['networks'] for net, net_attr in six.iteritems(changed_all): custom_parameters_string = net_attr.get('custom', {}).get('fcoe', '') custom_parameters[net] = _parse_custom(custom_parameters_string) if _has_fcoe(net_attr): changed_fcoe[net] = net_attr.get('nic') elif hooking.tobool(net_attr.get('remove')): removed_networks[net] = net_attr.get('nic') else: changed_non_fcoe[net] = net_attr.get('nic') _unconfigure_removed(existing_fcoe_networks, removed_networks) _unconfigure_non_fcoe(existing_fcoe_networks, changed_non_fcoe) _reconfigure_fcoe(existing_fcoe_networks, changed_fcoe, custom_parameters) # TODO If services are failed to start restore previous configuration # and notify user ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'lldpad']) if ret: hooking.log('Failed to restart lldpad service. err = %s' % (err)) ret, _, err = hooking.execCmd(['/bin/systemctl', 'restart', 'fcoe']) if ret: hooking.log('Failed to restart fcoe service. err = %s' % (err))
# 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking if hooking.tobool(os.environ.get('sap_agent', False)): domxml = hooking.read_domxml() subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'start']) devs = domxml.getElementsByTagName('devices')[0] diskelem = domxml.createElement('disk') diskelem.setAttribute('device', 'disk') source = domxml.createElement('source') diskelem.setAttribute('type', 'file') source.setAttribute('file', '/dev/shm/vhostmd0') diskelem.appendChild(source) target = domxml.createElement('target') target.setAttribute('dev', 'vdzz') # FIXME do not use a static location
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking from vdsm import vdscli s = vdscli.connect() res = s.list(True) if res['status']['code'] == 0: if not [ v for v in res['vmList'] if v.get('vmId') != os.environ.get('vmId') and hooking.tobool(v.get('custom', {}).get('sap_agent', False)) ]: subprocess.call( ['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'stop'])
# 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking if hooking.tobool(os.environ.get('sap_agent', False)): domxml = hooking.read_domxml() subprocess.call( ['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'start']) devs = domxml.getElementsByTagName('devices')[0] diskelem = domxml.createElement('disk') diskelem.setAttribute('device', 'disk') source = domxml.createElement('source') diskelem.setAttribute('type', 'file') source.setAttribute('file', '/dev/shm/vhostmd0') diskelem.appendChild(source) target = domxml.createElement('target') target.setAttribute('dev', 'vdzz') # FIXME do not use a static location
# 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking from vdsm import client from vdsm.config import config from vdsm import utils use_tls = config.getboolean('vars', 'ssl') cli = client.connect('localhost', use_tls=use_tls) with utils.closing(cli): res = cli.Host.getVMFullList() if not [v for v in res if v.get('vmId') != os.environ.get('vmId') and hooking.tobool(v.get('custom', {}).get('sap_agent', False))]: subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'stop'])
# the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking import vdscli s = vdscli.connect() res = s.list(True) if res["status"]["code"] == 0: if not [ v for v in res["vmList"] if v.get("vmId") != os.environ.get("vmId") and hooking.tobool(v.get("custom", {}).get("sap_agent", False)) ]: subprocess.call(["/usr/bin/sudo", "-n", "/sbin/service", "vhostmd", "stop"])
# 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 # # Refer to the README and COPYING files for full details of the license # import os import subprocess import hooking from vdsm import client from vdsm.config import config from vdsm import utils if hooking.tobool(os.environ.get('sap_agent', False)): use_tls = config.getboolean('vars', 'ssl') cli = client.connect('localhost', use_tls=use_tls) with utils.closing(cli): res = cli.Host.getVMFullList() if not [v for v in res if v.get('vmId') != os.environ.get('vmId') and hooking.tobool(v.get('custom', {}).get('sap_agent', False))]: subprocess.call(['/usr/bin/sudo', '-n', '/sbin/service', 'vhostmd', 'stop'])