summaryrefslogtreecommitdiffhomepage
path: root/tests/unit/lib/ovs/test_vsctl.py
blob: 28edf6e98fdc4b123d270cc72b97130ad46b0bf0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
# Copyright (C) 2016 Nippon Telegraph and Telephone Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain 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.

from distutils.spawn import find_executable
import logging
import subprocess
import unittest

from nose.tools import eq_
from nose.tools import ok_

from ryu.lib.hub import sleep
from ryu.lib.ovs import vsctl


LOG = logging.getLogger(__name__)

DOCKER_IMAGE_MININET = 'osrg/ryu-book'

OVSDB_MANAGER_ADDR = 'ptcp:6640'
OVSDB_SWITCH_ADDR = 'tcp:%s:6640'


def setUpModule():
    if not find_executable('docker'):
        raise unittest.SkipTest(
            'Docker is not available. Test in %s will be skipped.' % __name__)


def _run(command):
    popen = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
    popen.wait()
    result = popen.stdout.read().decode('utf-8')

    if result:
        return [str(r.strip('\r')) for r in result.split('\n')]
    else:
        return []


class TestVSCtl(unittest.TestCase):
    """
    Test cases for ryu.lib.ovs.vsctl.VSCtl
    """
    container_mn = None  # Container ID of Mininet
    container_mn_ip = None  # IP of Mininet container

    vsctl = None  # instance of vsctl.VSCtl

    @classmethod
    def _docker_exec(cls, container, command):
        return _run('docker exec -t %s %s' % (container, command))

    @classmethod
    def _docker_exec_mn(cls, command):
        return cls._docker_exec(cls.container_mn, command)

    @classmethod
    def _docker_run(cls, image):
        return _run('docker run --privileged -t -d %s' % image)[0]

    @classmethod
    def _docker_stop(cls, container):
        return _run('docker stop %s' % container)[0]

    @classmethod
    def _docker_rm(cls, container):
        return _run('docker rm %s' % container)[0]

    @classmethod
    def _docker_inspect_ip_addr(cls, container):
        return _run(
            'docker inspect --format="{{.NetworkSettings.IPAddress}}" %s' %
            container)[0].strip('"')

    @classmethod
    def _set_up_mn_container(cls):
        cls.container_mn = cls._docker_run(DOCKER_IMAGE_MININET)
        cls.container_mn_ip = cls._docker_inspect_ip_addr(cls.container_mn)

        # Note: Wait for loading the OVS kernel module.
        # If the OVS kernel module is loaded at first time, it might take
        # a few seconds.
        sleep(5)

        cls._docker_exec_mn(
            'ovs-vsctl set-manager %s' % OVSDB_MANAGER_ADDR)

    @classmethod
    def _set_up_vsctl(cls):
        cls.vsctl = vsctl.VSCtl(OVSDB_SWITCH_ADDR % cls.container_mn_ip)

    @classmethod
    def setUpClass(cls):
        cls._set_up_mn_container()
        cls._set_up_vsctl()

    @classmethod
    def _tear_down_mn_container(cls):
        cls._docker_exec_mn('mn --clean')
        cls._docker_stop(cls.container_mn)
        cls._docker_rm(cls.container_mn)

    @classmethod
    def tearDownClass(cls):
        cls._tear_down_mn_container()

    def setUp(self):
        pass

    def tearDown(self):
        pass

    def _run_commands(self, commands):
        self.vsctl.run_command(commands, timeout_sec=1)

    # 00: Open vSwitch commands

    def test_00_01_init(self):
        command = vsctl.VSCtlCommand('init')
        self._run_commands([command])

        ok_(command.result is None)

    def test_00_02_show(self):
        command = vsctl.VSCtlCommand('show')
        self._run_commands([command])

        ok_(command.result is not None)

    # 01: Bridge commands

    def test_01_01_add_br_bridge(self):
        bridge = 's1'
        command = vsctl.VSCtlCommand('add-br', (bridge,))
        self._run_commands([command])

        result = self._docker_exec_mn('ovs-vsctl list-br')
        ok_(bridge in result)

    def test_01_02_add_br_parent_vlan(self):
        bridge = 'sub-s1-100'
        parent = 's1'
        vlan = '100'
        command = vsctl.VSCtlCommand('add-br', (bridge, parent, vlan))
        self._run_commands([command])

        result = self._docker_exec_mn('ovs-vsctl list-br')
        ok_(bridge in result)
        result = self._docker_exec_mn(
            'ovs-vsctl br-to-parent %s' % bridge)
        eq_(parent, result[0])
        result = self._docker_exec_mn(
            'ovs-vsctl br-to-vlan %s' % bridge)
        eq_(vlan, result[0])

    def test_01_03_del_br(self):
        bridge = 's1'
        child = 'sub-s1-100'

        command = vsctl.VSCtlCommand('del-br', (bridge,))
        self._run_commands([command])

        result = self._docker_exec_mn('ovs-vsctl list-br')
        ok_(bridge not in result)
        ok_(child not in result)

    def test_01_04_list_br(self):
        bridge = 's1'
        child = 'sub-s1-100'
        vlan = '100'
        self._docker_exec_mn('ovs-vsctl add-br %s' % bridge)
        self._docker_exec_mn(
            'ovs-vsctl add-br %s %s %s' % (child, bridge, vlan))

        command = vsctl.VSCtlCommand('list-br')
        self._run_commands([command])

        ok_(bridge in command.result)
        ok_(child in command.result)

    def test_01_05_br_exists(self):
        bridge = 's1'

        command = vsctl.VSCtlCommand('br-exists', (bridge, ))
        self._run_commands([command])

        eq_(True, command.result)

    def test_01_06_br_to_vlan(self):
        bridge = 's1'

        command = vsctl.VSCtlCommand('br-to-vlan', (bridge, ))
        self._run_commands([command])

        eq_(0, command.result)

    def test_01_06_br_to_vlan_fake_bridge(self):
        bridge = 'sub-s1-100'

        command = vsctl.VSCtlCommand('br-to-vlan', (bridge, ))
        self._run_commands([command])

        eq_(100, command.result)

    def test_01_07_br_to_parent(self):
        bridge = 's1'
        parent = bridge

        command = vsctl.VSCtlCommand('br-to-parent', (bridge, ))
        self._run_commands([command])

        # result = <ryu.lib.ovs.vsctl.VSCtlBridge object>
        eq_(parent, command.result.name)

    def test_01_07_br_to_parent_fake_bridge(self):
        bridge = 'sub-s1-100'
        parent = 's1'

        command = vsctl.VSCtlCommand('br-to-parent', (bridge, ))
        self._run_commands([command])

        # result = <ryu.lib.ovs.vsctl.VSCtlBridge object>
        eq_(parent, command.result.name)

    def test_01_08_br_set_external_id_add(self):
        bridge = 's1'
        key = 'ext_id_key'
        value = 'ext_id_value'

        command = vsctl.VSCtlCommand(
            'br-set-external-id', (bridge, key, value))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl br-get-external-id %s %s' % (bridge, key))
        eq_(value, result[0])

    def test_01_09_br_get_external_id_value(self):
        bridge = 's1'
        key = 'ext_id_key'
        value = 'ext_id_value'

        command = vsctl.VSCtlCommand(
            'br-get-external-id', (bridge, key))
        self._run_commands([command])

        eq_(value, command.result)

    def test_01_10_br_get_external_id_dict(self):
        bridge = 's1'
        key = 'ext_id_key'
        value = 'ext_id_value'

        command = vsctl.VSCtlCommand(
            'br-get-external-id', (bridge,))
        self._run_commands([command])

        eq_({key: value}, command.result)

    def test_01_11_br_set_external_id_clear(self):
        bridge = 's1'
        key = 'ext_id_key'

        command = vsctl.VSCtlCommand(
            'br-set-external-id', (bridge, key))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl br-get-external-id %s %s' % (bridge, key))
        eq_([], result)

        # Clean up
        self._docker_exec_mn('mn --clean')

    # 02: Port commands

    def test_02_01_list_ports(self):
        bridge = 's1'
        interface_1 = 's1-eth1'
        interface_2 = 's1-eth2'

        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_1)
        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_2)
        self._docker_exec_mn(
            'ovs-vsctl add-br %(bridge)s'
            ' -- add-port %(bridge)s %(interface_1)s'
            ' -- add-port %(bridge)s %(interface_2)s' % locals())

        command = vsctl.VSCtlCommand('list-ports', (bridge,))
        self._run_commands([command])

        ok_(interface_1 in command.result)
        ok_(interface_2 in command.result)

    def test_02_02_add_port(self):
        bridge = 's1'
        interface_1 = 's1-eth1'
        self._docker_exec_mn(
            'ovs-vsctl del-port %s %s' % (bridge, interface_1))

        command = vsctl.VSCtlCommand('add-port', (bridge, interface_1))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl port-to-br %s' % interface_1)
        eq_(bridge, result[0])

    def test_02_03_add_bond(self):
        bridge = 's1'
        interface_1 = 's1-eth1'
        interface_2 = 's1-eth2'
        port = 's1-bond1'
        interface_list = [interface_1, interface_2]
        self._docker_exec_mn('ovs-vsctl del-br %s' % bridge)
        self._docker_exec_mn('ovs-vsctl add-br %s' % bridge)

        command = vsctl.VSCtlCommand(
            'add-bond', (bridge, port, interface_list))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl port-to-br %s' % port)
        eq_(bridge, result[0])

    def test_02_04_del_port(self):
        bridge = 's1'
        port = 's1-bond1'

        command = vsctl.VSCtlCommand('del-port', (bridge, port))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl list-ports %s' % bridge)
        eq_([], result)

    def test_02_05_port_to_br(self):
        bridge = 's1'
        port_1 = 's1-eth1'
        port_2 = 's1-eth2'
        self._docker_exec_mn('ovs-vsctl del-br %s' % bridge)
        self._docker_exec_mn(
            'ovs-vsctl add-br %(bridge)s'
            ' -- add-port %(bridge)s %(port_1)s'
            ' -- add-port %(bridge)s %(port_2)s' % locals())

        command = vsctl.VSCtlCommand('port-to-br', (port_1,))
        self._run_commands([command])

        eq_(bridge, command.result)

        # Clean up
        self._docker_exec_mn('mn --clean')

    # 03: Interface commands

    def test_03_01_list_ifaces(self):
        bridge = 's1'
        interface_1 = 's1-eth1'
        interface_2 = 's1-eth2'

        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_1)
        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_2)
        self._docker_exec_mn(
            'ovs-vsctl add-br %(bridge)s'
            ' -- add-port %(bridge)s %(interface_1)s'
            ' -- add-port %(bridge)s %(interface_2)s' % locals())

        command = vsctl.VSCtlCommand('list-ifaces', (bridge,))
        self._run_commands([command])

        ok_(interface_1 in command.result)
        ok_(interface_2 in command.result)

    def test_03_02_ifaces_to_br(self):
        bridge = 's1'
        interface_1 = 's1-eth1'

        command = vsctl.VSCtlCommand('iface-to-br', (interface_1,))
        self._run_commands([command])

        eq_(bridge, command.result)

        # Clean up
        self._docker_exec_mn('mn --clean')

    # 04: Controller commands

    def test_04_01_get_controller(self):
        bridge = 's1'
        controller = 'tcp:127.0.0.1:6653'
        self._docker_exec_mn(
            'ovs-vsctl add-br %(bridge)s'
            ' -- set-controller %(bridge)s %(controller)s' % locals())

        command = vsctl.VSCtlCommand('get-controller', (bridge,))
        self._run_commands([command])

        eq_(1, len(command.result))
        eq_(controller, command.result[0])

    def test_04_02_del_controller(self):
        bridge = 's1'

        command = vsctl.VSCtlCommand('del-controller', (bridge,))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get-controller %s' % bridge)
        eq_([], result)

    def test_04_03_set_controller(self):
        bridge = 's1'
        controller = 'tcp:127.0.0.1:6653'

        command = vsctl.VSCtlCommand('set-controller', (bridge, controller))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get-controller %s' % bridge)
        eq_(controller, result[0])

    def test_04_04_get_fail_mode(self):
        bridge = 's1'
        fai_mode = 'secure'
        self._docker_exec_mn(
            'ovs-vsctl set-fail-mode %s %s' % (bridge, fai_mode))

        command = vsctl.VSCtlCommand('get-fail-mode', (bridge,))
        self._run_commands([command])

        eq_(fai_mode, command.result)

    def test_04_05_del_fail_mode(self):
        bridge = 's1'

        command = vsctl.VSCtlCommand('del-fail-mode', (bridge,))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get-fail-mode %s' % bridge)
        eq_([], result)

    def test_04_06_set_fail_mode(self):
        bridge = 's1'
        fail_mode = 'secure'

        command = vsctl.VSCtlCommand('set-fail-mode', (bridge, fail_mode))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get-fail-mode %s' % bridge)
        eq_(fail_mode, result[0])

        # Clean up
        self._docker_exec_mn('mn --clean')

    # 05: Manager commands (not implemented yet)
    # 06: SSL commands (not implemented yet)
    # 07: Switch commands (not implemented yet)

    # 08: Database commands

    def test_08_01_list(self):
        table = 'Bridge'
        bridge = 's1'
        interface_1 = 's1-eth1'
        interface_2 = 's1-eth2'
        fail_mode = 'secure'
        protocols = 'OpenFlow10,OpenFlow13'
        datapath_id = '1111111111111111'

        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_1)
        self._docker_exec_mn(
            'ip link add %s type dummy' % interface_2)
        self._docker_exec_mn(
            'ovs-vsctl add-br %(bridge)s'
            ' -- add-port %(bridge)s %(interface_1)s'
            ' -- add-port %(bridge)s %(interface_2)s' % locals())
        self._docker_exec_mn(
            'ovs-vsctl set %(table)s %(bridge)s '
            'fail_mode=%(fail_mode)s '
            'protocols=%(protocols)s '
            'other_config:datapath-id=%(datapath_id)s' % locals())

        command = vsctl.VSCtlCommand('list', (table,))
        self._run_commands([command])

        eq_(1, len(command.result))
        # command.result[0] = <ryu.lib.ovs.vsctl.VSCtlBridge object>
        eq_(bridge, command.result[0].name)

    def test_08_02_find(self):
        table = 'Bridge'
        bridge = 's1'

        command = vsctl.VSCtlCommand('find', (table, 'name=%s' % bridge))
        self._run_commands([command])

        eq_(1, len(command.result))
        # command.result[0] = <ovs.db.idl.Row object object> for Bridge
        eq_(bridge, command.result[0].name)

    def test_08_02_find_complex(self):
        table = 'Bridge'
        bridge = 's1'
        fail_mode = 'secure'
        protocols = 'OpenFlow10,OpenFlow13'
        datapath_id = '1111111111111111'

        command = vsctl.VSCtlCommand(
            'find', (table, 'fail_mode=%s' % fail_mode,
                     'protocols=%s' % protocols,
                     'other_config:datapath-id=%s' % datapath_id))
        self._run_commands([command])

        eq_(1, len(command.result))
        # command.result[0] = <ovs.db.idl.Row object object> for Bridge
        eq_(bridge, command.result[0].name)

    def test_08_03_get_01_value(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'fail_mode'
        value = 'secure'

        command = vsctl.VSCtlCommand('get', (table, bridge, column))
        self._run_commands([command])

        # command.result[0] is a list of return values
        eq_(value, command.result[0][0])

    def test_08_03_get_02_set(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'protocols'
        value = 'OpenFlow10,OpenFlow13'.split(',')

        command = vsctl.VSCtlCommand('get', (table, bridge, column))
        self._run_commands([command])

        # command.result[0] is a list
        eq_(value, command.result[0])

    def test_08_03_get_03_map(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'other_config'
        key = 'datapath-id'
        datapath_id = '1111111111111111'
        value = {key: datapath_id}

        command = vsctl.VSCtlCommand('get', (table, bridge, column))
        self._run_commands([command])

        # command.result[0] is a dict
        eq_(value, command.result[0])

    def test_08_03_get_04_map_value(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'other_config'
        key = 'datapath-id'
        datapath_id = '1111111111111111'
        value = datapath_id

        command = vsctl.VSCtlCommand(
            'get', (table, bridge, '%s:%s' % (column, key)))
        self._run_commands([command])

        # command.result[0] is a dict
        eq_(value, command.result[0])

    def test_08_04_set_01_value(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'fail_mode'
        value = 'standalone'

        command = vsctl.VSCtlCommand(
            'set', (table, bridge, '%s=%s' % (column, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        eq_(value, result[0])

    def test_08_04_set_02_set(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'protocols'
        value = 'OpenFlow10,OpenFlow12,OpenFlow13'

        command = vsctl.VSCtlCommand(
            'set', (table, bridge, '%s=%s' % (column, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '["OpenFlow10", "OpenFlow12", "OpenFlow13"]'
        eq_(expected_value, result[0])

    def test_08_04_set_03_map(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'other_config'
        key = 'datapath-id'
        value = '0000000000000001'

        command = vsctl.VSCtlCommand(
            'set', (table, bridge, '%s:%s=%s' % (column, key, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s:%s' % (table, bridge, column, key))
        expected_value = '"0000000000000001"'
        eq_(expected_value, result[0])

    def test_08_05_add_01_value(self):
        table = 'Port'
        bridge = 's1'
        column = 'tag'
        value = '100'

        command = vsctl.VSCtlCommand(
            'add', (table, bridge, column, value))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        eq_(value, result[0])

    def test_08_05_add_02_set(self):
        table = 'Port'
        bridge = 's1'
        column = 'trunks'
        value = '100,200'

        command = vsctl.VSCtlCommand(
            'add', (table, bridge, column, value))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '[100, 200]'
        eq_(expected_value, result[0])

    def test_08_05_add_03_map(self):
        table = 'Bridge'
        bridge = 's1'
        column = 'other_config'
        key = 'datapath-id'
        value = '0000000000000011'

        command = vsctl.VSCtlCommand(
            'add', (table, bridge, column, '%s=%s' % (key, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s:%s' % (table, bridge, column, key))
        expected_value = '"0000000000000011"'
        eq_(expected_value, result[0])

    def test_08_06_remove_01_value(self):
        table = 'Port'
        bridge = 's1'
        column = 'tag'
        value = '100'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s=%s' % (table, bridge, column, value))

        command = vsctl.VSCtlCommand(
            'remove', (table, bridge, column, value))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '[]'
        eq_(expected_value, result[0])

    def test_08_06_remove_02_set(self):
        table = 'Port'
        bridge = 's1'
        column = 'trunks'
        init_value = '100,200,300'
        value = '100,200'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s=%s' % (table, bridge, column, init_value))

        command = vsctl.VSCtlCommand(
            'remove', (table, bridge, column, value))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '[300]'
        eq_(expected_value, result[0])

    def test_08_06_remove_03_map(self):
        table = 'Port'
        bridge = 's1'
        column = 'other_config'
        key = 'priority-tag'
        value = 'true'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s:%s=%s' %
            (table, bridge, column, key, value))

        command = vsctl.VSCtlCommand(
            'remove', (table, bridge, column, '%s=%s' % (key, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '{}'
        eq_(expected_value, result[0])

    def test_08_07_clear_01_value(self):
        table = 'Port'
        bridge = 's1'
        column = 'tag'
        value = '100'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s=%s' % (table, bridge, column, value))

        command = vsctl.VSCtlCommand(
            'clear', (table, bridge, column))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '[]'
        eq_(expected_value, result[0])

    def test_08_07_clear_02_set(self):
        table = 'Port'
        bridge = 's1'
        column = 'trunks'
        value = '100,200'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s=%s' % (table, bridge, column, value))

        command = vsctl.VSCtlCommand(
            'clear', (table, bridge, column))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '[]'
        eq_(expected_value, result[0])

    def test_08_07_clear_03_map(self):
        table = 'Port'
        bridge = 's1'
        column = 'other_config'
        key = 'priority-tag'
        value = 'true'
        self._docker_exec_mn(
            'ovs-vsctl set %s %s %s:%s=%s' %
            (table, bridge, column, key, value))

        command = vsctl.VSCtlCommand(
            'clear', (table, bridge, column, '%s=%s' % (key, value)))
        self._run_commands([command])

        result = self._docker_exec_mn(
            'ovs-vsctl get %s %s %s' % (table, bridge, column))
        expected_value = '{}'
        eq_(expected_value, result[0])

        # Clean up
        self._docker_exec_mn('mn --clean')