Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Thomas Vachuska
2014-10-21 16:37:40 -0700
Browse Files
Options
Browse Files
Download
Plain Diff
Committed by
Gerrit Code Review
2014-10-21 16:37:40 -0700
Commit
61d59dac06104fb82218d53751cd93e063087931
61d59dac
2 parents
e9fc596f
9fdf1eaa
Merge "Add L2 selector options to connectivity intents"
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
16 deletions
cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java
cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java
cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
cli/src/main/java/org/onlab/onos/cli/net/EthType.java
cli/src/main/java/org/onlab/onos/cli/net/EthTypeCompleter.java
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
cli/src/main/java/org/onlab/onos/cli/net/AddMultiPointToSinglePointIntentCommand.java
View file @
61d59da
...
...
@@ -2,18 +2,15 @@ package org.onlab.onos.cli.net;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.DefaultTrafficSelector
;
import
org.onlab.onos.net.flow.DefaultTrafficTreatment
;
import
org.onlab.onos.net.flow.TrafficSelector
;
import
org.onlab.onos.net.flow.TrafficTreatment
;
import
org.onlab.onos.net.intent.Intent
;
import
org.onlab.onos.net.intent.IntentService
;
import
org.onlab.onos.net.intent.MultiPointToSinglePointIntent
;
import
org.onlab.packet.Ethernet
;
import
java.util.HashSet
;
import
java.util.Set
;
...
...
@@ -26,7 +23,7 @@ import static org.onlab.onos.net.PortNumber.portNumber;
*/
@Command
(
scope
=
"onos"
,
name
=
"add-multi-to-single-intent"
,
description
=
"Installs point-to-point connectivity intent"
)
public
class
AddMultiPointToSinglePointIntentCommand
extends
AbstractShell
Command
{
public
class
AddMultiPointToSinglePointIntentCommand
extends
ConnectivityIntent
Command
{
@Argument
(
index
=
0
,
name
=
"ingressDevices"
,
description
=
"Ingress Device/Port Description"
,
...
...
@@ -55,9 +52,7 @@ public class AddMultiPointToSinglePointIntentCommand extends AbstractShellComman
ingressPoints
.
add
(
ingress
);
}
TrafficSelector
selector
=
DefaultTrafficSelector
.
builder
()
.
matchEthType
(
Ethernet
.
TYPE_IPV4
)
.
build
();
TrafficSelector
selector
=
buildTrafficSelector
();
TrafficTreatment
treatment
=
DefaultTrafficTreatment
.
builder
().
build
();
Intent
intent
=
new
MultiPointToSinglePointIntent
(
appId
(),
selector
,
treatment
,
...
...
cli/src/main/java/org/onlab/onos/cli/net/AddPointToPointIntentCommand.java
View file @
61d59da
...
...
@@ -2,18 +2,16 @@ package org.onlab.onos.cli.net;
import
org.apache.karaf.shell.commands.Argument
;
import
org.apache.karaf.shell.commands.Command
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.ConnectPoint
;
import
org.onlab.onos.net.DeviceId
;
import
org.onlab.onos.net.PortNumber
;
import
org.onlab.onos.net.flow.DefaultTrafficSelector
;
import
org.onlab.onos.net.flow.DefaultTrafficTreatment
;
import
org.onlab.onos.net.flow.TrafficSelector
;
import
org.onlab.onos.net.flow.TrafficTreatment
;
import
org.onlab.onos.net.intent.Intent
;
import
org.onlab.onos.net.intent.IntentService
;
import
org.onlab.onos.net.intent.PointToPointIntent
;
import
org.onlab.packet.Ethernet
;
import
static
org
.
onlab
.
onos
.
net
.
flow
.
DefaultTrafficTreatment
.
builder
;
import
static
org
.
onlab
.
onos
.
net
.
DeviceId
.
deviceId
;
import
static
org
.
onlab
.
onos
.
net
.
PortNumber
.
portNumber
;
...
...
@@ -23,7 +21,7 @@ import static org.onlab.onos.net.PortNumber.portNumber;
*/
@Command
(
scope
=
"onos"
,
name
=
"add-point-intent"
,
description
=
"Installs point-to-point connectivity intent"
)
public
class
AddPointToPointIntentCommand
extends
AbstractShell
Command
{
public
class
AddPointToPointIntentCommand
extends
ConnectivityIntent
Command
{
@Argument
(
index
=
0
,
name
=
"ingressDevice"
,
description
=
"Ingress Device/Port Description"
,
...
...
@@ -47,10 +45,8 @@ public class AddPointToPointIntentCommand extends AbstractShellCommand {
PortNumber
egressPortNumber
=
portNumber
(
getPortNumber
(
egressDeviceString
));
ConnectPoint
egress
=
new
ConnectPoint
(
egressDeviceId
,
egressPortNumber
);
TrafficSelector
selector
=
DefaultTrafficSelector
.
builder
()
.
matchEthType
(
Ethernet
.
TYPE_IPV4
)
.
build
();
TrafficTreatment
treatment
=
DefaultTrafficTreatment
.
builder
().
build
();
TrafficSelector
selector
=
buildTrafficSelector
();
TrafficTreatment
treatment
=
builder
().
build
();
Intent
intent
=
new
PointToPointIntent
(
appId
(),
selector
,
treatment
,
ingress
,
egress
);
...
...
cli/src/main/java/org/onlab/onos/cli/net/ConnectivityIntentCommand.java
0 → 100644
View file @
61d59da
package
org
.
onlab
.
onos
.
cli
.
net
;
import
org.apache.karaf.shell.commands.Option
;
import
org.onlab.onos.cli.AbstractShellCommand
;
import
org.onlab.onos.net.flow.DefaultTrafficSelector
;
import
org.onlab.onos.net.flow.TrafficSelector
;
import
org.onlab.packet.Ethernet
;
import
org.onlab.packet.MacAddress
;
import
com.google.common.base.Strings
;
/**
* Base class for command line operations for connectivity based intents.
*/
public
abstract
class
ConnectivityIntentCommand
extends
AbstractShellCommand
{
@Option
(
name
=
"-s"
,
aliases
=
"--ethSrc"
,
description
=
"Source MAC Address"
,
required
=
false
,
multiValued
=
false
)
private
String
srcMacString
=
null
;
@Option
(
name
=
"-d"
,
aliases
=
"--ethDst"
,
description
=
"Destination MAC Address"
,
required
=
false
,
multiValued
=
false
)
private
String
dstMacString
=
null
;
@Option
(
name
=
"-t"
,
aliases
=
"--ethType"
,
description
=
"Ethernet Type"
,
required
=
false
,
multiValued
=
false
)
private
String
ethTypeString
=
""
;
/**
* Constructs a traffic selector based on the command line arguments
* presented to the command.
*/
protected
TrafficSelector
buildTrafficSelector
()
{
TrafficSelector
.
Builder
selectorBuilder
=
DefaultTrafficSelector
.
builder
();
Short
ethType
=
Ethernet
.
TYPE_IPV4
;
if
(!
Strings
.
isNullOrEmpty
(
ethTypeString
))
{
EthType
ethTypeParameter
=
EthType
.
valueOf
(
ethTypeString
);
ethType
=
ethTypeParameter
.
value
();
}
selectorBuilder
.
matchEthType
(
ethType
);
if
(!
Strings
.
isNullOrEmpty
(
srcMacString
))
{
selectorBuilder
.
matchEthSrc
(
MacAddress
.
valueOf
(
srcMacString
));
}
if
(!
Strings
.
isNullOrEmpty
(
dstMacString
))
{
selectorBuilder
.
matchEthDst
(
MacAddress
.
valueOf
(
dstMacString
));
}
return
selectorBuilder
.
build
();
}
}
cli/src/main/java/org/onlab/onos/cli/net/EthType.java
0 → 100644
View file @
61d59da
package
org
.
onlab
.
onos
.
cli
.
net
;
import
org.onlab.packet.Ethernet
;
/**
* Allowed values for Ethernet types. Used by the CLI completer for
* connectivity based intent L2 parameters.
*/
public
enum
EthType
{
/** ARP. */
ARP
(
Ethernet
.
TYPE_ARP
),
/** RARP. */
RARP
(
Ethernet
.
TYPE_RARP
),
/** IPV4. */
IPV4
(
Ethernet
.
TYPE_IPV4
),
/** LLDP. */
LLDP
(
Ethernet
.
TYPE_LLDP
),
/** BSN. */
BSN
(
Ethernet
.
TYPE_BSN
);
private
short
value
;
/**
* Constructs an EthType with the given value.
*
* @param value value to use when this EthType is seen.
*/
private
EthType
(
short
value
)
{
this
.
value
=
value
;
}
/**
* Gets the value to use for this EthType.
*
* @return short value to use for this EthType
*/
public
short
value
()
{
return
this
.
value
;
}
}
cli/src/main/java/org/onlab/onos/cli/net/EthTypeCompleter.java
0 → 100644
View file @
61d59da
package
org
.
onlab
.
onos
.
cli
.
net
;
import
java.util.List
;
import
java.util.SortedSet
;
import
org.apache.karaf.shell.console.Completer
;
import
org.apache.karaf.shell.console.completer.StringsCompleter
;
/**
* Ethernet type completer.
*/
public
class
EthTypeCompleter
implements
Completer
{
@Override
public
int
complete
(
String
buffer
,
int
cursor
,
List
<
String
>
candidates
)
{
// Delegate string completer
StringsCompleter
delegate
=
new
StringsCompleter
();
SortedSet
<
String
>
strings
=
delegate
.
getStrings
();
strings
.
add
(
EthType
.
ARP
.
toString
());
strings
.
add
(
EthType
.
BSN
.
toString
());
strings
.
add
(
EthType
.
IPV4
.
toString
());
strings
.
add
(
EthType
.
LLDP
.
toString
());
strings
.
add
(
EthType
.
RARP
.
toString
());
// Now let the completer do the work for figuring out what to offer.
return
delegate
.
complete
(
buffer
,
cursor
,
candidates
);
}
}
cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
View file @
61d59da
...
...
@@ -96,12 +96,18 @@
<ref
component-id=
"connectPointCompleter"
/>
<null/>
</completers>
<optional-completers>
<entry
key=
"-t"
value-ref=
"ethTypeCompleter"
/>
</optional-completers>
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.AddMultiPointToSinglePointIntentCommand"
/>
<completers>
<ref
component-id=
"connectPointCompleter"
/>
</completers>
<optional-completers>
<entry
key=
"-t"
value-ref=
"ethTypeCompleter"
/>
</optional-completers>
</command>
<command>
<action
class=
"org.onlab.onos.cli.net.IntentPushTestCommand"
/>
...
...
@@ -158,5 +164,6 @@
<bean
id=
"flowRuleStatusCompleter"
class=
"org.onlab.onos.cli.net.FlowRuleStatusCompleter"
/>
<bean
id=
"connectPointCompleter"
class=
"org.onlab.onos.cli.net.ConnectPointCompleter"
/>
<bean
id=
"nullCompleter"
class=
"org.apache.karaf.shell.console.completer.NullCompleter"
/>
<bean
id=
"ethTypeCompleter"
class=
"org.onlab.onos.cli.net.EthTypeCompleter"
/>
</blueprint>
...
...
Please
register
or
login
to post a comment