alshabib

Merge branch 'master' of ssh://gerrit.onlab.us:29418/onos-next

Showing 56 changed files with 1063 additions and 65 deletions
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 +<!--
3 + ~ Licensed to the Apache Software Foundation (ASF) under one
4 + ~ or more contributor license agreements. See the NOTICE file
5 + ~ distributed with this work for additional information
6 + ~ regarding copyright ownership. The ASF licenses this file
7 + ~ to you under the Apache License, Version 2.0 (the
8 + ~ "License"); you may not use this file except in compliance
9 + ~ with the License. You may obtain a copy of the License at
10 + ~
11 + ~ http://www.apache.org/licenses/LICENSE-2.0
12 + ~
13 + ~ Unless required by applicable law or agreed to in writing,
14 + ~ software distributed under the License is distributed on an
15 + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 + ~ KIND, either express or implied. See the License for the
17 + ~ specific language governing permissions and limitations
18 + ~ under the License.
19 + -->
2 <project xmlns="http://maven.apache.org/POM/4.0.0" 20 <project xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 21 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 22 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import org.apache.karaf.shell.commands.Option; 21 import org.apache.karaf.shell.commands.Option;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import org.onlab.onos.cluster.ControllerNode; 21 import org.onlab.onos.cluster.ControllerNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import static com.google.common.collect.Lists.newArrayList; 21 import static com.google.common.collect.Lists.newArrayList;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli; 19 package org.onlab.onos.cli;
2 20
3 import com.fasterxml.jackson.databind.ObjectMapper; 21 import com.fasterxml.jackson.databind.ObjectMapper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
4 import org.apache.karaf.shell.commands.Command; 22 import org.apache.karaf.shell.commands.Command;
5 -import org.onlab.onos.cli.AbstractShellCommand;
6 import org.onlab.onos.net.ConnectPoint; 23 import org.onlab.onos.net.ConnectPoint;
7 import org.onlab.onos.net.DeviceId; 24 import org.onlab.onos.net.DeviceId;
8 import org.onlab.onos.net.PortNumber; 25 import org.onlab.onos.net.PortNumber;
9 -import org.onlab.onos.net.flow.DefaultTrafficSelector;
10 import org.onlab.onos.net.flow.DefaultTrafficTreatment; 26 import org.onlab.onos.net.flow.DefaultTrafficTreatment;
11 import org.onlab.onos.net.flow.TrafficSelector; 27 import org.onlab.onos.net.flow.TrafficSelector;
12 import org.onlab.onos.net.flow.TrafficTreatment; 28 import org.onlab.onos.net.flow.TrafficTreatment;
13 import org.onlab.onos.net.intent.Intent; 29 import org.onlab.onos.net.intent.Intent;
14 import org.onlab.onos.net.intent.IntentService; 30 import org.onlab.onos.net.intent.IntentService;
15 import org.onlab.onos.net.intent.MultiPointToSinglePointIntent; 31 import org.onlab.onos.net.intent.MultiPointToSinglePointIntent;
16 -import org.onlab.packet.Ethernet;
17 32
18 import java.util.HashSet; 33 import java.util.HashSet;
19 import java.util.Set; 34 import java.util.Set;
...@@ -26,7 +41,7 @@ import static org.onlab.onos.net.PortNumber.portNumber; ...@@ -26,7 +41,7 @@ import static org.onlab.onos.net.PortNumber.portNumber;
26 */ 41 */
27 @Command(scope = "onos", name = "add-multi-to-single-intent", 42 @Command(scope = "onos", name = "add-multi-to-single-intent",
28 description = "Installs point-to-point connectivity intent") 43 description = "Installs point-to-point connectivity intent")
29 -public class AddMultiPointToSinglePointIntentCommand extends AbstractShellCommand { 44 +public class AddMultiPointToSinglePointIntentCommand extends ConnectivityIntentCommand {
30 45
31 @Argument(index = 0, name = "ingressDevices", 46 @Argument(index = 0, name = "ingressDevices",
32 description = "Ingress Device/Port Description", 47 description = "Ingress Device/Port Description",
...@@ -55,9 +70,7 @@ public class AddMultiPointToSinglePointIntentCommand extends AbstractShellComman ...@@ -55,9 +70,7 @@ public class AddMultiPointToSinglePointIntentCommand extends AbstractShellComman
55 ingressPoints.add(ingress); 70 ingressPoints.add(ingress);
56 } 71 }
57 72
58 - TrafficSelector selector = DefaultTrafficSelector.builder() 73 + TrafficSelector selector = buildTrafficSelector();
59 - .matchEthType(Ethernet.TYPE_IPV4)
60 - .build();
61 TrafficTreatment treatment = DefaultTrafficTreatment.builder().build(); 74 TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
62 75
63 Intent intent = new MultiPointToSinglePointIntent(appId(), selector, treatment, 76 Intent intent = new MultiPointToSinglePointIntent(appId(), selector, treatment,
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
4 import org.apache.karaf.shell.commands.Command; 22 import org.apache.karaf.shell.commands.Command;
5 -import org.onlab.onos.cli.AbstractShellCommand;
6 import org.onlab.onos.net.ConnectPoint; 23 import org.onlab.onos.net.ConnectPoint;
7 import org.onlab.onos.net.DeviceId; 24 import org.onlab.onos.net.DeviceId;
8 import org.onlab.onos.net.PortNumber; 25 import org.onlab.onos.net.PortNumber;
9 -import org.onlab.onos.net.flow.DefaultTrafficSelector;
10 -import org.onlab.onos.net.flow.DefaultTrafficTreatment;
11 import org.onlab.onos.net.flow.TrafficSelector; 26 import org.onlab.onos.net.flow.TrafficSelector;
12 import org.onlab.onos.net.flow.TrafficTreatment; 27 import org.onlab.onos.net.flow.TrafficTreatment;
13 import org.onlab.onos.net.intent.Intent; 28 import org.onlab.onos.net.intent.Intent;
14 import org.onlab.onos.net.intent.IntentService; 29 import org.onlab.onos.net.intent.IntentService;
15 import org.onlab.onos.net.intent.PointToPointIntent; 30 import org.onlab.onos.net.intent.PointToPointIntent;
16 -import org.onlab.packet.Ethernet; 31 +
32 +import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
17 33
18 import static org.onlab.onos.net.DeviceId.deviceId; 34 import static org.onlab.onos.net.DeviceId.deviceId;
19 import static org.onlab.onos.net.PortNumber.portNumber; 35 import static org.onlab.onos.net.PortNumber.portNumber;
...@@ -23,7 +39,7 @@ import static org.onlab.onos.net.PortNumber.portNumber; ...@@ -23,7 +39,7 @@ import static org.onlab.onos.net.PortNumber.portNumber;
23 */ 39 */
24 @Command(scope = "onos", name = "add-point-intent", 40 @Command(scope = "onos", name = "add-point-intent",
25 description = "Installs point-to-point connectivity intent") 41 description = "Installs point-to-point connectivity intent")
26 -public class AddPointToPointIntentCommand extends AbstractShellCommand { 42 +public class AddPointToPointIntentCommand extends ConnectivityIntentCommand {
27 43
28 @Argument(index = 0, name = "ingressDevice", 44 @Argument(index = 0, name = "ingressDevice",
29 description = "Ingress Device/Port Description", 45 description = "Ingress Device/Port Description",
...@@ -47,10 +63,8 @@ public class AddPointToPointIntentCommand extends AbstractShellCommand { ...@@ -47,10 +63,8 @@ public class AddPointToPointIntentCommand extends AbstractShellCommand {
47 PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString)); 63 PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
48 ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber); 64 ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
49 65
50 - TrafficSelector selector = DefaultTrafficSelector.builder() 66 + TrafficSelector selector = buildTrafficSelector();
51 - .matchEthType(Ethernet.TYPE_IPV4) 67 + TrafficTreatment treatment = builder().build();
52 - .build();
53 - TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
54 68
55 Intent intent = new PointToPointIntent(appId(), selector, treatment, 69 Intent intent = new PointToPointIntent(appId(), selector, treatment,
56 ingress, egress); 70 ingress, egress);
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.ObjectMapper; 21 import com.fasterxml.jackson.databind.ObjectMapper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.cli.net;
20 +
21 +import org.apache.karaf.shell.commands.Option;
22 +import org.onlab.onos.cli.AbstractShellCommand;
23 +import org.onlab.onos.net.flow.DefaultTrafficSelector;
24 +import org.onlab.onos.net.flow.TrafficSelector;
25 +import org.onlab.packet.Ethernet;
26 +import org.onlab.packet.MacAddress;
27 +
28 +import com.google.common.base.Strings;
29 +
30 +/**
31 + * Base class for command line operations for connectivity based intents.
32 + */
33 +public abstract class ConnectivityIntentCommand extends AbstractShellCommand {
34 +
35 + @Option(name = "-s", aliases = "--ethSrc", description = "Source MAC Address",
36 + required = false, multiValued = false)
37 + private String srcMacString = null;
38 +
39 + @Option(name = "-d", aliases = "--ethDst", description = "Destination MAC Address",
40 + required = false, multiValued = false)
41 + private String dstMacString = null;
42 +
43 + @Option(name = "-t", aliases = "--ethType", description = "Ethernet Type",
44 + required = false, multiValued = false)
45 + private String ethTypeString = "";
46 +
47 + /**
48 + * Constructs a traffic selector based on the command line arguments
49 + * presented to the command.
50 + */
51 + protected TrafficSelector buildTrafficSelector() {
52 + TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
53 +
54 + Short ethType = Ethernet.TYPE_IPV4;
55 + if (!Strings.isNullOrEmpty(ethTypeString)) {
56 + EthType ethTypeParameter = EthType.valueOf(ethTypeString);
57 + ethType = ethTypeParameter.value();
58 + }
59 + selectorBuilder.matchEthType(ethType);
60 +
61 + if (!Strings.isNullOrEmpty(srcMacString)) {
62 + selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
63 + }
64 +
65 + if (!Strings.isNullOrEmpty(dstMacString)) {
66 + selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
67 + }
68 +
69 + return selectorBuilder.build();
70 + }
71 +
72 +}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.cli.net;
20 +
21 +import org.onlab.packet.Ethernet;
22 +
23 +/**
24 + * Allowed values for Ethernet types. Used by the CLI completer for
25 + * connectivity based intent L2 parameters.
26 + */
27 +public enum EthType {
28 + /** ARP. */
29 + ARP(Ethernet.TYPE_ARP),
30 + /** RARP. */
31 + RARP(Ethernet.TYPE_RARP),
32 + /** IPV4. */
33 + IPV4(Ethernet.TYPE_IPV4),
34 + /** LLDP. */
35 + LLDP(Ethernet.TYPE_LLDP),
36 + /** BSN. */
37 + BSN(Ethernet.TYPE_BSN);
38 +
39 + private short value;
40 +
41 + /**
42 + * Constructs an EthType with the given value.
43 + *
44 + * @param value value to use when this EthType is seen.
45 + */
46 + private EthType(short value) {
47 + this.value = value;
48 + }
49 +
50 + /**
51 + * Gets the value to use for this EthType.
52 + *
53 + * @return short value to use for this EthType
54 + */
55 + public short value() {
56 + return this.value;
57 + }
58 +}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +package org.onlab.onos.cli.net;
20 +
21 +import java.util.List;
22 +import java.util.SortedSet;
23 +
24 +import org.apache.karaf.shell.console.Completer;
25 +import org.apache.karaf.shell.console.completer.StringsCompleter;
26 +
27 +/**
28 + * Ethernet type completer.
29 + */
30 +public class EthTypeCompleter implements Completer {
31 + @Override
32 + public int complete(String buffer, int cursor, List<String> candidates) {
33 + // Delegate string completer
34 + StringsCompleter delegate = new StringsCompleter();
35 + SortedSet<String> strings = delegate.getStrings();
36 + strings.add(EthType.ARP.toString());
37 + strings.add(EthType.BSN.toString());
38 + strings.add(EthType.IPV4.toString());
39 + strings.add(EthType.LLDP.toString());
40 + strings.add(EthType.RARP.toString());
41 +
42 + // Now let the completer do the work for figuring out what to offer.
43 + return delegate.complete(buffer, cursor, candidates);
44 + }
45 +
46 +}
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import java.util.List; 21 import java.util.List;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import java.util.Iterator; 21 import java.util.Iterator;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.JsonNode; 21 import com.fasterxml.jackson.databind.JsonNode;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.console.Completer; 21 import org.apache.karaf.shell.console.Completer;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import com.fasterxml.jackson.databind.ObjectMapper; 21 import com.fasterxml.jackson.databind.ObjectMapper;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
1 package org.onlab.onos.cli.net; 19 package org.onlab.onos.cli.net;
2 20
3 import org.apache.karaf.shell.commands.Argument; 21 import org.apache.karaf.shell.commands.Argument;
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Administrative console command-line extensions for interacting with the 21 * Administrative console command-line extensions for interacting with the
3 * network model &amp; services. 22 * network model &amp; services.
......
1 +/*
2 + * Licensed to the Apache Software Foundation (ASF) under one
3 + * or more contributor license agreements. See the NOTICE file
4 + * distributed with this work for additional information
5 + * regarding copyright ownership. The ASF licenses this file
6 + * to you under the Apache License, Version 2.0 (the
7 + * "License"); you may not use this file except in compliance
8 + * with the License. You may obtain a copy of the License at
9 + *
10 + * http://www.apache.org/licenses/LICENSE-2.0
11 + *
12 + * Unless required by applicable law or agreed to in writing,
13 + * software distributed under the License is distributed on an
14 + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + * KIND, either express or implied. See the License for the
16 + * specific language governing permissions and limitations
17 + * under the License.
18 + */
19 +
1 /** 20 /**
2 * Administrative console command-line extensions. 21 * Administrative console command-line extensions.
3 */ 22 */
......
1 +<!--
2 + ~ Licensed to the Apache Software Foundation (ASF) under one
3 + ~ or more contributor license agreements. See the NOTICE file
4 + ~ distributed with this work for additional information
5 + ~ regarding copyright ownership. The ASF licenses this file
6 + ~ to you under the Apache License, Version 2.0 (the
7 + ~ "License"); you may not use this file except in compliance
8 + ~ with the License. You may obtain a copy of the License at
9 + ~
10 + ~ http://www.apache.org/licenses/LICENSE-2.0
11 + ~
12 + ~ Unless required by applicable law or agreed to in writing,
13 + ~ software distributed under the License is distributed on an
14 + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 + ~ KIND, either express or implied. See the License for the
16 + ~ specific language governing permissions and limitations
17 + ~ under the License.
18 + -->
1 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"> 19 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
2 20
3 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0"> 21 <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
...@@ -96,12 +114,18 @@ ...@@ -96,12 +114,18 @@
96 <ref component-id="connectPointCompleter"/> 114 <ref component-id="connectPointCompleter"/>
97 <null/> 115 <null/>
98 </completers> 116 </completers>
117 + <optional-completers>
118 + <entry key="-t" value-ref="ethTypeCompleter"/>
119 + </optional-completers>
99 </command> 120 </command>
100 <command> 121 <command>
101 <action class="org.onlab.onos.cli.net.AddMultiPointToSinglePointIntentCommand"/> 122 <action class="org.onlab.onos.cli.net.AddMultiPointToSinglePointIntentCommand"/>
102 <completers> 123 <completers>
103 <ref component-id="connectPointCompleter"/> 124 <ref component-id="connectPointCompleter"/>
104 </completers> 125 </completers>
126 + <optional-completers>
127 + <entry key="-t" value-ref="ethTypeCompleter"/>
128 + </optional-completers>
105 </command> 129 </command>
106 <command> 130 <command>
107 <action class="org.onlab.onos.cli.net.IntentPushTestCommand"/> 131 <action class="org.onlab.onos.cli.net.IntentPushTestCommand"/>
...@@ -158,5 +182,6 @@ ...@@ -158,5 +182,6 @@
158 <bean id="flowRuleStatusCompleter" class="org.onlab.onos.cli.net.FlowRuleStatusCompleter"/> 182 <bean id="flowRuleStatusCompleter" class="org.onlab.onos.cli.net.FlowRuleStatusCompleter"/>
159 <bean id="connectPointCompleter" class="org.onlab.onos.cli.net.ConnectPointCompleter"/> 183 <bean id="connectPointCompleter" class="org.onlab.onos.cli.net.ConnectPointCompleter"/>
160 <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/> 184 <bean id="nullCompleter" class="org.apache.karaf.shell.console.completer.NullCompleter"/>
185 + <bean id="ethTypeCompleter" class="org.onlab.onos.cli.net.EthTypeCompleter"/>
161 186
162 </blueprint> 187 </blueprint>
......
...@@ -19,6 +19,7 @@ public class AbstractListenerRegistry<E extends Event, L extends EventListener<E ...@@ -19,6 +19,7 @@ public class AbstractListenerRegistry<E extends Event, L extends EventListener<E
19 private final Logger log = getLogger(getClass()); 19 private final Logger log = getLogger(getClass());
20 20
21 private final Set<L> listeners = new CopyOnWriteArraySet<>(); 21 private final Set<L> listeners = new CopyOnWriteArraySet<>();
22 + private volatile boolean shutdown = false;
22 23
23 /** 24 /**
24 * Adds the specified listener. 25 * Adds the specified listener.
...@@ -58,7 +59,24 @@ public class AbstractListenerRegistry<E extends Event, L extends EventListener<E ...@@ -58,7 +59,24 @@ public class AbstractListenerRegistry<E extends Event, L extends EventListener<E
58 * @param error error encountered while processing 59 * @param error error encountered while processing
59 */ 60 */
60 protected void reportProblem(E event, Throwable error) { 61 protected void reportProblem(E event, Throwable error) {
61 - log.warn("Exception encountered while processing event " + event, error); 62 + if (!shutdown) {
63 + log.warn("Exception encountered while processing event " + event, error);
64 + }
65 + }
66 +
67 + /**
68 + * Prepares the registry for normal operation.
69 + */
70 + public void activate() {
71 + shutdown = false;
62 } 72 }
63 73
74 + /**
75 + * Prepares the registry for shutdown.
76 + */
77 + public void deactivate() {
78 + shutdown = true;
79 + }
80 +
81 +
64 } 82 }
......
...@@ -44,6 +44,16 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -44,6 +44,16 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
44 return new Builder(); 44 return new Builder();
45 } 45 }
46 46
47 + /**
48 + * Returns a new traffic treatment builder primed to produce entities
49 + * patterned after the supplied treatment.
50 + *
51 + * @return traffic treatment builder
52 + */
53 + public static TrafficTreatment.Builder builder(TrafficTreatment treatment) {
54 + return new Builder(treatment);
55 + }
56 +
47 //FIXME: Order of instructions may affect hashcode 57 //FIXME: Order of instructions may affect hashcode
48 @Override 58 @Override
49 public int hashCode() { 59 public int hashCode() {
...@@ -90,6 +100,13 @@ public final class DefaultTrafficTreatment implements TrafficTreatment { ...@@ -90,6 +100,13 @@ public final class DefaultTrafficTreatment implements TrafficTreatment {
90 private Builder() { 100 private Builder() {
91 } 101 }
92 102
103 + // Creates a new builder based off an existing treatment
104 + private Builder(TrafficTreatment treatment) {
105 + for (Instruction instruction : treatment.instructions()) {
106 + add(instruction);
107 + }
108 + }
109 +
93 @Override 110 @Override
94 public Builder add(Instruction instruction) { 111 public Builder add(Instruction instruction) {
95 if (drop) { 112 if (drop) {
......
...@@ -41,7 +41,7 @@ public final class HostToHostIntent extends ConnectivityIntent { ...@@ -41,7 +41,7 @@ public final class HostToHostIntent extends ConnectivityIntent {
41 } 41 }
42 42
43 private static HostId max(HostId one, HostId two) { 43 private static HostId max(HostId one, HostId two) {
44 - return one.hashCode() > two.hashCode() ? one : two; 44 + return one.hashCode() >= two.hashCode() ? one : two;
45 } 45 }
46 46
47 /** 47 /**
......
...@@ -37,8 +37,8 @@ public abstract class Intent implements BatchOperationTarget { ...@@ -37,8 +37,8 @@ public abstract class Intent implements BatchOperationTarget {
37 */ 37 */
38 protected Intent(IntentId id, ApplicationId appId, 38 protected Intent(IntentId id, ApplicationId appId,
39 Collection<NetworkResource> resources) { 39 Collection<NetworkResource> resources) {
40 + this.id = checkNotNull(id, "Intent ID cannot be null");
40 this.appId = checkNotNull(appId, "Application ID cannot be null"); 41 this.appId = checkNotNull(appId, "Application ID cannot be null");
41 - this.id = checkNotNull(id, "Fingerprint cannot be null");
42 this.resources = resources; 42 this.resources = resources;
43 } 43 }
44 44
...@@ -77,6 +77,7 @@ public abstract class Intent implements BatchOperationTarget { ...@@ -77,6 +77,7 @@ public abstract class Intent implements BatchOperationTarget {
77 * @return intent identifier 77 * @return intent identifier
78 */ 78 */
79 protected static IntentId id(Object... fields) { 79 protected static IntentId id(Object... fields) {
80 + // FIXME: spread the bits across the full long spectrum
80 return IntentId.valueOf(Objects.hash(fields)); 81 return IntentId.valueOf(Objects.hash(fields));
81 } 82 }
82 83
...@@ -90,12 +91,12 @@ public abstract class Intent implements BatchOperationTarget { ...@@ -90,12 +91,12 @@ public abstract class Intent implements BatchOperationTarget {
90 } 91 }
91 92
92 @Override 93 @Override
93 - public int hashCode() { 94 + public final int hashCode() {
94 return Objects.hash(id); 95 return Objects.hash(id);
95 } 96 }
96 97
97 @Override 98 @Override
98 - public boolean equals(Object obj) { 99 + public final boolean equals(Object obj) {
99 if (this == obj) { 100 if (this == obj) {
100 return true; 101 return true;
101 } 102 }
......
1 package org.onlab.onos.net.intent.impl; 1 package org.onlab.onos.net.intent.impl;
2 2
3 -import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
4 import static org.slf4j.LoggerFactory.getLogger; 3 import static org.slf4j.LoggerFactory.getLogger;
5 4
6 import java.util.List; 5 import java.util.List;
...@@ -17,6 +16,7 @@ import org.onlab.onos.net.Link; ...@@ -17,6 +16,7 @@ import org.onlab.onos.net.Link;
17 import org.onlab.onos.net.PortNumber; 16 import org.onlab.onos.net.PortNumber;
18 import org.onlab.onos.net.flow.DefaultFlowRule; 17 import org.onlab.onos.net.flow.DefaultFlowRule;
19 import org.onlab.onos.net.flow.DefaultTrafficSelector; 18 import org.onlab.onos.net.flow.DefaultTrafficSelector;
19 +import org.onlab.onos.net.flow.DefaultTrafficTreatment;
20 import org.onlab.onos.net.flow.FlowRule; 20 import org.onlab.onos.net.flow.FlowRule;
21 import org.onlab.onos.net.flow.FlowRuleBatchEntry; 21 import org.onlab.onos.net.flow.FlowRuleBatchEntry;
22 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation; 22 import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
...@@ -61,18 +61,16 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -61,18 +61,16 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
61 61
62 @Override 62 @Override
63 public List<FlowRuleBatchOperation> install(LinkCollectionIntent intent) { 63 public List<FlowRuleBatchOperation> install(LinkCollectionIntent intent) {
64 - TrafficSelector.Builder builder =
65 - DefaultTrafficSelector.builder(intent.selector());
66 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 64 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
67 for (Link link : intent.links()) { 65 for (Link link : intent.links()) {
68 rules.add(createBatchEntry(FlowRuleOperation.ADD, 66 rules.add(createBatchEntry(FlowRuleOperation.ADD,
69 - builder.build(), 67 + intent,
70 link.src().deviceId(), 68 link.src().deviceId(),
71 link.src().port())); 69 link.src().port()));
72 } 70 }
73 71
74 rules.add(createBatchEntry(FlowRuleOperation.ADD, 72 rules.add(createBatchEntry(FlowRuleOperation.ADD,
75 - builder.build(), 73 + intent,
76 intent.egressPoint().deviceId(), 74 intent.egressPoint().deviceId(),
77 intent.egressPoint().port())); 75 intent.egressPoint().port()));
78 76
...@@ -81,19 +79,17 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -81,19 +79,17 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
81 79
82 @Override 80 @Override
83 public List<FlowRuleBatchOperation> uninstall(LinkCollectionIntent intent) { 81 public List<FlowRuleBatchOperation> uninstall(LinkCollectionIntent intent) {
84 - TrafficSelector.Builder builder =
85 - DefaultTrafficSelector.builder(intent.selector());
86 List<FlowRuleBatchEntry> rules = Lists.newLinkedList(); 82 List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
87 83
88 for (Link link : intent.links()) { 84 for (Link link : intent.links()) {
89 rules.add(createBatchEntry(FlowRuleOperation.REMOVE, 85 rules.add(createBatchEntry(FlowRuleOperation.REMOVE,
90 - builder.build(), 86 + intent,
91 link.src().deviceId(), 87 link.src().deviceId(),
92 link.src().port())); 88 link.src().port()));
93 } 89 }
94 90
95 rules.add(createBatchEntry(FlowRuleOperation.REMOVE, 91 rules.add(createBatchEntry(FlowRuleOperation.REMOVE,
96 - builder.build(), 92 + intent,
97 intent.egressPoint().deviceId(), 93 intent.egressPoint().deviceId(),
98 intent.egressPoint().port())); 94 intent.egressPoint().port()));
99 95
...@@ -104,17 +100,23 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec ...@@ -104,17 +100,23 @@ public class LinkCollectionIntentInstaller implements IntentInstaller<LinkCollec
104 * Creates a FlowRuleBatchEntry based on the provided parameters. 100 * Creates a FlowRuleBatchEntry based on the provided parameters.
105 * 101 *
106 * @param operation the FlowRuleOperation to use 102 * @param operation the FlowRuleOperation to use
107 - * @param selector the traffic selector 103 + * @param intent the link collection intent
108 * @param deviceId the device ID for the flow rule 104 * @param deviceId the device ID for the flow rule
109 * @param outPort the output port of the flow rule 105 * @param outPort the output port of the flow rule
110 * @return the new flow rule batch entry 106 * @return the new flow rule batch entry
111 */ 107 */
112 private FlowRuleBatchEntry createBatchEntry(FlowRuleOperation operation, 108 private FlowRuleBatchEntry createBatchEntry(FlowRuleOperation operation,
113 - TrafficSelector selector, 109 + LinkCollectionIntent intent,
114 DeviceId deviceId, 110 DeviceId deviceId,
115 PortNumber outPort) { 111 PortNumber outPort) {
116 112
117 - TrafficTreatment treatment = builder().setOutput(outPort).build(); 113 + TrafficTreatment.Builder treatmentBuilder =
114 + DefaultTrafficTreatment.builder(intent.treatment());
115 +
116 + TrafficTreatment treatment = treatmentBuilder.setOutput(outPort).build();
117 +
118 + TrafficSelector selector = DefaultTrafficSelector.builder(intent.selector())
119 + .build();
118 120
119 FlowRule rule = new DefaultFlowRule(deviceId, 121 FlowRule rule = new DefaultFlowRule(deviceId,
120 selector, treatment, 123, appId, 0, true); 122 selector, treatment, 123, appId, 0, true);
......
...@@ -67,7 +67,7 @@ public class ClusterCommunicationManager ...@@ -67,7 +67,7 @@ public class ClusterCommunicationManager
67 @Activate 67 @Activate
68 public void activate() { 68 public void activate() {
69 ControllerNode localNode = clusterService.getLocalNode(); 69 ControllerNode localNode = clusterService.getLocalNode();
70 - NettyMessagingService netty = new NettyMessagingService(localNode.tcpPort()); 70 + NettyMessagingService netty = new NettyMessagingService(localNode.ip().toString(), localNode.tcpPort());
71 // FIXME: workaround until it becomes a service. 71 // FIXME: workaround until it becomes a service.
72 try { 72 try {
73 netty.activate(); 73 netty.activate();
......
...@@ -23,9 +23,9 @@ import org.onlab.onos.net.DefaultAnnotations; ...@@ -23,9 +23,9 @@ import org.onlab.onos.net.DefaultAnnotations;
23 import org.onlab.onos.net.DefaultLink; 23 import org.onlab.onos.net.DefaultLink;
24 import org.onlab.onos.net.DeviceId; 24 import org.onlab.onos.net.DeviceId;
25 import org.onlab.onos.net.Link; 25 import org.onlab.onos.net.Link;
26 -import org.onlab.onos.net.SparseAnnotations;
27 import org.onlab.onos.net.Link.Type; 26 import org.onlab.onos.net.Link.Type;
28 import org.onlab.onos.net.LinkKey; 27 import org.onlab.onos.net.LinkKey;
28 +import org.onlab.onos.net.SparseAnnotations;
29 import org.onlab.onos.net.device.DeviceClockService; 29 import org.onlab.onos.net.device.DeviceClockService;
30 import org.onlab.onos.net.link.DefaultLinkDescription; 30 import org.onlab.onos.net.link.DefaultLinkDescription;
31 import org.onlab.onos.net.link.LinkDescription; 31 import org.onlab.onos.net.link.LinkDescription;
...@@ -266,8 +266,8 @@ public class GossipLinkStore ...@@ -266,8 +266,8 @@ public class GossipLinkStore
266 ProviderId providerId, 266 ProviderId providerId,
267 Timestamped<LinkDescription> linkDescription) { 267 Timestamped<LinkDescription> linkDescription) {
268 268
269 - LinkKey key = linkKey(linkDescription.value().src(), 269 + final LinkKey key = linkKey(linkDescription.value().src(),
270 - linkDescription.value().dst()); 270 + linkDescription.value().dst());
271 Map<ProviderId, Timestamped<LinkDescription>> descs = getOrCreateLinkDescriptions(key); 271 Map<ProviderId, Timestamped<LinkDescription>> descs = getOrCreateLinkDescriptions(key);
272 272
273 synchronized (descs) { 273 synchronized (descs) {
...@@ -278,6 +278,7 @@ public class GossipLinkStore ...@@ -278,6 +278,7 @@ public class GossipLinkStore
278 if (linkDescription.isNewer(linkRemovedTimestamp)) { 278 if (linkDescription.isNewer(linkRemovedTimestamp)) {
279 removedLinks.remove(key); 279 removedLinks.remove(key);
280 } else { 280 } else {
281 + log.trace("Link {} was already removed ignoring.", key);
281 return null; 282 return null;
282 } 283 }
283 } 284 }
...@@ -302,17 +303,25 @@ public class GossipLinkStore ...@@ -302,17 +303,25 @@ public class GossipLinkStore
302 // merge existing annotations 303 // merge existing annotations
303 Timestamped<LinkDescription> existingLinkDescription = descs.get(providerId); 304 Timestamped<LinkDescription> existingLinkDescription = descs.get(providerId);
304 if (existingLinkDescription != null && existingLinkDescription.isNewer(linkDescription)) { 305 if (existingLinkDescription != null && existingLinkDescription.isNewer(linkDescription)) {
306 + log.trace("local info is more up-to-date, ignoring {}.", linkDescription);
305 return null; 307 return null;
306 } 308 }
307 Timestamped<LinkDescription> newLinkDescription = linkDescription; 309 Timestamped<LinkDescription> newLinkDescription = linkDescription;
308 if (existingLinkDescription != null) { 310 if (existingLinkDescription != null) {
311 + // we only allow transition from INDIRECT -> DIRECT
312 + final Type newType;
313 + if (existingLinkDescription.value().type() == DIRECT) {
314 + newType = DIRECT;
315 + } else {
316 + newType = linkDescription.value().type();
317 + }
309 SparseAnnotations merged = union(existingLinkDescription.value().annotations(), 318 SparseAnnotations merged = union(existingLinkDescription.value().annotations(),
310 linkDescription.value().annotations()); 319 linkDescription.value().annotations());
311 newLinkDescription = new Timestamped<LinkDescription>( 320 newLinkDescription = new Timestamped<LinkDescription>(
312 new DefaultLinkDescription( 321 new DefaultLinkDescription(
313 linkDescription.value().src(), 322 linkDescription.value().src(),
314 linkDescription.value().dst(), 323 linkDescription.value().dst(),
315 - linkDescription.value().type(), merged), 324 + newType, merged),
316 linkDescription.timestamp()); 325 linkDescription.timestamp());
317 } 326 }
318 return descs.put(providerId, newLinkDescription); 327 return descs.put(providerId, newLinkDescription);
...@@ -346,6 +355,8 @@ public class GossipLinkStore ...@@ -346,6 +355,8 @@ public class GossipLinkStore
346 return null; 355 return null;
347 } 356 }
348 357
358 + // Note: INDIRECT -> DIRECT transition only
359 + // so that BDDP discovered Link will not overwrite LDDP Link
349 if ((oldLink.type() == INDIRECT && newLink.type() == DIRECT) || 360 if ((oldLink.type() == INDIRECT && newLink.type() == DIRECT) ||
350 !AnnotationsUtil.isEqual(oldLink.annotations(), newLink.annotations())) { 361 !AnnotationsUtil.isEqual(oldLink.annotations(), newLink.annotations())) {
351 362
......
...@@ -172,12 +172,19 @@ public class SimpleLinkStore ...@@ -172,12 +172,19 @@ public class SimpleLinkStore
172 LinkDescription oldDesc = descs.get(providerId); 172 LinkDescription oldDesc = descs.get(providerId);
173 LinkDescription newDesc = linkDescription; 173 LinkDescription newDesc = linkDescription;
174 if (oldDesc != null) { 174 if (oldDesc != null) {
175 + // we only allow transition from INDIRECT -> DIRECT
176 + final Type newType;
177 + if (oldDesc.type() == DIRECT) {
178 + newType = DIRECT;
179 + } else {
180 + newType = linkDescription.type();
181 + }
175 SparseAnnotations merged = union(oldDesc.annotations(), 182 SparseAnnotations merged = union(oldDesc.annotations(),
176 linkDescription.annotations()); 183 linkDescription.annotations());
177 newDesc = new DefaultLinkDescription( 184 newDesc = new DefaultLinkDescription(
178 linkDescription.src(), 185 linkDescription.src(),
179 linkDescription.dst(), 186 linkDescription.dst(),
180 - linkDescription.type(), merged); 187 + newType, merged);
181 } 188 }
182 return descs.put(providerId, newDesc); 189 return descs.put(providerId, newDesc);
183 } 190 }
......
1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 1 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<!--
3 + ~ Licensed to the Apache Software Foundation (ASF) under one
4 + ~ or more contributor license agreements. See the NOTICE file
5 + ~ distributed with this work for additional information
6 + ~ regarding copyright ownership. The ASF licenses this file
7 + ~ to you under the Apache License, Version 2.0 (the
8 + ~ "License"); you may not use this file except in compliance
9 + ~ with the License. You may obtain a copy of the License at
10 + ~
11 + ~ http://www.apache.org/licenses/LICENSE-2.0
12 + ~
13 + ~ Unless required by applicable law or agreed to in writing,
14 + ~ software distributed under the License is distributed on an
15 + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 + ~ KIND, either express or implied. See the License for the
17 + ~ specific language governing permissions and limitations
18 + ~ under the License.
19 + -->
2 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" 20 <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
3 name="onos-1.0.0"> 21 name="onos-1.0.0">
4 - <repository>mvn:org.onlab.onos/onos-features/1.0.0-SNAPSHOT/xml/features 22 + <repository>mvn:org.onlab.onos/onos-features/1.0.0-SNAPSHOT/xml/features</repository>
5 - </repository>
6 23
7 <feature name="onos-thirdparty-base" version="1.0.0" 24 <feature name="onos-thirdparty-base" version="1.0.0"
8 description="ONOS 3rd party dependencies"> 25 description="ONOS 3rd party dependencies">
...@@ -15,6 +32,7 @@ ...@@ -15,6 +32,7 @@
15 <bundle>mvn:io.netty/netty-transport/4.0.23.Final</bundle> 32 <bundle>mvn:io.netty/netty-transport/4.0.23.Final</bundle>
16 <bundle>mvn:io.netty/netty-handler/4.0.23.Final</bundle> 33 <bundle>mvn:io.netty/netty-handler/4.0.23.Final</bundle>
17 <bundle>mvn:io.netty/netty-codec/4.0.23.Final</bundle> 34 <bundle>mvn:io.netty/netty-codec/4.0.23.Final</bundle>
35 + <bundle>mvn:io.netty/netty-transport-native-epoll/4.0.23.Final</bundle>
18 <bundle>mvn:commons-pool/commons-pool/1.6</bundle> 36 <bundle>mvn:commons-pool/commons-pool/1.6</bundle>
19 37
20 <bundle>mvn:com.hazelcast/hazelcast/3.3</bundle> 38 <bundle>mvn:com.hazelcast/hazelcast/3.3</bundle>
......
...@@ -312,6 +312,11 @@ ...@@ -312,6 +312,11 @@
312 <artifactId>netty-codec</artifactId> 312 <artifactId>netty-codec</artifactId>
313 <version>${netty4.version}</version> 313 <version>${netty4.version}</version>
314 </dependency> 314 </dependency>
315 + <dependency>
316 + <groupId>io.netty</groupId>
317 + <artifactId>netty-transport-native-epoll</artifactId>
318 + <version>${netty4.version}</version>
319 + </dependency>
315 </dependencies> 320 </dependencies>
316 </dependencyManagement> 321 </dependencyManagement>
317 322
......
...@@ -6,8 +6,17 @@ ...@@ -6,8 +6,17 @@
6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1 6 [ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 . $ONOS_ROOT/tools/build/envDefaults 7 . $ONOS_ROOT/tools/build/envDefaults
8 8
9 -# If the first option is -f attempt uninstall first. 9 +while getopts fn o; do
10 -[ "$1" = "-f" ] && shift && onos-uninstall ${1:-$OCI} 10 + case "$o" in
11 + f) uninstall=true;;
12 + n) nostart=true;;
13 + esac
14 +done
15 +let OPC=$OPTIND-1
16 +shift $OPC
17 +
18 +# If the -f was given, attempt uninstall first.
19 +[ -n "$uninstall" ] && onos-uninstall ${1:-$OCI}
11 20
12 node=${1:-$OCI} 21 node=${1:-$OCI}
13 remote=$ONOS_USER@$node 22 remote=$ONOS_USER@$node
...@@ -27,19 +36,20 @@ ssh $remote " ...@@ -27,19 +36,20 @@ ssh $remote "
27 mkdir $ONOS_INSTALL_DIR/config 36 mkdir $ONOS_INSTALL_DIR/config
28 37
29 # Install the upstart configuration file and setup options for debugging 38 # Install the upstart configuration file and setup options for debugging
30 - sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf 39 + [ -z "$nostart" ] && sudo cp $ONOS_INSTALL_DIR/debian/onos.conf /etc/init/onos.conf
31 echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options 40 echo 'export ONOS_OPTS=debug' > $ONOS_INSTALL_DIR/options
32 41
33 # Remove any previous ON.Lab bits from ~/.m2 repo 42 # Remove any previous ON.Lab bits from ~/.m2 repo
34 rm -fr ~/.m2/repository/org/onlab 43 rm -fr ~/.m2/repository/org/onlab
35 44
36 # Drop log level for the console 45 # Drop log level for the console
37 - echo "log4j.logger.org.apache.sshd = WARN" >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg 46 + echo "log4j.logger.org.apache.sshd = WARN" \
47 + >> $ONOS_INSTALL_DIR/$KARAF_DIST/etc/org.ops4j.pax.logging.cfg
38 48
39 " 49 "
40 50
41 # Configure the ONOS installation 51 # Configure the ONOS installation
42 onos-config $node 52 onos-config $node
43 53
44 -# Ignite the ONOS service. 54 +# Unless -n option was given, attempt to ignite the ONOS service.
45 -onos-service $node start 55 +[ -z "$nostart" ] && onos-service $node start
......
...@@ -55,6 +55,10 @@ ...@@ -55,6 +55,10 @@
55 <groupId>io.netty</groupId> 55 <groupId>io.netty</groupId>
56 <artifactId>netty-codec</artifactId> 56 <artifactId>netty-codec</artifactId>
57 </dependency> 57 </dependency>
58 + <dependency>
59 + <groupId>io.netty</groupId>
60 + <artifactId>netty-transport-native-epoll</artifactId>
61 + </dependency>
58 </dependencies> 62 </dependencies>
59 63
60 </project> 64 </project>
......
...@@ -44,8 +44,7 @@ public final class InternalMessage implements Message { ...@@ -44,8 +44,7 @@ public final class InternalMessage implements Message {
44 public void respond(byte[] data) throws IOException { 44 public void respond(byte[] data) throws IOException {
45 Builder builder = new Builder(messagingService); 45 Builder builder = new Builder(messagingService);
46 InternalMessage message = builder.withId(this.id) 46 InternalMessage message = builder.withId(this.id)
47 - // FIXME: Sender should be messagingService.localEp. 47 + .withSender(messagingService.localEp())
48 - .withSender(this.sender)
49 .withPayload(data) 48 .withPayload(data)
50 .withType(REPLY_MESSAGE_TYPE) 49 .withType(REPLY_MESSAGE_TYPE)
51 .build(); 50 .build();
......
...@@ -16,7 +16,11 @@ import io.netty.channel.ChannelHandlerContext; ...@@ -16,7 +16,11 @@ import io.netty.channel.ChannelHandlerContext;
16 import io.netty.channel.ChannelInitializer; 16 import io.netty.channel.ChannelInitializer;
17 import io.netty.channel.ChannelOption; 17 import io.netty.channel.ChannelOption;
18 import io.netty.channel.EventLoopGroup; 18 import io.netty.channel.EventLoopGroup;
19 +import io.netty.channel.ServerChannel;
19 import io.netty.channel.SimpleChannelInboundHandler; 20 import io.netty.channel.SimpleChannelInboundHandler;
21 +import io.netty.channel.epoll.EpollEventLoopGroup;
22 +import io.netty.channel.epoll.EpollServerSocketChannel;
23 +import io.netty.channel.epoll.EpollSocketChannel;
20 import io.netty.channel.nio.NioEventLoopGroup; 24 import io.netty.channel.nio.NioEventLoopGroup;
21 import io.netty.channel.socket.SocketChannel; 25 import io.netty.channel.socket.SocketChannel;
22 import io.netty.channel.socket.nio.NioServerSocketChannel; 26 import io.netty.channel.socket.nio.NioServerSocketChannel;
...@@ -38,11 +42,7 @@ public class NettyMessagingService implements MessagingService { ...@@ -38,11 +42,7 @@ public class NettyMessagingService implements MessagingService {
38 42
39 private final Logger log = LoggerFactory.getLogger(getClass()); 43 private final Logger log = LoggerFactory.getLogger(getClass());
40 44
41 - private final int port;
42 private final Endpoint localEp; 45 private final Endpoint localEp;
43 - private final EventLoopGroup bossGroup = new NioEventLoopGroup();
44 - private EventLoopGroup workerGroup;
45 - private Class<? extends Channel> channelClass;
46 private final ConcurrentMap<String, MessageHandler> handlers = new ConcurrentHashMap<>(); 46 private final ConcurrentMap<String, MessageHandler> handlers = new ConcurrentHashMap<>();
47 private final Cache<Long, AsyncResponse> responseFutures = CacheBuilder.newBuilder() 47 private final Cache<Long, AsyncResponse> responseFutures = CacheBuilder.newBuilder()
48 .maximumSize(100000) 48 .maximumSize(100000)
...@@ -53,10 +53,31 @@ public class NettyMessagingService implements MessagingService { ...@@ -53,10 +53,31 @@ public class NettyMessagingService implements MessagingService {
53 private final GenericKeyedObjectPool<Endpoint, Channel> channels 53 private final GenericKeyedObjectPool<Endpoint, Channel> channels
54 = new GenericKeyedObjectPool<Endpoint, Channel>(new OnosCommunicationChannelFactory()); 54 = new GenericKeyedObjectPool<Endpoint, Channel>(new OnosCommunicationChannelFactory());
55 55
56 - // TODO: make this configurable. 56 + private EventLoopGroup serverGroup;
57 + private EventLoopGroup clientGroup;
58 + private Class<? extends ServerChannel> serverChannelClass;
59 + private Class<? extends Channel> clientChannelClass;
60 +
57 private void initEventLoopGroup() { 61 private void initEventLoopGroup() {
58 - workerGroup = new NioEventLoopGroup(); 62 + // try Epoll first and if that does work, use nio.
59 - channelClass = NioSocketChannel.class; 63 + // TODO: make this configurable.
64 + try {
65 + clientGroup = new EpollEventLoopGroup();
66 + serverGroup = new EpollEventLoopGroup();
67 + serverChannelClass = EpollServerSocketChannel.class;
68 + clientChannelClass = EpollSocketChannel.class;
69 + return;
70 + } catch (Throwable t) {
71 + log.warn("Failed to initialize native (epoll) transport. Proceeding with nio.", t);
72 + }
73 + clientGroup = new NioEventLoopGroup();
74 + serverGroup = new NioEventLoopGroup();
75 + serverChannelClass = NioServerSocketChannel.class;
76 + clientChannelClass = NioSocketChannel.class;
77 + }
78 +
79 + public NettyMessagingService(String ip, int port) {
80 + localEp = new Endpoint(ip, port);
60 } 81 }
61 82
62 public NettyMessagingService() { 83 public NettyMessagingService() {
...@@ -66,7 +87,6 @@ public class NettyMessagingService implements MessagingService { ...@@ -66,7 +87,6 @@ public class NettyMessagingService implements MessagingService {
66 87
67 // FIXME: Constructor should not throw exceptions. 88 // FIXME: Constructor should not throw exceptions.
68 public NettyMessagingService(int port) { 89 public NettyMessagingService(int port) {
69 - this.port = port;
70 try { 90 try {
71 localEp = new Endpoint(java.net.InetAddress.getLocalHost().getHostName(), port); 91 localEp = new Endpoint(java.net.InetAddress.getLocalHost().getHostName(), port);
72 } catch (UnknownHostException e) { 92 } catch (UnknownHostException e) {
...@@ -84,8 +104,16 @@ public class NettyMessagingService implements MessagingService { ...@@ -84,8 +104,16 @@ public class NettyMessagingService implements MessagingService {
84 104
85 public void deactivate() throws Exception { 105 public void deactivate() throws Exception {
86 channels.close(); 106 channels.close();
87 - bossGroup.shutdownGracefully(); 107 + serverGroup.shutdownGracefully();
88 - workerGroup.shutdownGracefully(); 108 + clientGroup.shutdownGracefully();
109 + }
110 +
111 + /**
112 + * Returns the local endpoint for this instance.
113 + * @return local end point.
114 + */
115 + public Endpoint localEp() {
116 + return localEp;
89 } 117 }
90 118
91 @Override 119 @Override
...@@ -109,7 +137,7 @@ public class NettyMessagingService implements MessagingService { ...@@ -109,7 +137,7 @@ public class NettyMessagingService implements MessagingService {
109 channels.returnObject(ep, channel); 137 channels.returnObject(ep, channel);
110 } 138 }
111 } catch (Exception e) { 139 } catch (Exception e) {
112 - throw new IOException(e); 140 + throw new IOException("Failed to send message to " + ep.toString(), e);
113 } 141 }
114 } 142 }
115 143
...@@ -149,14 +177,14 @@ public class NettyMessagingService implements MessagingService { ...@@ -149,14 +177,14 @@ public class NettyMessagingService implements MessagingService {
149 b.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024); 177 b.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);
150 // TODO: Need JVM options to configure PooledByteBufAllocator. 178 // TODO: Need JVM options to configure PooledByteBufAllocator.
151 b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); 179 b.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
152 - b.group(bossGroup, workerGroup) 180 + b.group(serverGroup, clientGroup)
153 - .channel(NioServerSocketChannel.class) 181 + .channel(serverChannelClass)
154 .childHandler(new OnosCommunicationChannelInitializer()) 182 .childHandler(new OnosCommunicationChannelInitializer())
155 .option(ChannelOption.SO_BACKLOG, 128) 183 .option(ChannelOption.SO_BACKLOG, 128)
156 .childOption(ChannelOption.SO_KEEPALIVE, true); 184 .childOption(ChannelOption.SO_KEEPALIVE, true);
157 185
158 // Bind and start to accept incoming connections. 186 // Bind and start to accept incoming connections.
159 - b.bind(port).sync(); 187 + b.bind(localEp.port()).sync();
160 } 188 }
161 189
162 private class OnosCommunicationChannelFactory 190 private class OnosCommunicationChannelFactory
...@@ -178,10 +206,10 @@ public class NettyMessagingService implements MessagingService { ...@@ -178,10 +206,10 @@ public class NettyMessagingService implements MessagingService {
178 bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); 206 bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
179 bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024); 207 bootstrap.option(ChannelOption.WRITE_BUFFER_HIGH_WATER_MARK, 32 * 1024);
180 bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024); 208 bootstrap.option(ChannelOption.WRITE_BUFFER_LOW_WATER_MARK, 8 * 1024);
181 - bootstrap.group(workerGroup); 209 + bootstrap.group(clientGroup);
182 // TODO: Make this faster: 210 // TODO: Make this faster:
183 // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0 211 // http://normanmaurer.me/presentations/2014-facebook-eng-netty/slides.html#37.0
184 - bootstrap.channel(channelClass); 212 + bootstrap.channel(clientChannelClass);
185 bootstrap.option(ChannelOption.SO_KEEPALIVE, true); 213 bootstrap.option(ChannelOption.SO_KEEPALIVE, true);
186 bootstrap.handler(new OnosCommunicationChannelInitializer()); 214 bootstrap.handler(new OnosCommunicationChannelInitializer());
187 // Start the client. 215 // Start the client.
......