def inspect_vnics(self, instance): domain = self._get_domain_not_shut_off_or_raise(instance) tree = etree.fromstring(domain.XMLDesc(0)) for iface in tree.findall('devices/interface'): if iface.get('type') != PORT_DIRECT_TYPE: # Not SRIOV generator = super(MlnxLibvirtInspector, self).inspect_vnics(instance) if hasattr(generator, "__iter__"): for gen in generator: yield gen return mac = iface.find('mac') if mac is not None: mac_address = mac.get('address') else: continue args = ["ip", "link", "show"] try: (output, rc) = utils.execute(*args) except Exception: LOG.error('Unable to run command: %s' % output) continue lines = output.split(os.linesep) name = vf_num = None for line in reversed(lines): if mac_address in line: try: vf_num = int(self.regex_get_vf.match(line).groups()[1]) except Exception: continue elif vf_num is not None: if self.regex_get_number.match(line) is not None: name = self.regex_get_string.split(line)[1].strip() break if vf_num is None or name is None: LOG.error('Unable to reach counters: unknown VF number or " \ "interface name for MAC=%s' % mac_address) continue # filtertref (fref) is not supported in SRIOV interface = virt_inspector.Interface(name=name, mac=mac_address, fref=None, parameters=None) self._init_vf_counters(name, vf_num) stats = virt_inspector.InterfaceStats( rx_bytes=self.counters_dic["rx_bytes"], rx_packets=self.counters_dic["rx_packets"], tx_bytes=self.counters_dic["tx_bytes"], tx_packets=self.counters_dic["tx_packets"]) yield (interface, stats)
def _execute(self, **kwargs): args = ['ipmitool'] command = f(self, **kwargs) args.extend(command.split(" ")) try: (out, __) = utils.execute(*args, run_as_root=True) except processutils.ProcessExecutionError: raise ipmiexcept.IPMIException(_("running ipmitool failure")) return _parse_output(out, template)
def _prepare_socket_dir(self): chmod_dir_cmd = ['chmod', '-R', 'g+rwx', _QEMU_GA_DEVICE_DIR] utils.execute(*chmod_dir_cmd, run_as_root=True)
def inspect_vnics(self, instance): domain = self._get_domain_not_shut_off_or_raise(instance) tree = etree.fromstring(domain.XMLDesc(0)) for iface in tree.findall('devices/interface'): if iface.get('type') != PORT_DIRECT_TYPE: #Not SRIOV generator = super(MlnxLibvirtInspector, self).inspect_vnics(instance_name) if hasattr(generator, "__iter__"): for gen in generator: yield gen return mac = iface.find('mac') if mac is not None: mac_address = mac.get('address') else: continue args = ["ip", "link", "show"] try: (output, rc) = utils.execute(*args) except: LOG.warning('Unable to run command: %s' % output) continue lines = output.split(os.linesep) name = vf_num = None for line in reversed(lines): if mac_address in line: try: vf_num = int( self.regex_get_number.search(line).group()) except: pass elif vf_num is not None: if self.regex_get_number.match(line) is not None: name = self.regex_get_string.split(line)[1].strip() break if vf_num is None or name is None: LOG.warning( 'Unable to reach counters: unknown VF number and interface name' ) continue #filtertref (fref) is not supported in SRIOV interface = virt_inspector.Interface(name=name, mac=mac_address, fref=None, parameters=None) self._init_vf_counters(name, vf_num) stats = virt_inspector.InterfaceStats( rx_bytes=self.counters_dic["rx_bytes"], rx_packets=self.counters_dic["rx_packets"], tx_bytes=self.counters_dic["tx_bytes"], tx_packets=self.counters_dic["tx_packets"]) yield (interface, stats)
from ceilometer import utils as ceilometer_utils from cinder import utils as cinder_utils from neutron.agent.linux import utils as neutron_utils from nova import utils as nova_utils # Ceilometer ceilometer_utils.execute('gcc --version') ceilometer_utils.execute('gcc --version', run_as_root=False) ceilometer_utils.execute('gcc --version', run_as_root=True) # Cinder cinder_utils.execute('gcc --version') cinder_utils.execute('gcc --version', run_as_root=False) cinder_utils.execute('gcc --version', run_as_root=True) # Neutron neutron_utils.execute('gcc --version') neutron_utils.execute('gcc --version', run_as_root=False) neutron_utils.execute('gcc --version', run_as_root=True) # Nova nova_utils.execute('gcc --version') nova_utils.execute('gcc --version', run_as_root=False) nova_utils.execute('gcc --version', run_as_root=True) nova_utils.trycmd('gcc --version') nova_utils.trycmd('gcc --version', run_as_root=True)
def _prepare_socket(self): chmod_file_cmd = ['chmod', 'g+rw', self._socketName] utils.execute(*chmod_file_cmd, run_as_root=True)