~ubuntu-branches/ubuntu/vivid/neutron/vivid-updates

« back to all changes in this revision

Viewing changes to neutron/cmd/sanity/checks.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:17:19 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150330111719-h0gx7233p4jkkgfh
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream.
  - d/control: Add new dependency on oslo-log.
  - d/p/*: Rebase.
  - d/control,d/neutron-plugin-hyperv*: Dropped, decomposed into
    separate project upstream.
  - d/control,d/neutron-plugin-openflow*: Dropped, decomposed into
    separate project upstream.
  - d/neutron-common.install: Add neutron-rootwrap-daemon and 
    neutron-keepalived-state-change binaries.
  - d/rules: Ignore neutron-hyperv-agent when installing; only for Windows.
  - d/neutron-plugin-cisco.install: Drop neutron-cisco-cfg-agent as
    decomposed into separate project upstream.
  - d/neutron-plugin-vmware.install: Drop neutron-check-nsx-config and
    neutron-nsx-manage as decomposed into separate project upstream.
  - d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent.
* d/pydist-overrides: Add overrides for oslo packages.
* d/control: Fixup type in package description (LP: #1263539).
* d/p/fixup-driver-test-execution.patch: Cherry pick fix from upstream VCS
  to support unit test exection in out-of-tree vendor drivers.
* d/neutron-common.postinst: Allow general access to /etc/neutron but limit
  access to root/neutron to /etc/neutron/neutron.conf to support execution
  of unit tests in decomposed vendor drivers.
* d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import re
17
17
 
18
18
import netaddr
 
19
from oslo_log import log as logging
19
20
 
20
21
from neutron.agent.linux import ip_lib
21
22
from neutron.agent.linux import ip_link_support
23
24
from neutron.agent.linux import utils as agent_utils
24
25
from neutron.common import utils
25
26
from neutron.i18n import _LE
26
 
from neutron.openstack.common import log as logging
27
27
from neutron.openstack.common import uuidutils
28
28
from neutron.plugins.common import constants as const
29
29
from neutron.plugins.openvswitch.common import constants as ovs_const
34
34
MINIMUM_DNSMASQ_VERSION = 2.67
35
35
 
36
36
 
37
 
def ovs_vxlan_supported(root_helper, from_ip='192.0.2.1', to_ip='192.0.2.2'):
 
37
def ovs_vxlan_supported(from_ip='192.0.2.1', to_ip='192.0.2.2'):
38
38
    name = "vxlantest-" + utils.get_random_string(6)
39
 
    with ovs_lib.OVSBridge(name, root_helper) as br:
 
39
    with ovs_lib.OVSBridge(name) as br:
40
40
        port = br.add_tunnel_port(from_ip, to_ip, const.TYPE_VXLAN)
41
41
        return port != ovs_lib.INVALID_OFPORT
42
42
 
43
43
 
44
 
def iproute2_vxlan_supported(root_helper):
45
 
    ip = ip_lib.IPWrapper(root_helper)
 
44
def iproute2_vxlan_supported():
 
45
    ip = ip_lib.IPWrapper()
46
46
    name = "vxlantest-" + utils.get_random_string(4)
47
47
    port = ip.add_vxlan(name, 3000)
48
48
    ip.del_veth(name)
49
49
    return name == port.name
50
50
 
51
51
 
52
 
def patch_supported(root_helper):
 
52
def patch_supported():
53
53
    seed = utils.get_random_string(6)
54
54
    name = "patchtest-" + seed
55
55
    peer_name = "peertest0-" + seed
56
56
    patch_name = "peertest1-" + seed
57
 
    with ovs_lib.OVSBridge(name, root_helper) as br:
 
57
    with ovs_lib.OVSBridge(name) as br:
58
58
        port = br.add_patch_port(patch_name, peer_name)
59
59
        return port != ovs_lib.INVALID_OFPORT
60
60
 
67
67
        return False
68
68
 
69
69
 
70
 
def ofctl_arg_supported(root_helper, cmd, **kwargs):
 
70
def ofctl_arg_supported(cmd, **kwargs):
71
71
    """Verify if ovs-ofctl binary supports cmd with **kwargs.
72
72
 
73
 
    :param root_helper: utility to use when running shell commands.
74
73
    :param cmd: ovs-ofctl command to use for test.
75
74
    :param **kwargs: arguments to test with the command.
76
75
    :returns: a boolean if the supplied arguments are supported.
77
76
    """
78
77
    br_name = 'br-test-%s' % utils.get_random_string(6)
79
 
    with ovs_lib.OVSBridge(br_name, root_helper) as test_br:
 
78
    with ovs_lib.OVSBridge(br_name) as test_br:
80
79
        full_args = ["ovs-ofctl", cmd, test_br.br_name,
81
80
                     ovs_lib._build_flow_expr_str(kwargs, cmd.split('-')[0])]
82
81
        try:
83
 
            agent_utils.execute(full_args, root_helper=root_helper)
 
82
            agent_utils.execute(full_args, run_as_root=True)
84
83
        except RuntimeError as e:
85
84
            LOG.debug("Exception while checking supported feature via "
86
85
                      "command %s. Exception: %s", full_args, e)
93
92
            return True
94
93
 
95
94
 
96
 
def arp_responder_supported(root_helper):
 
95
def arp_responder_supported():
97
96
    mac = netaddr.EUI('dead:1234:beef', dialect=netaddr.mac_unix)
98
97
    ip = netaddr.IPAddress('240.0.0.1')
99
98
    actions = ovs_const.ARP_RESPONDER_ACTIONS % {'mac': mac, 'ip': ip}
100
99
 
101
 
    return ofctl_arg_supported(root_helper,
102
 
                               cmd='add-flow',
 
100
    return ofctl_arg_supported(cmd='add-flow',
103
101
                               table=21,
104
102
                               priority=1,
105
103
                               proto='arp',
108
106
                               actions=actions)
109
107
 
110
108
 
111
 
def vf_management_supported(root_helper):
 
109
def vf_management_supported():
112
110
    try:
113
 
        vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section(
114
 
                        root_helper)
 
111
        vf_section = ip_link_support.IpLinkSupport.get_vf_mgmt_section()
115
112
        if not ip_link_support.IpLinkSupport.vf_mgmt_capability_supported(
116
113
                vf_section,
117
114
                ip_link_support.IpLinkConstants.IP_LINK_CAPABILITY_STATE):
124
121
    return True
125
122
 
126
123
 
127
 
def netns_read_requires_helper(root_helper):
128
 
    ipw = ip_lib.IPWrapper(root_helper)
 
124
def netns_read_requires_helper():
 
125
    ipw = ip_lib.IPWrapper()
129
126
    nsname = "netnsreadtest-" + uuidutils.generate_uuid()
130
127
    ipw.netns.add(nsname)
131
128
    try: