public final class RemoteIpCommandUtil extends Object
RemoteIpCommandUtil provides methods to help execute Linux IP commands to a remote server.
It opens individual exec channels for each command. User can create a session with connect
method and then execute a series commands. After done with all commands, the session must be closed
explicitly by calling disconnect.| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
log |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addIp(com.jcraft.jsch.Session session,
CidrAddr ip,
String device)
Adds a given IP address to a given device.
|
static com.jcraft.jsch.Session |
connect(SshAccessInfo sshInfo)
Creates a new session with a given access information.
|
static boolean |
deleteIp(com.jcraft.jsch.Session session,
org.onlab.packet.IpAddress ip,
String device)
Removes the IP address from a given device.
|
static void |
disconnect(com.jcraft.jsch.Session session)
Closes a connection.
|
static boolean |
flushIp(com.jcraft.jsch.Session session,
String device)
Removes all IP address on a given device.
|
static Set<org.onlab.packet.IpAddress> |
getCurrentIps(com.jcraft.jsch.Session session,
String device)
Returns a set of IP address that a given device has.
|
static boolean |
isInterfaceUp(com.jcraft.jsch.Session session,
String device)
Checks if a given interface is up or not.
|
static boolean |
setInterfaceUp(com.jcraft.jsch.Session session,
String device)
Sets link state up for a given device.
|
public static boolean addIp(com.jcraft.jsch.Session session,
CidrAddr ip,
String device)
session - ssh connectionip - network addressdevice - device name to assign the ip addresspublic static boolean deleteIp(com.jcraft.jsch.Session session,
org.onlab.packet.IpAddress ip,
String device)
session - ssh connectionip - ip addressdevice - device namepublic static boolean flushIp(com.jcraft.jsch.Session session,
String device)
session - ssh connectiondevice - device namepublic static Set<org.onlab.packet.IpAddress> getCurrentIps(com.jcraft.jsch.Session session, String device)
session - ssh connectiondevice - device namepublic static boolean setInterfaceUp(com.jcraft.jsch.Session session,
String device)
session - ssh connectiondevice - device namepublic static boolean isInterfaceUp(com.jcraft.jsch.Session session,
String device)
session - ssh connectiondevice - device namepublic static com.jcraft.jsch.Session connect(SshAccessInfo sshInfo)
sshInfo - information to ssh to the remove serverpublic static void disconnect(com.jcraft.jsch.Session session)
session - sessionCopyright © 2018. All rights reserved.