コード例 #1
0
ファイル: pcap_driver.py プロジェクト: openstack/steth
#    a copy of the License at
#
#         http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import pcap
from steth.agent.common import log
from steth.agent.common import utils
from steth.agent.common import constants

LOG = log.get_logger()


class PcapDriver(object):

    def setup_listener(self, iface, filter, timeout=2):
        listener = pcap.pcap(iface, timeout_ms=timeout * 1000)
        listener.setfilter(filter)
        return listener

    def setup_listener_on_comp(self, port_id, filter):
        tap_device = utils.get_vif_name(constants.TAP_DEVICE_PREFIX, port_id)
        qvb_device = utils.get_vif_name(constants.QVB_DEVICE_PREFIX, port_id)
        qbr_device = utils.get_vif_name(constants.QBR_DEVICE_PREFIX, port_id)
        qvo_device = utils.get_vif_name(constants.QVO_DEVICE_PREFIX, port_id)
        vif_devices = [tap_device, qvb_device, qbr_device, qvo_device]
コード例 #2
0
ファイル: api.py プロジェクト: vkdrao4git/steth
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
#    License for the specific language governing permissions and limitations
#    under the License.

import re
from netaddr import IPNetwork
from steth.agent.common import utils as agent_utils
from steth.agent.drivers import iperf as iperf_driver
from steth.agent.drivers import scapy_driver
from steth.agent.drivers import pcap_driver
from steth.agent.common import log
from steth.agent.common import constants

LOG = log.get_logger()


class AgentApi(object):
    def check_ports_on_br(self, bridge='br-ex', ports=['eth3']):
        """Check ports exist on bridge.

        ovs-vsctl list-ports bridge
        """
        LOG.info("RPC: check_ports_on_br bridge: %s, ports: %s" %
                 (bridge, ports))
        cmd = ['ovs-vsctl', 'list-ports', bridge]
        stdcode, stdout = agent_utils.execute(cmd, root=True)
        data = dict()
        if stdcode == 0:
            for port in ports: