def test_create_packetfilter_with_all_params(self):
     """Create packetfilter: packetfilter1."""
     resource = 'packet_filter'
     cmd = pf.CreatePacketFilter(test_cli20.MyApp(sys.stdout), None)
     name = 'packetfilter1'
     myid = 'myid'
     args = [
         '--name', name, '--admin-state-down', '--in-port', 'port1',
         '--src-mac', '00:11:22:33:44:55', '--dst-mac', 'aa:bb:cc:dd:ee:ff',
         '--eth-type', '0x0800', '--protocol', 'tcp', '--src-cidr',
         '10.1.1.0/24', '--dst-cidr', '10.2.2.0/24', '--src-port', '40001',
         '--dst-port', '4000', '--priority', '30000', '--action', 'drop',
         'net1'
     ]
     params = {
         'network_id': 'net1',
         'action': 'drop',
         'priority': '30000',
         'name': name,
         'admin_state_up': False,
         'in_port': 'port1',
         'src_mac': '00:11:22:33:44:55',
         'dst_mac': 'aa:bb:cc:dd:ee:ff',
         'eth_type': '0x0800',
         'protocol': 'tcp',
         'src_cidr': '10.1.1.0/24',
         'dst_cidr': '10.2.2.0/24',
         'src_port': '40001',
         'dst_port': '4000',
     }
     position_names = sorted(params)
     position_values = [params[k] for k in sorted(params)]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
 def _test_create_packetfilter_pass_validation(self,
                                               cmdline=None,
                                               params=None,
                                               base_args=None):
     resource = 'packet_filter'
     cmd = pf.CreatePacketFilter(test_cli20.MyApp(sys.stdout), None)
     name = 'packetfilter1'
     myid = 'myid'
     if base_args is None:
         args = '--priority 30000 --action allow net1'.split()
     else:
         args = base_args.split()
     if cmdline:
         args += cmdline.split()
     _params = {
         'network_id': 'net1',
         'action': 'allow',
         'priority': '30000'
     }
     if params:
         _params.update(params)
     position_names = sorted(_params)
     position_values = [_params[k] for k in sorted(_params)]
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)
 def _test_create_packetfilter_negative_validation(self, cmdline):
     resource = 'packet_filter'
     cmd = pf.CreatePacketFilter(test_cli20.MyApp(sys.stdout), None)
     self.mox.StubOutWithMock(cmd, "get_client")
     self.mox.StubOutWithMock(self.client.httpclient, "request")
     cmd.get_client().MultipleTimes().AndReturn(self.client)
     cmd_parser = cmd.get_parser('create_' + resource)
     args = cmdline.split()
     self.assertRaises(exceptions.CommandError, shell.run_command, cmd,
                       cmd_parser, args)
 def test_create_packetfilter_with_mandatory_params(self):
     """Create packetfilter: packetfilter1."""
     resource = 'packet_filter'
     cmd = pf.CreatePacketFilter(test_cli20.MyApp(sys.stdout), None)
     name = 'packetfilter1'
     myid = 'myid'
     args = ['--priority', '30000', '--action', 'allow', 'net1']
     position_names = ['network_id', 'action', 'priority']
     position_values = ['net1', 'allow', '30000']
     self._test_create_resource(resource, cmd, name, myid, args,
                                position_names, position_values)