mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
post-rebasing
This commit is contained in:
parent
61e80f030a
commit
267ff79bfb
@ -1,79 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.network.ovs;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class OvsCreateGreTunnelAnswer extends Answer {
|
|
||||||
String hostIp;
|
|
||||||
String remoteIp;
|
|
||||||
String bridge;
|
|
||||||
String key;
|
|
||||||
long from;
|
|
||||||
long to;
|
|
||||||
int port;
|
|
||||||
|
|
||||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details) {
|
|
||||||
super(cmd, success, details);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details, String hostIp, String bridge) {
|
|
||||||
super(cmd, success, details);
|
|
||||||
OvsCreateGreTunnelCommand c = (OvsCreateGreTunnelCommand)cmd;
|
|
||||||
this.hostIp = hostIp;
|
|
||||||
this.bridge = bridge;
|
|
||||||
this.remoteIp = c.getRemoteIp();
|
|
||||||
this.key = c.getKey();
|
|
||||||
this.port = -1;
|
|
||||||
this.from = c.getFrom();
|
|
||||||
this.to = c.getTo();
|
|
||||||
}
|
|
||||||
|
|
||||||
public OvsCreateGreTunnelAnswer(Command cmd, boolean success, String details, String hostIp, String bridge, int port) {
|
|
||||||
this(cmd, success, details, hostIp, bridge);
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostIp() {
|
|
||||||
return hostIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRemoteIp() {
|
|
||||||
return remoteIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBridge() {
|
|
||||||
return bridge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getFrom() {
|
|
||||||
return from;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getTo() {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,83 +0,0 @@
|
|||||||
// Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
// or more contributor license agreements. See the NOTICE file
|
|
||||||
// distributed with this work for additional information
|
|
||||||
// regarding copyright ownership. The ASF licenses this file
|
|
||||||
// to you under the Apache License, Version 2.0 (the
|
|
||||||
// "License"); you may not use this file except in compliance
|
|
||||||
// with the License. You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing,
|
|
||||||
// software distributed under the License is distributed on an
|
|
||||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
// KIND, either express or implied. See the License for the
|
|
||||||
// specific language governing permissions and limitations
|
|
||||||
// under the License.
|
|
||||||
package com.cloud.network.ovs;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class OvsCreateTunnelAnswer extends Answer {
|
|
||||||
Long from;
|
|
||||||
Long to;
|
|
||||||
long networkId;
|
|
||||||
String inPortName;
|
|
||||||
|
|
||||||
//for debug info
|
|
||||||
String fromIp;
|
|
||||||
String toIp;
|
|
||||||
int key;
|
|
||||||
String bridge;
|
|
||||||
|
|
||||||
public OvsCreateTunnelAnswer(Command cmd, boolean success, String details, String bridge) {
|
|
||||||
super(cmd, success, details);
|
|
||||||
OvsCreateTunnelCommand c = (OvsCreateTunnelCommand)cmd;
|
|
||||||
from = c.getFrom();
|
|
||||||
to = c.getTo();
|
|
||||||
networkId = c.getNetworkId();
|
|
||||||
inPortName = "[]";
|
|
||||||
fromIp = c.getFromIp();
|
|
||||||
toIp = c.getRemoteIp();
|
|
||||||
key = c.getKey();
|
|
||||||
this.bridge = bridge;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OvsCreateTunnelAnswer(Command cmd, boolean success, String details, String inPortName, String bridge) {
|
|
||||||
this(cmd, success, details, bridge);
|
|
||||||
this.inPortName = inPortName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getFrom() {
|
|
||||||
return from;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getTo() {
|
|
||||||
return to;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getNetworkId() {
|
|
||||||
return networkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInPortName() {
|
|
||||||
return inPortName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFromIp() {
|
|
||||||
return fromIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getToIp() {
|
|
||||||
return toIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getKey() {
|
|
||||||
return key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBridge() {
|
|
||||||
return bridge;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -19,6 +19,7 @@ package com.cloud.network.ovs;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
|
||||||
import javax.ejb.Local;
|
import javax.ejb.Local;
|
||||||
@ -28,7 +29,6 @@ import javax.persistence.EntityExistsException;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
import com.cloud.agent.AgentManager;
|
||||||
@ -60,6 +60,7 @@ import com.cloud.network.ovs.dao.OvsTunnelInterfaceVO;
|
|||||||
import com.cloud.network.ovs.dao.OvsTunnelNetworkDao;
|
import com.cloud.network.ovs.dao.OvsTunnelNetworkDao;
|
||||||
import com.cloud.network.ovs.dao.OvsTunnelNetworkVO;
|
import com.cloud.network.ovs.dao.OvsTunnelNetworkVO;
|
||||||
import com.cloud.utils.component.ManagerBase;
|
import com.cloud.utils.component.ManagerBase;
|
||||||
|
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||||
import com.cloud.utils.db.DB;
|
import com.cloud.utils.db.DB;
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
import com.cloud.utils.exception.CloudRuntimeException;
|
||||||
import com.cloud.vm.DomainRouterVO;
|
import com.cloud.vm.DomainRouterVO;
|
||||||
@ -103,28 +104,11 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
|||||||
@Override
|
@Override
|
||||||
public boolean configure(String name, Map<String, Object> params)
|
public boolean configure(String name, Map<String, Object> params)
|
||||||
throws ConfigurationException {
|
throws ConfigurationException {
|
||||||
return true;
|
_executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
|
||||||
}
|
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
|
||||||
|
|
||||||
@DB
|
return true;
|
||||||
protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
|
}
|
||||||
OvsTunnelNetworkVO ta = null;
|
|
||||||
try {
|
|
||||||
ta = new OvsTunnelNetworkVO(from, to, key, networkId);
|
|
||||||
OvsTunnelNetworkVO lock = _tunnelNetworkDao.acquireInLockTable(Long
|
|
||||||
.valueOf(1));
|
|
||||||
if (lock == null) {
|
|
||||||
s_logger.warn("Cannot lock table ovs_tunnel_account");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_tunnelNetworkDao.persist(ta);
|
|
||||||
_tunnelNetworkDao.releaseFromLockTable(lock.getId());
|
|
||||||
} catch (EntityExistsException e) {
|
|
||||||
s_logger.debug("A record for the tunnel from " + from + " to " + to
|
|
||||||
+ " already exists");
|
|
||||||
}
|
|
||||||
return ta;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
|
protected OvsTunnelInterfaceVO createInterfaceRecord(String ip,
|
||||||
@ -163,14 +147,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_isEnabled) {
|
|
||||||
_executorPool = Executors.newScheduledThreadPool(10, new NamedThreadFactory("OVS"));
|
|
||||||
_cleanupExecutor = Executors.newScheduledThreadPool(1, new NamedThreadFactory("OVS-Cleanup"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@DB
|
@DB
|
||||||
protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
|
protected OvsTunnelNetworkVO createTunnelRecord(long from, long to, long networkId, int key) {
|
||||||
OvsTunnelNetworkVO ta = null;
|
OvsTunnelNetworkVO ta = null;
|
||||||
@ -189,37 +165,6 @@ public class OvsTunnelManagerImpl extends ManagerBase implements OvsTunnelManage
|
|||||||
return ta;
|
return ta;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DB
|
|
||||||
protected OvsTunnelInterfaceVO createInterfaceRecord(String ip, String netmask, String mac, long hostId, String label) {
|
|
||||||
OvsTunnelInterfaceVO ti = null;
|
|
||||||
try {
|
|
||||||
ti = new OvsTunnelInterfaceVO(ip, netmask, mac, hostId, label);
|
|
||||||
//TODO: Is locking really necessary here?
|
|
||||||
OvsTunnelInterfaceVO lock = _tunnelInterfaceDao.acquireInLockTable(Long.valueOf(1));
|
|
||||||
if (lock == null) {
|
|
||||||
s_logger.warn("Cannot lock table ovs_tunnel_account");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
_tunnelInterfaceDao.persist(ti);
|
|
||||||
_tunnelInterfaceDao.releaseFromLockTable(lock.getId());
|
|
||||||
} catch (EntityExistsException e) {
|
|
||||||
s_logger.debug("A record for the interface for network " + label + " on host id " + hostId + " already exists");
|
|
||||||
}
|
|
||||||
return ti;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String handleFetchInterfaceAnswer(Answer[] answers, Long hostId) {
|
|
||||||
OvsFetchInterfaceAnswer ans = (OvsFetchInterfaceAnswer)answers[0];
|
|
||||||
if (ans.getResult()) {
|
|
||||||
if (ans.getIp() != null && !("".equals(ans.getIp()))) {
|
|
||||||
OvsTunnelInterfaceVO ti = createInterfaceRecord(ans.getIp(), ans.getNetmask(), ans.getMac(), hostId, ans.getLabel());
|
|
||||||
return ti.getIp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Fetch interface failed!
|
|
||||||
s_logger.warn("Unable to fetch the IP address for the GRE tunnel endpoint" + ans.getDetails());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleCreateTunnelAnswer(Answer[] answers) {
|
private void handleCreateTunnelAnswer(Answer[] answers) {
|
||||||
OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer)answers[0];
|
OvsCreateTunnelAnswer r = (OvsCreateTunnelAnswer)answers[0];
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user