Skip to content

Commit ce67e24

Browse files
author
Sheng Yang
committed
CLOUDSTACK-5779: Move ipAlias to use routerProxy
1 parent 36920a3 commit ce67e24

9 files changed

Lines changed: 10 additions & 147 deletions

File tree

core/src/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ public class VirtualRoutingResource implements Manager {
106106
private String _loadbPath;
107107
private String _publicEthIf;
108108
private String _privateEthIf;
109-
private String _bumpUpPriorityPath;
110109
private String _routerProxyPath;
111-
private String _createIpAliasPath;
112-
private String _deleteIpAliasPath;
113110

114111
private int _timeout;
115112
private int _startTimeout;
@@ -587,23 +584,18 @@ protected Answer execute(final DhcpEntryCommand cmd) {
587584

588585
protected Answer execute(final CreateIpAliasCommand cmd) {
589586
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
590-
final Script command = new Script(_createIpAliasPath, _timeout, s_logger);
591587
List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
592588
String args = "";
593-
command.add(routerIp);
594589
for (IpAliasTO ipaliasto : ipAliasTOs) {
595590
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
596591
}
597-
command.add(args);
598-
final String result = command.execute();
592+
final String result = routerProxy("createipAlias.sh", routerIp, args);
599593
return new Answer(cmd, result == null, result);
600594
}
601595

602596
protected Answer execute(final DeleteIpAliasCommand cmd) {
603-
final Script command = new Script(_deleteIpAliasPath, _timeout, s_logger);
604597
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
605598
String args = "";
606-
command.add(routerIp);
607599
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
608600
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
609601
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
@@ -613,8 +605,7 @@ protected Answer execute(final DeleteIpAliasCommand cmd) {
613605
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
614606
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
615607
}
616-
command.add(args);
617-
final String result = command.execute();
608+
final String result = routerProxy("deleteipAlias.sh", routerIp, args);
618609
return new Answer(cmd, result == null, result);
619610
}
620611

@@ -1136,24 +1127,10 @@ public boolean configure(final String name, final Map<String, Object> params) th
11361127
}
11371128
_privateEthIf = _privateEthIf.toLowerCase();
11381129

1139-
_bumpUpPriorityPath = findScript("bumpUpPriority.sh");
1140-
if (_bumpUpPriorityPath == null) {
1141-
throw new ConfigurationException("Unable to find bumpUpPriority.sh");
1142-
}
1143-
11441130
_routerProxyPath = findScript("router_proxy.sh");
11451131
if (_routerProxyPath == null) {
11461132
throw new ConfigurationException("Unable to find router_proxy.sh");
11471133
}
1148-
_createIpAliasPath = findScript("createipAlias.sh");
1149-
if (_createIpAliasPath == null) {
1150-
throw new ConfigurationException("unable to find createipAlias.sh");
1151-
}
1152-
_deleteIpAliasPath = findScript("deleteipAlias.sh");
1153-
if (_deleteIpAliasPath == null) {
1154-
throw new ConfigurationException("unable to find deleteipAlias.sh");
1155-
}
1156-
11571134
return true;
11581135
}
11591136

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,14 +2181,14 @@ protected Answer execute(final CreateIpAliasCommand cmd) {
21812181
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
21822182
}
21832183
if (s_logger.isDebugEnabled()) {
2184-
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/createIpAlias " + args);
2184+
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/createIpAlias " + args);
21852185
}
21862186

21872187
try {
21882188
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
21892189
String controlIp = getRouterSshControlIp(cmd);
21902190
Pair<Boolean, String> result =
2191-
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/createIpAlias.sh " + args);
2191+
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/createIpAlias.sh " + args);
21922192

21932193
if (!result.first()) {
21942194
s_logger.error("CreateIpAlias command on domr " + controlIp + " failed, message: " + result.second());
@@ -2225,14 +2225,14 @@ protected Answer execute(final DeleteIpAliasCommand cmd) {
22252225
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
22262226
}
22272227
if (s_logger.isDebugEnabled()) {
2228-
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /root/deleteIpAlias " + args);
2228+
s_logger.debug("Run command on domR " + cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP) + ", /opt/cloud/bin/deleteIpAlias " + args);
22292229
}
22302230

22312231
try {
22322232
VmwareManager mgr = getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
22332233
String controlIp = getRouterSshControlIp(cmd);
22342234
Pair<Boolean, String> result =
2235-
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/root/deleteIpAlias.sh " + args);
2235+
SshHelper.sshExecute(controlIp, DefaultDomRSshPort, "root", mgr.getSystemVMKeyFile(), null, "/opt/cloud/bin/deleteIpAlias.sh " + args);
22362236

22372237
if (!result.first()) {
22382238
s_logger.error("deleteIpAlias command on domr " + controlIp + " failed, message: " + result.second());

plugins/hypervisors/xen/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2194,14 +2194,13 @@ protected Answer VPCLoadBalancerConfig(final LoadBalancerConfigCommand cmd) {
21942194
}
21952195

21962196
protected Answer execute(final CreateIpAliasCommand cmd) {
2197-
Connection conn = getConnection();
21982197
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
21992198
List<IpAliasTO> ipAliasTOs = cmd.getIpAliasList();
2200-
String args = routerIp + " ";
2199+
String args = "";
22012200
for (IpAliasTO ipaliasto : ipAliasTOs) {
22022201
args = args + ipaliasto.getAlias_count() + ":" + ipaliasto.getRouterip() + ":" + ipaliasto.getNetmask() + "-";
22032202
}
2204-
String result = callHostPlugin(conn, "vmops", "createipAlias", "args", args);
2203+
String result = routerProxy("createipAlias.sh", routerIp, args);
22052204
if (result == null || result.isEmpty()) {
22062205
return new Answer(cmd, false, "CreateIPAliasCommand failed\n");
22072206
}
@@ -2210,10 +2209,9 @@ protected Answer execute(final CreateIpAliasCommand cmd) {
22102209
}
22112210

22122211
protected Answer execute(final DeleteIpAliasCommand cmd) {
2213-
Connection conn = getConnection();
22142212
String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
22152213
List<IpAliasTO> revokedIpAliasTOs = cmd.getDeleteIpAliasTos();
2216-
String args = routerIp + " ";
2214+
String args = "";
22172215
for (IpAliasTO ipAliasTO : revokedIpAliasTOs) {
22182216
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
22192217
}
@@ -2223,7 +2221,7 @@ protected Answer execute(final DeleteIpAliasCommand cmd) {
22232221
for (IpAliasTO ipAliasTO : activeIpAliasTOs) {
22242222
args = args + ipAliasTO.getAlias_count() + ":" + ipAliasTO.getRouterip() + ":" + ipAliasTO.getNetmask() + "-";
22252223
}
2226-
String result = callHostPlugin(conn, "vmops", "deleteipAlias", "args", args);
2224+
String result = routerProxy("deleteipAlias", routerIp, args);
22272225
if (result == null || result.isEmpty()) {
22282226
return new Answer(cmd, false, "DeleteipAliasCommand failed\n");
22292227
}

scripts/network/domr/createipAlias.sh

Lines changed: 0 additions & 26 deletions
This file was deleted.

scripts/network/domr/deleteipAlias.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

scripts/network/domr/s2s_vpn.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

scripts/vm/hypervisor/xenserver/vmops

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ def routerProxy(session, args):
255255

256256
return txt
257257

258-
259-
260258
@echo
261259
def setLoadBalancerRule(session, args):
262260
sargs = args['args']
@@ -272,34 +270,6 @@ def setLoadBalancerRule(session, args):
272270

273271
return txt
274272

275-
@echo
276-
def createipAlias(session, args):
277-
args = args['args']
278-
cmd = args.split(' ')
279-
cmd.insert(0, "/opt/cloud/bin/createipAlias.sh")
280-
cmd.insert(0, "bin/bash")
281-
try:
282-
txt=util.pread2(cmd)
283-
txt='success'
284-
except:
285-
logging.debug("failed to create ip alias on router vm")
286-
txt=''
287-
return txt
288-
289-
@echo
290-
def deleteipAlias(session, args):
291-
args = args['args']
292-
cmd = args.split(' ')
293-
cmd.insert(0, "/opt/cloud/bin/deleteipAlias.sh")
294-
cmd.insert(0, "bin/bash")
295-
try:
296-
txt=util.pread2(cmd)
297-
txt='success'
298-
except:
299-
logging.debug("failed to create ip alias on router vm")
300-
txt=''
301-
return txt
302-
303273
@echo
304274
def createFile(session, args):
305275
file_path = args['filepath']
@@ -1593,8 +1563,6 @@ if __name__ == "__main__":
15931563
"destroy_network_rules_for_vm":destroy_network_rules_for_vm,
15941564
"default_network_rules_systemvm":default_network_rules_systemvm,
15951565
"network_rules_vmSecondaryIp":network_rules_vmSecondaryIp,
1596-
"createipAlias":createipAlias,
1597-
"deleteipAlias":deleteipAlias,
15981566
"get_rule_logs_for_vms":get_rule_logs_for_vms,
15991567
"add_to_VCPUs_params_live":add_to_VCPUs_params_live,
16001568
"setLinkLocalIP":setLinkLocalIP,

systemvm/patches/debian/config/root/createIpAlias.sh renamed to systemvm/patches/debian/config/opt/cloud/bin/createIpAlias.sh

File renamed without changes.

systemvm/patches/debian/config/root/deleteIpAlias.sh renamed to systemvm/patches/debian/config/opt/cloud/bin/deleteIpAlias.sh

File renamed without changes.

0 commit comments

Comments
 (0)