alshabib

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

...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 <param-name>com.sun.jersey.config.property.packages</param-name> 16 <param-name>com.sun.jersey.config.property.packages</param-name>
17 <param-value>org.onlab.onos.tvue</param-value> 17 <param-value>org.onlab.onos.tvue</param-value>
18 </init-param> 18 </init-param>
19 - <load-on-startup>1</load-on-startup> 19 + <load-on-startup>10</load-on-startup>
20 </servlet> 20 </servlet>
21 21
22 <servlet-mapping> 22 <servlet-mapping>
......
...@@ -8,6 +8,8 @@ import org.onlab.onos.net.DeviceId; ...@@ -8,6 +8,8 @@ import org.onlab.onos.net.DeviceId;
8 */ 8 */
9 public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> { 9 public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceId> {
10 10
11 + //do we worry about explicitly setting slaves/equals? probably not,
12 + //to keep it simple
11 NodeId master; 13 NodeId master;
12 14
13 /** 15 /**
...@@ -28,7 +30,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -28,7 +30,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
28 * @param device event device subject 30 * @param device event device subject
29 * @param master master ID subject 31 * @param master master ID subject
30 */ 32 */
31 - protected MastershipEvent(Type type, DeviceId device, NodeId master) { 33 + public MastershipEvent(Type type, DeviceId device, NodeId master) {
32 super(type, device); 34 super(type, device);
33 this.master = master; 35 this.master = master;
34 } 36 }
...@@ -42,7 +44,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI ...@@ -42,7 +44,7 @@ public class MastershipEvent extends AbstractEvent<MastershipEvent.Type, DeviceI
42 * @param master master ID subject 44 * @param master master ID subject
43 * @param time occurrence time 45 * @param time occurrence time
44 */ 46 */
45 - protected MastershipEvent(Type type, DeviceId device, NodeId master, long time) { 47 + public MastershipEvent(Type type, DeviceId device, NodeId master, long time) {
46 super(type, device, time); 48 super(type, device, time);
47 this.master = master; 49 this.master = master;
48 } 50 }
......
...@@ -5,9 +5,12 @@ import static org.slf4j.LoggerFactory.getLogger; ...@@ -5,9 +5,12 @@ import static org.slf4j.LoggerFactory.getLogger;
5 import java.util.Set; 5 import java.util.Set;
6 6
7 import org.apache.felix.scr.annotations.Activate; 7 import org.apache.felix.scr.annotations.Activate;
8 +import org.apache.felix.scr.annotations.Component;
8 import org.apache.felix.scr.annotations.Deactivate; 9 import org.apache.felix.scr.annotations.Deactivate;
9 import org.apache.felix.scr.annotations.Reference; 10 import org.apache.felix.scr.annotations.Reference;
10 import org.apache.felix.scr.annotations.ReferenceCardinality; 11 import org.apache.felix.scr.annotations.ReferenceCardinality;
12 +import org.apache.felix.scr.annotations.Service;
13 +import org.onlab.onos.cluster.ClusterService;
11 import org.onlab.onos.cluster.MastershipAdminService; 14 import org.onlab.onos.cluster.MastershipAdminService;
12 import org.onlab.onos.cluster.MastershipEvent; 15 import org.onlab.onos.cluster.MastershipEvent;
13 import org.onlab.onos.cluster.MastershipListener; 16 import org.onlab.onos.cluster.MastershipListener;
...@@ -26,6 +29,8 @@ import org.slf4j.Logger; ...@@ -26,6 +29,8 @@ import org.slf4j.Logger;
26 29
27 import static com.google.common.base.Preconditions.checkNotNull; 30 import static com.google.common.base.Preconditions.checkNotNull;
28 31
32 +@Component(immediate = true)
33 +@Service
29 public class MastershipManager 34 public class MastershipManager
30 extends AbstractProviderRegistry<MastershipProvider, MastershipProviderService> 35 extends AbstractProviderRegistry<MastershipProvider, MastershipProviderService>
31 implements MastershipService, MastershipAdminService { 36 implements MastershipService, MastershipAdminService {
...@@ -46,7 +51,7 @@ public class MastershipManager ...@@ -46,7 +51,7 @@ public class MastershipManager
46 protected EventDeliveryService eventDispatcher; 51 protected EventDeliveryService eventDispatcher;
47 52
48 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 53 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
49 - protected ClusterManager clusterManager; 54 + protected ClusterService clusterService;
50 55
51 @Activate 56 @Activate
52 public void activate() { 57 public void activate() {
...@@ -65,7 +70,10 @@ public class MastershipManager ...@@ -65,7 +70,10 @@ public class MastershipManager
65 checkNotNull(nodeId, NODE_ID_NULL); 70 checkNotNull(nodeId, NODE_ID_NULL);
66 checkNotNull(deviceId, DEVICE_ID_NULL); 71 checkNotNull(deviceId, DEVICE_ID_NULL);
67 checkNotNull(role, ROLE_NULL); 72 checkNotNull(role, ROLE_NULL);
68 - store.setRole(nodeId, deviceId, role); 73 + MastershipEvent event = store.setRole(nodeId, deviceId, role);
74 + if (event != null) {
75 + post(event);
76 + }
69 } 77 }
70 78
71 @Override 79 @Override
...@@ -83,7 +91,7 @@ public class MastershipManager ...@@ -83,7 +91,7 @@ public class MastershipManager
83 @Override 91 @Override
84 public MastershipRole requestRoleFor(DeviceId deviceId) { 92 public MastershipRole requestRoleFor(DeviceId deviceId) {
85 checkNotNull(deviceId, DEVICE_ID_NULL); 93 checkNotNull(deviceId, DEVICE_ID_NULL);
86 - NodeId id = clusterManager.getLocalNode().id(); 94 + NodeId id = clusterService.getLocalNode().id();
87 return store.getRole(id, deviceId); 95 return store.getRole(id, deviceId);
88 } 96 }
89 97
......
...@@ -6,6 +6,7 @@ import org.apache.felix.scr.annotations.Deactivate; ...@@ -6,6 +6,7 @@ import org.apache.felix.scr.annotations.Deactivate;
6 import org.apache.felix.scr.annotations.Reference; 6 import org.apache.felix.scr.annotations.Reference;
7 import org.apache.felix.scr.annotations.ReferenceCardinality; 7 import org.apache.felix.scr.annotations.ReferenceCardinality;
8 import org.apache.felix.scr.annotations.Service; 8 import org.apache.felix.scr.annotations.Service;
9 +import org.onlab.onos.cluster.MastershipService;
9 import org.onlab.onos.event.AbstractListenerRegistry; 10 import org.onlab.onos.event.AbstractListenerRegistry;
10 import org.onlab.onos.event.EventDeliveryService; 11 import org.onlab.onos.event.EventDeliveryService;
11 import org.onlab.onos.net.Device; 12 import org.onlab.onos.net.Device;
...@@ -29,6 +30,7 @@ import org.slf4j.Logger; ...@@ -29,6 +30,7 @@ import org.slf4j.Logger;
29 30
30 import java.util.List; 31 import java.util.List;
31 32
33 +import static org.onlab.onos.net.device.DeviceEvent.Type.*;
32 import static com.google.common.base.Preconditions.checkNotNull; 34 import static com.google.common.base.Preconditions.checkNotNull;
33 import static org.slf4j.LoggerFactory.getLogger; 35 import static org.slf4j.LoggerFactory.getLogger;
34 36
...@@ -58,6 +60,9 @@ public class DeviceManager ...@@ -58,6 +60,9 @@ public class DeviceManager
58 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) 60 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
59 protected EventDeliveryService eventDispatcher; 61 protected EventDeliveryService eventDispatcher;
60 62
63 + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
64 + protected MastershipService mastershipService;
65 +
61 @Activate 66 @Activate
62 public void activate() { 67 public void activate() {
63 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry); 68 eventDispatcher.addSink(DeviceEvent.class, listenerRegistry);
...@@ -171,6 +176,10 @@ public class DeviceManager ...@@ -171,6 +176,10 @@ public class DeviceManager
171 // If there was a change of any kind, trigger role selection process. 176 // If there was a change of any kind, trigger role selection process.
172 if (event != null) { 177 if (event != null) {
173 log.info("Device {} connected", deviceId); 178 log.info("Device {} connected", deviceId);
179 + if (event.type().equals(DEVICE_ADDED)) {
180 + MastershipRole role = mastershipService.requestRoleFor(deviceId);
181 + store.setRole(deviceId, role);
182 + }
174 Device device = event.subject(); 183 Device device = event.subject();
175 provider().roleChanged(device, store.getRole(device.id())); 184 provider().roleChanged(device, store.getRole(device.id()));
176 post(event); 185 post(event);
......
1 package org.onlab.onos.net.host.impl; 1 package org.onlab.onos.net.host.impl;
2 2
3 +import java.nio.ByteBuffer;
4 +import java.util.ArrayList;
5 +import java.util.Collections;
3 import java.util.HashSet; 6 import java.util.HashSet;
7 +import java.util.List;
4 import java.util.Set; 8 import java.util.Set;
5 import java.util.concurrent.TimeUnit; 9 import java.util.concurrent.TimeUnit;
6 10
7 import org.jboss.netty.util.Timeout; 11 import org.jboss.netty.util.Timeout;
8 import org.jboss.netty.util.TimerTask; 12 import org.jboss.netty.util.TimerTask;
13 +import org.onlab.onos.net.ConnectPoint;
14 +import org.onlab.onos.net.Device;
15 +import org.onlab.onos.net.DeviceId;
9 import org.onlab.onos.net.Host; 16 import org.onlab.onos.net.Host;
10 import org.onlab.onos.net.Port; 17 import org.onlab.onos.net.Port;
11 import org.onlab.onos.net.device.DeviceService; 18 import org.onlab.onos.net.device.DeviceService;
19 +import org.onlab.onos.net.flow.DefaultTrafficTreatment;
20 +import org.onlab.onos.net.flow.TrafficTreatment;
21 +import org.onlab.onos.net.flow.instructions.Instruction;
22 +import org.onlab.onos.net.flow.instructions.Instructions;
12 import org.onlab.onos.net.host.HostProvider; 23 import org.onlab.onos.net.host.HostProvider;
13 import org.onlab.onos.net.host.HostService; 24 import org.onlab.onos.net.host.HostService;
14 -import org.onlab.onos.net.packet.PacketProvider; 25 +import org.onlab.onos.net.host.HostStore;
26 +import org.onlab.onos.net.host.PortAddresses;
27 +import org.onlab.onos.net.packet.DefaultOutboundPacket;
28 +import org.onlab.onos.net.packet.OutboundPacket;
29 +import org.onlab.onos.net.packet.PacketService;
15 import org.onlab.onos.net.topology.TopologyService; 30 import org.onlab.onos.net.topology.TopologyService;
31 +import org.onlab.packet.ARP;
32 +import org.onlab.packet.Ethernet;
33 +import org.onlab.packet.IpAddress;
16 import org.onlab.packet.IpPrefix; 34 import org.onlab.packet.IpPrefix;
35 +import org.onlab.packet.MacAddress;
17 import org.onlab.util.Timer; 36 import org.onlab.util.Timer;
18 37
38 +/**
39 + * Monitors hosts on the dataplane to detect changes in host data.
40 + * <p/>
41 + * The HostMonitor can monitor hosts that have already been detected for
42 + * changes. At an application's request, it can also monitor and actively
43 + * probe for hosts that have not yet been detected (specified by IP address).
44 + */
19 public class HostMonitor implements TimerTask { 45 public class HostMonitor implements TimerTask {
20 46
47 + private static final byte[] DEFAULT_MAC_ADDRESS =
48 + MacAddress.valueOf("00:00:00:00:00:01").getAddress();
49 +
50 + private static final byte[] ZERO_MAC_ADDRESS =
51 + MacAddress.valueOf("00:00:00:00:00:00").getAddress();
52 +
53 + // TODO put on Ethernet
54 + private static final byte[] BROADCAST_MAC =
55 + MacAddress.valueOf("ff:ff:ff:ff:ff:ff").getAddress();
56 +
21 private final HostService hostService; 57 private final HostService hostService;
22 private final TopologyService topologyService; 58 private final TopologyService topologyService;
23 private final DeviceService deviceService; 59 private final DeviceService deviceService;
24 private final HostProvider hostProvider; 60 private final HostProvider hostProvider;
25 - private final PacketProvider packetProvider; 61 + private final PacketService packetService;
62 + private final HostStore hostStore;
26 63
27 - private final Set<IpPrefix> monitoredAddresses; 64 + private final Set<IpAddress> monitoredAddresses;
28 65
29 private final long probeRate; 66 private final long probeRate;
30 67
...@@ -32,12 +69,14 @@ public class HostMonitor implements TimerTask { ...@@ -32,12 +69,14 @@ public class HostMonitor implements TimerTask {
32 69
33 public HostMonitor(HostService hostService, TopologyService topologyService, 70 public HostMonitor(HostService hostService, TopologyService topologyService,
34 DeviceService deviceService, 71 DeviceService deviceService,
35 - HostProvider hostProvider, PacketProvider packetProvider) { 72 + HostProvider hostProvider, PacketService packetService,
73 + HostStore hostStore) {
36 this.hostService = hostService; 74 this.hostService = hostService;
37 this.topologyService = topologyService; 75 this.topologyService = topologyService;
38 this.deviceService = deviceService; 76 this.deviceService = deviceService;
39 this.hostProvider = hostProvider; 77 this.hostProvider = hostProvider;
40 - this.packetProvider = packetProvider; 78 + this.packetService = packetService;
79 + this.hostStore = hostStore;
41 80
42 monitoredAddresses = new HashSet<>(); 81 monitoredAddresses = new HashSet<>();
43 82
...@@ -46,11 +85,11 @@ public class HostMonitor implements TimerTask { ...@@ -46,11 +85,11 @@ public class HostMonitor implements TimerTask {
46 timeout = Timer.getTimer().newTimeout(this, 0, TimeUnit.MILLISECONDS); 85 timeout = Timer.getTimer().newTimeout(this, 0, TimeUnit.MILLISECONDS);
47 } 86 }
48 87
49 - public void addMonitoringFor(IpPrefix ip) { 88 + public void addMonitoringFor(IpAddress ip) {
50 monitoredAddresses.add(ip); 89 monitoredAddresses.add(ip);
51 } 90 }
52 91
53 - public void stopMonitoring(IpPrefix ip) { 92 + public void stopMonitoring(IpAddress ip) {
54 monitoredAddresses.remove(ip); 93 monitoredAddresses.remove(ip);
55 } 94 }
56 95
...@@ -60,8 +99,8 @@ public class HostMonitor implements TimerTask { ...@@ -60,8 +99,8 @@ public class HostMonitor implements TimerTask {
60 99
61 @Override 100 @Override
62 public void run(Timeout timeout) throws Exception { 101 public void run(Timeout timeout) throws Exception {
63 - for (IpPrefix ip : monitoredAddresses) { 102 + for (IpAddress ip : monitoredAddresses) {
64 - Set<Host> hosts = hostService.getHostsByIp(ip); 103 + Set<Host> hosts = Collections.emptySet(); //TODO hostService.getHostsByIp(ip);
65 104
66 if (hosts.isEmpty()) { 105 if (hosts.isEmpty()) {
67 sendArpRequest(ip); 106 sendArpRequest(ip);
...@@ -80,28 +119,70 @@ public class HostMonitor implements TimerTask { ...@@ -80,28 +119,70 @@ public class HostMonitor implements TimerTask {
80 * 119 *
81 * @param targetIp IP address to ARP for 120 * @param targetIp IP address to ARP for
82 */ 121 */
83 - private void sendArpRequest(IpPrefix targetIp) { 122 + private void sendArpRequest(IpAddress targetIp) {
84 - // emit ARP packet out appropriate ports
85 123
86 - // if ip in one of the configured (external) subnets 124 + // Find ports with an IP address in the target's subnet and sent ARP
87 - // sent out that port 125 + // probes out those ports.
88 - // else (ip isn't in any configured subnet) 126 + for (Device device : deviceService.getDevices()) {
89 - // send out all non-external edge ports
90 -
91 - /*for (Device device : deviceService.getDevices()) {
92 for (Port port : deviceService.getPorts(device.id())) { 127 for (Port port : deviceService.getPorts(device.id())) {
93 - for (IpPrefix ip : port.ipAddresses()) { 128 + ConnectPoint cp = new ConnectPoint(device.id(), port.number());
94 - if (ip.contains(targetIp)) { 129 + PortAddresses addresses = hostStore.getAddressBindingsForPort(cp);
95 - sendProbe(port, targetIp); 130 +
96 - continue; 131 + if (addresses.ip().contains(targetIp)) {
97 - } 132 + sendProbe(device.id(), port, addresses, targetIp);
98 } 133 }
99 } 134 }
100 - }*/ 135 + }
101 136
137 + // TODO case where no address was found.
138 + // Broadcast out internal edge ports?
102 } 139 }
103 140
104 - private void sendProbe(Port port, IpPrefix targetIp) { 141 + private void sendProbe(DeviceId deviceId, Port port, PortAddresses portAddresses,
142 + IpAddress targetIp) {
143 + Ethernet arpPacket = createArpFor(targetIp, portAddresses);
144 +
145 + List<Instruction> instructions = new ArrayList<>();
146 + instructions.add(Instructions.createOutput(port.number()));
147 +
148 + TrafficTreatment treatment =
149 + new DefaultTrafficTreatment.Builder()
150 + .add(Instructions.createOutput(port.number()))
151 + .build();
152 +
153 + OutboundPacket outboundPacket =
154 + new DefaultOutboundPacket(deviceId, treatment,
155 + ByteBuffer.wrap(arpPacket.serialize()));
156 +
157 + packetService.emit(outboundPacket);
158 + }
159 +
160 + private Ethernet createArpFor(IpAddress targetIp, PortAddresses portAddresses) {
161 +
162 + ARP arp = new ARP();
163 + arp.setHardwareType(ARP.HW_TYPE_ETHERNET)
164 + .setHardwareAddressLength((byte) Ethernet.DATALAYER_ADDRESS_LENGTH)
165 + .setProtocolType(ARP.PROTO_TYPE_IP)
166 + .setProtocolAddressLength((byte) IpPrefix.INET_LEN);
167 +
168 + byte[] sourceMacAddress;
169 + if (portAddresses.mac() == null) {
170 + sourceMacAddress = DEFAULT_MAC_ADDRESS;
171 + } else {
172 + sourceMacAddress = portAddresses.mac().getAddress();
173 + }
174 +
175 + arp.setSenderHardwareAddress(sourceMacAddress)
176 + .setSenderProtocolAddress(portAddresses.ip().toOctets())
177 + .setTargetHardwareAddress(ZERO_MAC_ADDRESS)
178 + .setTargetProtocolAddress(targetIp.toOctets());
179 +
180 + Ethernet ethernet = new Ethernet();
181 + ethernet.setEtherType(Ethernet.TYPE_ARP)
182 + .setDestinationMACAddress(BROADCAST_MAC)
183 + .setSourceMACAddress(sourceMacAddress)
184 + .setPayload(arp);
105 185
186 + return ethernet;
106 } 187 }
107 } 188 }
......
...@@ -3,6 +3,9 @@ package org.onlab.onos.net.device.impl; ...@@ -3,6 +3,9 @@ package org.onlab.onos.net.device.impl;
3 import org.junit.After; 3 import org.junit.After;
4 import org.junit.Before; 4 import org.junit.Before;
5 import org.junit.Test; 5 import org.junit.Test;
6 +import org.onlab.onos.cluster.MastershipListener;
7 +import org.onlab.onos.cluster.MastershipService;
8 +import org.onlab.onos.cluster.NodeId;
6 import org.onlab.onos.event.Event; 9 import org.onlab.onos.event.Event;
7 import org.onlab.onos.net.Device; 10 import org.onlab.onos.net.Device;
8 import org.onlab.onos.net.DeviceId; 11 import org.onlab.onos.net.DeviceId;
...@@ -25,9 +28,12 @@ import org.onlab.onos.net.provider.ProviderId; ...@@ -25,9 +28,12 @@ import org.onlab.onos.net.provider.ProviderId;
25 import org.onlab.onos.event.impl.TestEventDispatcher; 28 import org.onlab.onos.event.impl.TestEventDispatcher;
26 import org.onlab.onos.net.trivial.impl.SimpleDeviceStore; 29 import org.onlab.onos.net.trivial.impl.SimpleDeviceStore;
27 30
31 +import com.google.common.collect.Sets;
32 +
28 import java.util.ArrayList; 33 import java.util.ArrayList;
29 import java.util.Iterator; 34 import java.util.Iterator;
30 import java.util.List; 35 import java.util.List;
36 +import java.util.Set;
31 37
32 import static org.junit.Assert.*; 38 import static org.junit.Assert.*;
33 import static org.onlab.onos.net.Device.Type.SWITCH; 39 import static org.onlab.onos.net.Device.Type.SWITCH;
...@@ -69,6 +75,7 @@ public class DeviceManagerTest { ...@@ -69,6 +75,7 @@ public class DeviceManagerTest {
69 registry = mgr; 75 registry = mgr;
70 mgr.store = new SimpleDeviceStore(); 76 mgr.store = new SimpleDeviceStore();
71 mgr.eventDispatcher = new TestEventDispatcher(); 77 mgr.eventDispatcher = new TestEventDispatcher();
78 + mgr.mastershipService = new TestMastershipService();
72 mgr.activate(); 79 mgr.activate();
73 80
74 service.addListener(listener); 81 service.addListener(listener);
...@@ -252,4 +259,31 @@ public class DeviceManagerTest { ...@@ -252,4 +259,31 @@ public class DeviceManagerTest {
252 } 259 }
253 } 260 }
254 261
262 + private static class TestMastershipService implements MastershipService {
263 +
264 + @Override
265 + public NodeId getMasterFor(DeviceId deviceId) {
266 + return null;
267 + }
268 +
269 + @Override
270 + public Set<DeviceId> getDevicesOf(NodeId nodeId) {
271 + return Sets.newHashSet(DID1, DID2);
272 + }
273 +
274 + @Override
275 + public MastershipRole requestRoleFor(DeviceId deviceId) {
276 + return MastershipRole.MASTER;
277 + }
278 +
279 + @Override
280 + public void addListener(MastershipListener listener) {
281 + }
282 +
283 + @Override
284 + public void removeListener(MastershipListener listener) {
285 + }
286 +
287 + }
288 +
255 } 289 }
......
1 package org.onlab.onos.net.device.impl; 1 package org.onlab.onos.net.device.impl;
2 2
3 import com.google.common.collect.Iterables; 3 import com.google.common.collect.Iterables;
4 +import com.google.common.collect.Sets;
4 import com.hazelcast.config.Config; 5 import com.hazelcast.config.Config;
5 import com.hazelcast.core.Hazelcast; 6 import com.hazelcast.core.Hazelcast;
6 import com.hazelcast.core.HazelcastInstance; 7 import com.hazelcast.core.HazelcastInstance;
8 +
7 import org.junit.After; 9 import org.junit.After;
8 import org.junit.Before; 10 import org.junit.Before;
9 import org.junit.Test; 11 import org.junit.Test;
12 +import org.onlab.onos.cluster.MastershipListener;
13 +import org.onlab.onos.cluster.MastershipService;
14 +import org.onlab.onos.cluster.NodeId;
10 import org.onlab.onos.event.Event; 15 import org.onlab.onos.event.Event;
11 import org.onlab.onos.event.impl.TestEventDispatcher; 16 import org.onlab.onos.event.impl.TestEventDispatcher;
12 import org.onlab.onos.net.Device; 17 import org.onlab.onos.net.Device;
...@@ -34,6 +39,7 @@ import org.onlab.onos.store.impl.StoreManager; ...@@ -34,6 +39,7 @@ import org.onlab.onos.store.impl.StoreManager;
34 import java.util.ArrayList; 39 import java.util.ArrayList;
35 import java.util.Iterator; 40 import java.util.Iterator;
36 import java.util.List; 41 import java.util.List;
42 +import java.util.Set;
37 import java.util.UUID; 43 import java.util.UUID;
38 44
39 import static org.junit.Assert.*; 45 import static org.junit.Assert.*;
...@@ -98,6 +104,7 @@ public class DistributedDeviceManagerTest { ...@@ -98,6 +104,7 @@ public class DistributedDeviceManagerTest {
98 dstore.activate(); 104 dstore.activate();
99 mgr.store = dstore; 105 mgr.store = dstore;
100 mgr.eventDispatcher = new TestEventDispatcher(); 106 mgr.eventDispatcher = new TestEventDispatcher();
107 + mgr.mastershipService = new TestMastershipService();
101 mgr.activate(); 108 mgr.activate();
102 109
103 service.addListener(listener); 110 service.addListener(listener);
...@@ -302,4 +309,32 @@ public class DistributedDeviceManagerTest { ...@@ -302,4 +309,32 @@ public class DistributedDeviceManagerTest {
302 setupKryoPool(); 309 setupKryoPool();
303 } 310 }
304 } 311 }
312 +
313 + private static class TestMastershipService implements MastershipService {
314 +
315 + @Override
316 + public NodeId getMasterFor(DeviceId deviceId) {
317 + return null;
318 + }
319 +
320 + @Override
321 + public Set<DeviceId> getDevicesOf(NodeId nodeId) {
322 + return Sets.newHashSet(DID1, DID2);
323 + }
324 +
325 + @Override
326 + public MastershipRole requestRoleFor(DeviceId deviceId) {
327 + return MastershipRole.MASTER;
328 + }
329 +
330 + @Override
331 + public void addListener(MastershipListener listener) {
332 + }
333 +
334 + @Override
335 + public void removeListener(MastershipListener listener) {
336 + }
337 +
338 + }
339 +
305 } 340 }
......
1 package org.onlab.onos.store.impl; 1 package org.onlab.onos.store.impl;
2 2
3 +import com.hazelcast.config.Config;
4 +import com.hazelcast.config.FileSystemXmlConfig;
3 import com.hazelcast.core.Hazelcast; 5 import com.hazelcast.core.Hazelcast;
4 import com.hazelcast.core.HazelcastInstance; 6 import com.hazelcast.core.HazelcastInstance;
5 import de.javakaffee.kryoserializers.URISerializer; 7 import de.javakaffee.kryoserializers.URISerializer;
...@@ -25,6 +27,7 @@ import org.onlab.util.KryoPool; ...@@ -25,6 +27,7 @@ import org.onlab.util.KryoPool;
25 import org.slf4j.Logger; 27 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory; 28 import org.slf4j.LoggerFactory;
27 29
30 +import java.io.FileNotFoundException;
28 import java.net.URI; 31 import java.net.URI;
29 import java.util.ArrayList; 32 import java.util.ArrayList;
30 import java.util.HashMap; 33 import java.util.HashMap;
...@@ -36,6 +39,8 @@ import java.util.HashMap; ...@@ -36,6 +39,8 @@ import java.util.HashMap;
36 @Service 39 @Service
37 public class StoreManager implements StoreService { 40 public class StoreManager implements StoreService {
38 41
42 + private static final String HAZELCAST_XML_FILE = "etc/hazelcast.xml";
43 +
39 private final Logger log = LoggerFactory.getLogger(getClass()); 44 private final Logger log = LoggerFactory.getLogger(getClass());
40 45
41 protected HazelcastInstance instance; 46 protected HazelcastInstance instance;
...@@ -44,9 +49,14 @@ public class StoreManager implements StoreService { ...@@ -44,9 +49,14 @@ public class StoreManager implements StoreService {
44 49
45 @Activate 50 @Activate
46 public void activate() { 51 public void activate() {
47 - instance = Hazelcast.newHazelcastInstance(); 52 + try {
48 - setupKryoPool(); 53 + Config config = new FileSystemXmlConfig(HAZELCAST_XML_FILE);
49 - log.info("Started"); 54 + instance = Hazelcast.newHazelcastInstance(config);
55 + setupKryoPool();
56 + log.info("Started");
57 + } catch (FileNotFoundException e) {
58 + log.error("Unable to configure Hazelcast", e);
59 + }
50 } 60 }
51 61
52 /** 62 /**
......
...@@ -98,7 +98,7 @@ public class SimpleDeviceStore implements DeviceStore { ...@@ -98,7 +98,7 @@ public class SimpleDeviceStore implements DeviceStore {
98 availableDevices.add(deviceId); 98 availableDevices.add(deviceId);
99 99
100 // For now claim the device as a master automatically. 100 // For now claim the device as a master automatically.
101 - roles.put(deviceId, MastershipRole.MASTER); 101 + // roles.put(deviceId, MastershipRole.MASTER);
102 } 102 }
103 return new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, null); 103 return new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device, null);
104 } 104 }
......
1 +package org.onlab.onos.net.trivial.impl;
2 +
3 +import static org.slf4j.LoggerFactory.getLogger;
4 +
5 +import java.util.Collections;
6 +import java.util.Set;
7 +import java.util.concurrent.ConcurrentHashMap;
8 +import java.util.concurrent.ConcurrentMap;
9 +
10 +import org.apache.felix.scr.annotations.Activate;
11 +import org.apache.felix.scr.annotations.Component;
12 +import org.apache.felix.scr.annotations.Deactivate;
13 +import org.apache.felix.scr.annotations.Service;
14 +import org.onlab.onos.cluster.ControllerNode;
15 +import org.onlab.onos.cluster.DefaultControllerNode;
16 +import org.onlab.onos.cluster.MastershipEvent;
17 +import org.onlab.onos.cluster.MastershipStore;
18 +import org.onlab.onos.cluster.NodeId;
19 +import org.onlab.onos.net.DeviceId;
20 +import org.onlab.onos.net.MastershipRole;
21 +import org.onlab.packet.IpPrefix;
22 +import org.slf4j.Logger;
23 +
24 +import static org.onlab.onos.cluster.MastershipEvent.Type.*;
25 +
26 +/**
27 + * Manages inventory of controller mastership over devices using
28 + * trivial in-memory structures implementation.
29 + */
30 +@Component(immediate = true)
31 +@Service
32 +public class SimpleMastershipStore implements MastershipStore {
33 +
34 + public static final IpPrefix LOCALHOST = IpPrefix.valueOf("127.0.0.1");
35 +
36 + private final Logger log = getLogger(getClass());
37 +
38 + private ControllerNode instance;
39 +
40 + protected final ConcurrentMap<DeviceId, MastershipRole> roleMap =
41 + new ConcurrentHashMap<DeviceId, MastershipRole>();
42 +
43 + @Activate
44 + public void activate() {
45 + instance = new DefaultControllerNode(new NodeId("local"), LOCALHOST);
46 + log.info("Started");
47 + }
48 +
49 + @Deactivate
50 + public void deactivate() {
51 + log.info("Stopped");
52 + }
53 +
54 + @Override
55 + public MastershipEvent setRole(NodeId nodeId, DeviceId deviceId,
56 + MastershipRole role) {
57 + if (roleMap.get(deviceId) == null) {
58 + return null;
59 + }
60 + roleMap.put(deviceId, role);
61 + return new MastershipEvent(MASTER_CHANGED, deviceId, nodeId);
62 + }
63 +
64 + @Override
65 + public MastershipEvent addOrUpdateDevice(NodeId instance,
66 + DeviceId deviceId, MastershipRole role) {
67 + //TODO refine when we do listeners
68 + roleMap.put(deviceId, role);
69 + return null;
70 + }
71 +
72 + @Override
73 + public NodeId getMaster(DeviceId deviceId) {
74 + return instance.id();
75 + }
76 +
77 + @Override
78 + public Set<DeviceId> getDevices(NodeId nodeId) {
79 + return Collections.unmodifiableSet(roleMap.keySet());
80 + }
81 +
82 + @Override
83 + public MastershipRole getRole(NodeId nodeId, DeviceId deviceId) {
84 + MastershipRole role = roleMap.get(deviceId);
85 + if (role == null) {
86 + //say MASTER. If clustered, we'd figure out if anyone's got dibs here.
87 + role = MastershipRole.MASTER;
88 + roleMap.put(deviceId, role);
89 + }
90 + return role;
91 + }
92 +
93 +}
...@@ -93,8 +93,8 @@ ...@@ -93,8 +93,8 @@
93 93
94 <feature name="onos-app-tvue" version="1.0.0" 94 <feature name="onos-app-tvue" version="1.0.0"
95 description="ONOS sample topology viewer application"> 95 description="ONOS sample topology viewer application">
96 - <feature>onos-thirdparty-web</feature>
97 <feature>onos-api</feature> 96 <feature>onos-api</feature>
97 + <feature>onos-thirdparty-web</feature>
98 <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle> 98 <bundle>mvn:org.onlab.onos/onos-app-tvue/1.0.0-SNAPSHOT</bundle>
99 </feature> 99 </feature>
100 100
......
1 +#!/bin/bash
2 +#-------------------------------------------------------------------------------
3 +# Builds the ONOS from source.
4 +#-------------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +cd $ONOS_ROOT
10 +mvn clean install && mvn javadoc:aggregate
...\ No newline at end of file ...\ No newline at end of file
...@@ -51,7 +51,7 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature ...@@ -51,7 +51,7 @@ perl -pi.old -e "s|^(featuresRepositories=.*)|\1,mvn:org.onlab.onos/onos-feature
51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 51 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
52 52
53 # Patch the Apache Karaf distribution file to load ONOS features 53 # Patch the Apache Karaf distribution file to load ONOS features
54 -perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue,onos-app-fwd|' \ 54 +perl -pi.old -e 's|^(featuresBoot=.*)|\1,onos-api,onos-core-trivial,onos-cli,onos-rest,onos-gui,onos-openflow,onos-app-tvue,onos-app-fwd|' \
55 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg 55 $ONOS_STAGE/$KARAF_DIST/etc/org.apache.karaf.features.cfg
56 56
57 # Patch the Apache Karaf distribution with ONOS branding bundle 57 # Patch the Apache Karaf distribution with ONOS branding bundle
......
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
9 nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2) 9 nodes=$(env | sort | egrep "OC[0-9]+" | cut -d= -f2)
10 10
11 onos-package 11 onos-package
12 -for node in $nodes; do onos-install -f $node; done 12 +for node in $nodes; do printf "%s: " $node; onos-install -f $node; done
13 for node in $nodes; do onos-wait-for-start $node; done 13 for node in $nodes; do onos-wait-for-start $node; done
......
...@@ -28,8 +28,9 @@ function o { ...@@ -28,8 +28,9 @@ function o {
28 # Short-hand for 'mvn clean install' for us lazy folk 28 # Short-hand for 'mvn clean install' for us lazy folk
29 alias mci='mvn clean install' 29 alias mci='mvn clean install'
30 30
31 -# Short-hand for ONOS build from the top of the source tree. 31 +# Short-hand for ONOS build, package and test.
32 -alias ob='o && mvn clean install javadoc:aggregate' 32 +alias ob='onos-build'
33 +alias op='onos-package'
33 alias ot='onos-test' 34 alias ot='onos-test'
34 35
35 # Short-hand for tailing the ONOS (karaf) log 36 # Short-hand for tailing the ONOS (karaf) log
...@@ -41,7 +42,7 @@ alias pp='python -m json.tool' ...@@ -41,7 +42,7 @@ alias pp='python -m json.tool'
41 42
42 # Short-hand to launch API docs and sample topology viewer GUI 43 # Short-hand to launch API docs and sample topology viewer GUI
43 alias docs='open $ONOS_ROOT/target/site/apidocs/index.html' 44 alias docs='open $ONOS_ROOT/target/site/apidocs/index.html'
44 -alias gui='open http://localhost:8181/onos/tvue' 45 +alias gui='onos-gui'
45 46
46 47
47 # Test related conveniences 48 # Test related conveniences
......
...@@ -16,6 +16,6 @@ env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 ...@@ -16,6 +16,6 @@ env JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
16 script 16 script
17 [ -f /opt/onos/options ] && . /opt/onos/options 17 [ -f /opt/onos/options ] && . /opt/onos/options
18 start-stop-daemon --signal INT --start --chuid sdn \ 18 start-stop-daemon --signal INT --start --chuid sdn \
19 - --exec /opt/onos/bin/onos-ctl -- $ONOS_OPTS \ 19 + --exec /opt/onos/bin/onos-service -- $ONOS_OPTS \
20 >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log 20 >/opt/onos/var/stdout.log 2>/opt/onos/var/stderr.log
21 end script 21 end script
......
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 -<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.2.xsd" 2 +<!--
3 + ~ Copyright (c) 2008-2013, Hazelcast, Inc. All Rights Reserved.
4 + ~
5 + ~ Licensed under the Apache License, Version 2.0 (the "License");
6 + ~ you may not use this file except in compliance with the License.
7 + ~ You may obtain a copy of the License at
8 + ~
9 + ~ http://www.apache.org/licenses/LICENSE-2.0
10 + ~
11 + ~ Unless required by applicable law or agreed to in writing, software
12 + ~ distributed under the License is distributed on an "AS IS" BASIS,
13 + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 + ~ See the License for the specific language governing permissions and
15 + ~ limitations under the License.
16 + -->
17 +
18 +<!--
19 + The default Hazelcast configuration. This is used when:
20 +
21 + - no hazelcast.xml if present
22 +
23 +-->
24 +<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.3.xsd"
3 xmlns="http://www.hazelcast.com/schema/config" 25 xmlns="http://www.hazelcast.com/schema/config"
4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 26 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
5 <group> 27 <group>
...@@ -11,8 +33,8 @@ ...@@ -11,8 +33,8 @@
11 <port auto-increment="true" port-count="100">5701</port> 33 <port auto-increment="true" port-count="100">5701</port>
12 <outbound-ports> 34 <outbound-ports>
13 <!-- 35 <!--
14 - Allowed port range when connecting to other nodes. 36 + Allowed port range when connecting to other nodes.
15 - 0 or * means use system provided port. 37 + 0 or * means use system provided port.
16 --> 38 -->
17 <ports>0</ports> 39 <ports>0</ports>
18 </outbound-ports> 40 </outbound-ports>
...@@ -24,18 +46,6 @@ ...@@ -24,18 +46,6 @@
24 <tcp-ip enabled="false"> 46 <tcp-ip enabled="false">
25 <interface>127.0.0.1</interface> 47 <interface>127.0.0.1</interface>
26 </tcp-ip> 48 </tcp-ip>
27 - <aws enabled="false">
28 - <access-key>my-access-key</access-key>
29 - <secret-key>my-secret-key</secret-key>
30 - <!--optional, default is us-east-1 -->
31 - <region>us-west-1</region>
32 - <!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
33 - <host-header>ec2.amazonaws.com</host-header>
34 - <!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
35 - <security-group-name>hazelcast-sg</security-group-name>
36 - <tag-key>type</tag-key>
37 - <tag-value>hz-nodes</tag-value>
38 - </aws>
39 </join> 49 </join>
40 <interfaces enabled="true"> 50 <interfaces enabled="true">
41 <interface>192.168.56.*</interface> 51 <interface>192.168.56.*</interface>
...@@ -61,9 +71,9 @@ ...@@ -61,9 +71,9 @@
61 </symmetric-encryption> 71 </symmetric-encryption>
62 </network> 72 </network>
63 <partition-group enabled="false"/> 73 <partition-group enabled="false"/>
64 - <executor-service> 74 + <executor-service name="default">
65 <pool-size>16</pool-size> 75 <pool-size>16</pool-size>
66 - <!-- Queue capacity. 0 means Integer.MAX_VALUE --> 76 + <!--Queue capacity. 0 means Integer.MAX_VALUE.-->
67 <queue-capacity>0</queue-capacity> 77 <queue-capacity>0</queue-capacity>
68 </executor-service> 78 </executor-service>
69 <queue name="default"> 79 <queue name="default">
...@@ -81,22 +91,24 @@ ...@@ -81,22 +91,24 @@
81 fail-safety. 0 means no backup. 91 fail-safety. 0 means no backup.
82 --> 92 -->
83 <backup-count>1</backup-count> 93 <backup-count>1</backup-count>
94 +
84 <!-- 95 <!--
85 Number of async backups. 0 means no backup. 96 Number of async backups. 0 means no backup.
86 --> 97 -->
87 <async-backup-count>0</async-backup-count> 98 <async-backup-count>0</async-backup-count>
99 +
88 <empty-queue-ttl>-1</empty-queue-ttl> 100 <empty-queue-ttl>-1</empty-queue-ttl>
89 </queue> 101 </queue>
90 -
91 <map name="default"> 102 <map name="default">
92 <!-- 103 <!--
93 - Data type that will be used for storing recordMap. 104 + Data type that will be used for storing recordMap.
94 - Possible values: 105 + Possible values:
95 - BINARY (default): keys and values will be stored as binary data 106 + BINARY (default): keys and values will be stored as binary data
96 - OBJECT : values will be stored in their object forms 107 + OBJECT : values will be stored in their object forms
97 - OFFHEAP : values will be stored in non-heap region of JVM 108 + OFFHEAP : values will be stored in non-heap region of JVM
98 --> 109 -->
99 <in-memory-format>BINARY</in-memory-format> 110 <in-memory-format>BINARY</in-memory-format>
111 +
100 <!-- 112 <!--
101 Number of backups. If 1 is set as the backup-count for example, 113 Number of backups. If 1 is set as the backup-count for example,
102 then all entries of the map will be copied to another JVM for 114 then all entries of the map will be copied to another JVM for
...@@ -144,6 +156,12 @@ ...@@ -144,6 +156,12 @@
144 --> 156 -->
145 <eviction-percentage>25</eviction-percentage> 157 <eviction-percentage>25</eviction-percentage>
146 <!-- 158 <!--
159 + Minimum time in milliseconds which should pass before checking
160 + if a partition of this map is evictable or not.
161 + Default value is 100 millis.
162 + -->
163 + <min-eviction-check-millis>100</min-eviction-check-millis>
164 + <!--
147 While recovering from split-brain (network partitioning), 165 While recovering from split-brain (network partitioning),
148 map entries in the small cluster will merge into the bigger cluster 166 map entries in the small cluster will merge into the bigger cluster
149 based on the policy set here. When an entry merge into the 167 based on the policy set here. When an entry merge into the
...@@ -159,6 +177,7 @@ ...@@ -159,6 +177,7 @@
159 com.hazelcast.map.merge.LatestUpdateMapMergePolicy ; entry with the latest update wins. 177 com.hazelcast.map.merge.LatestUpdateMapMergePolicy ; entry with the latest update wins.
160 --> 178 -->
161 <merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy> 179 <merge-policy>com.hazelcast.map.merge.PassThroughMergePolicy</merge-policy>
180 +
162 </map> 181 </map>
163 182
164 <multimap name="default"> 183 <multimap name="default">
...@@ -199,5 +218,6 @@ ...@@ -199,5 +218,6 @@
199 <portable-version>0</portable-version> 218 <portable-version>0</portable-version>
200 </serialization> 219 </serialization>
201 220
202 - <services enable-defaults="true" /> 221 + <services enable-defaults="true"/>
222 +
203 </hazelcast> 223 </hazelcast>
......
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# ONOS remote command-line client 3 +# ONOS remote command-line client.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
6 [ -n "$1" ] && OCI=$1 && shift 6 [ -n "$1" ] && OCI=$1 && shift
......
1 +#!/bin/bash
2 +#-------------------------------------------------------------------------------
3 +# Checks the logs of the remote ONOS instance and makes sure they are clean.
4 +#-------------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +remote=$ONOS_USER@${1:-$OCI}
10 +
11 +LOG=$ONOS_INSTALL_DIR/log/karaf.log
12 +
13 +ssh $remote "egrep 'ERROR|Exception' $LOG"
1 +#!/bin/bash
2 +#-------------------------------------------------------------------------------
3 +# Launches ONOS GUI on the specified node.
4 +#-------------------------------------------------------------------------------
5 +
6 +host=${1:-$OCI}
7 +host=${host:-localhost}
8 +
9 +open http://$host:8181/onos/tvue
...\ No newline at end of file ...\ No newline at end of file
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Remotely pushes bits to a remote machine and installs ONOS. 3 +# Remotely pushes bits to a remote node and installs ONOS on it.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Monitors remote ONOS log file. 3 +# Monitors remote ONOS log file on the specified node.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Pushes the local id_rsa.pub to the remote ONOS host authorized_keys. 3 +# Pushes the local id_rsa.pub to the authorized_keys on a remote ONOS node.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......
1 +#!/bin/bash
2 +#-------------------------------------------------------------------------------
3 +# Remotely administers the ONOS service on the specified node.
4 +#-------------------------------------------------------------------------------
5 +
6 +[ ! -d "$ONOS_ROOT" ] && echo "ONOS_ROOT is not defined" >&2 && exit 1
7 +. $ONOS_ROOT/tools/build/envDefaults
8 +
9 +ssh $ONOS_USER@${1:-$OCI} "sudo service onos ${2:-status}"
...\ No newline at end of file ...\ No newline at end of file
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Logs in to the remote ONOS instance. 3 +# Logs in to the remote ONOS node.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Remotely stops & uninstalls ONOS. 3 +# Remotely stops & uninstalls ONOS on the specified node.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......
1 #!/bin/bash 1 #!/bin/bash
2 #------------------------------------------------------------------------------- 2 #-------------------------------------------------------------------------------
3 -# Waits for ONOS to reach run-level 100. 3 +# Waits for ONOS to reach run-level 100 on the specified remote node.
4 #------------------------------------------------------------------------------- 4 #-------------------------------------------------------------------------------
5 5
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
......