mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9859: Retirement of midonet plugin (final removal) (#2285)
Following the component retirement process defined in [1], a vote thread was started in [2]. The community decided to retire this Midonet plugin. This task represents the final step of the retirement, which is the removal of the plugin from CloudStacks code base. [1] https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=68720798 [2] http://markmail.org/message/qigrtfirwnmct4hr
This commit is contained in:
parent
0dfdbe064c
commit
b044f1bc96
@ -1018,21 +1018,6 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>midonet</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>midonet</name>
|
||||
</property>
|
||||
</activation>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-network-midonet</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>srx</id>
|
||||
<activation>
|
||||
|
||||
@ -134,7 +134,6 @@
|
||||
<bean id="ipDeployersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="ip.deployers.exclude" />
|
||||
<property name="excludeDefault" value="MidoNetElement" />
|
||||
<property name="preRegistered">
|
||||
<list>
|
||||
<ref bean="VpcVirtualRouter" />
|
||||
@ -145,7 +144,6 @@
|
||||
<bean id="dhcpProvidersRegistry"
|
||||
class="org.apache.cloudstack.spring.lifecycle.registry.ExtensionRegistry">
|
||||
<property name="excludeKey" value="dhcp.providers.exclude" />
|
||||
<property name="excludeDefault" value="MidoNetElement" />
|
||||
<property name="preRegistered">
|
||||
<list>
|
||||
<ref bean="VpcVirtualRouter" />
|
||||
|
||||
@ -1,60 +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.
|
||||
-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cloud-plugin-network-midonet</artifactId>
|
||||
<name>Apache CloudStack Plugin - Midokura Midonet</name>
|
||||
<parent>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloudstack-plugins</artifactId>
|
||||
<version>4.11.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>mido-maven-public-releases</id>
|
||||
<name>mido-maven-public-releases</name>
|
||||
<url>http://cs-maven.midokura.com/releases</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.midonet</groupId>
|
||||
<artifactId>midonet-client</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cloudstack</groupId>
|
||||
<artifactId>cloud-plugin-hypervisor-kvm</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>1.9.11</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
<version>1.9.11</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@ -1,18 +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.
|
||||
name=midonet
|
||||
parent=network
|
||||
@ -1,37 +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.
|
||||
-->
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:aop="http://www.springframework.org/schema/aop"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context.xsd"
|
||||
>
|
||||
|
||||
<bean id="MidoNetGuestNetworkGuru" class="com.cloud.network.guru.MidoNetGuestNetworkGuru">
|
||||
<property name="name" value="MidoNetGuestNetworkGuru" />
|
||||
</bean>
|
||||
<bean id="MidoNetElement" class="com.cloud.network.element.MidoNetElement">
|
||||
<property name="name" value="MidoNetElement" />
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,219 +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.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
// Used for translation between MidoNet firewall rules and
|
||||
// CloudStack firewall rules
|
||||
|
||||
import org.midonet.client.dto.DtoRule;
|
||||
import org.midonet.client.resource.Rule;
|
||||
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.HashBiMap;
|
||||
|
||||
import com.cloud.agent.api.to.FirewallRuleTO;
|
||||
import com.cloud.agent.api.to.NetworkACLTO;
|
||||
import com.cloud.agent.api.to.PortForwardingRuleTO;
|
||||
|
||||
public class SimpleFirewallRule {
|
||||
|
||||
public List<String> sourceCidrs;
|
||||
public String protocol;
|
||||
public String dstIp;
|
||||
public int dstPortStart = 0;
|
||||
public int dstPortEnd = 0;
|
||||
public int icmpType = 0;
|
||||
public int icmpCode = 0;
|
||||
|
||||
private static BiMap<Integer, String> protocolNumberToString;
|
||||
static {
|
||||
protocolNumberToString = HashBiMap.create();
|
||||
protocolNumberToString.put(1, "icmp");
|
||||
protocolNumberToString.put(6, "tcp");
|
||||
protocolNumberToString.put(17, "udp");
|
||||
protocolNumberToString.put(0, "none");
|
||||
}
|
||||
|
||||
public SimpleFirewallRule(FirewallRuleTO rule) {
|
||||
// Destination IP (confusingly called SourceIP in FirewallRule attributes)
|
||||
dstIp = rule.getSrcIp();
|
||||
protocol = rule.getProtocol();
|
||||
|
||||
if ("icmp".equals(protocol)) {
|
||||
icmpType = rule.getIcmpType();
|
||||
icmpCode = rule.getIcmpCode();
|
||||
} else {
|
||||
int[] portNumbers = rule.getSrcPortRange();
|
||||
|
||||
// if port start and end are not set, they
|
||||
// should be 0,0, and that's already the case
|
||||
if (portNumbers != null && portNumbers.length == 2) {
|
||||
dstPortStart = portNumbers[0];
|
||||
dstPortEnd = portNumbers[1];
|
||||
}
|
||||
}
|
||||
|
||||
sourceCidrs = rule.getSourceCidrList();
|
||||
|
||||
// If no CIDRs specified, it is an "all sources" rule
|
||||
if (sourceCidrs == null || sourceCidrs.isEmpty()) {
|
||||
sourceCidrs = new ArrayList<String>();
|
||||
sourceCidrs.add("0.0.0.0/0");
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleFirewallRule(NetworkACLTO rule) {
|
||||
dstIp = "null";
|
||||
protocol = rule.getProtocol();
|
||||
|
||||
if ("icmp".equals(protocol)) {
|
||||
icmpType = rule.getIcmpType();
|
||||
icmpCode = rule.getIcmpCode();
|
||||
} else {
|
||||
int[] portNumbers = rule.getSrcPortRange();
|
||||
|
||||
// if port start and end are not set, they
|
||||
// should be 0,0, and that's already the case
|
||||
if (portNumbers != null && portNumbers.length == 2) {
|
||||
dstPortStart = portNumbers[0];
|
||||
dstPortEnd = portNumbers[1];
|
||||
}
|
||||
}
|
||||
|
||||
sourceCidrs = rule.getSourceCidrList();
|
||||
|
||||
// If no CIDRs specified, it is an "all sources" rule
|
||||
if (sourceCidrs == null || sourceCidrs.isEmpty()) {
|
||||
sourceCidrs = new ArrayList<String>();
|
||||
sourceCidrs.add("0.0.0.0/0");
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleFirewallRule(PortForwardingRuleTO rule) {
|
||||
dstIp = rule.getSrcIp();
|
||||
protocol = rule.getProtocol();
|
||||
|
||||
int[] srcPortNumbers = rule.getSrcPortRange();
|
||||
int[] dstPortNumbers = rule.getDstPortRange();
|
||||
|
||||
// if port start and end are not set, they
|
||||
// should be 0,0, and that's already the case
|
||||
if (srcPortNumbers != null && srcPortNumbers.length == 2 && dstPortNumbers != null && dstPortNumbers.length == 2) {
|
||||
dstPortStart = dstPortNumbers[0];
|
||||
dstPortEnd = srcPortNumbers[0];
|
||||
}
|
||||
|
||||
sourceCidrs = new ArrayList<String>();
|
||||
sourceCidrs.add(rule.getDstIp());
|
||||
}
|
||||
|
||||
public SimpleFirewallRule(Rule rule) {
|
||||
|
||||
String sourceIP = rule.getNwSrcAddress();
|
||||
int sourceLength = rule.getNwSrcLength();
|
||||
|
||||
sourceCidrs = new ArrayList<String>();
|
||||
/*
|
||||
* Only one IP in the CIDR list
|
||||
* Port Forwarding Rules don't have sourceCidrs, but they do have
|
||||
* targets. Use those instead if they exist.
|
||||
*/
|
||||
DtoRule.DtoNatTarget[] targets = rule.getNatTargets();
|
||||
if (targets != null) {
|
||||
sourceCidrs.add(targets[0].addressFrom);
|
||||
} else {
|
||||
sourceCidrs.add(String.format("%s/%d", sourceIP, sourceLength));
|
||||
}
|
||||
|
||||
int protoNum = rule.getNwProto();
|
||||
protocol = SimpleFirewallRule.protocolNumberToString(protoNum);
|
||||
|
||||
dstIp = rule.getNwDstAddress();
|
||||
|
||||
if ("icmp".equals(protocol)) {
|
||||
if (rule.getTpSrc() != null && rule.getTpDst() != null) {
|
||||
icmpType = rule.getTpSrc().start;
|
||||
icmpCode = rule.getTpDst().start;
|
||||
} else {
|
||||
icmpType = -1;
|
||||
icmpCode = -1;
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
* If this is port forwarding, we want to take the start
|
||||
* port for the public port range, and the start port for
|
||||
* the private port range to uniquely identify this rule.
|
||||
*/
|
||||
if (targets != null) {
|
||||
dstPortStart = targets[0].portFrom;
|
||||
} else {
|
||||
dstPortStart = rule.getTpDst().start;
|
||||
}
|
||||
dstPortEnd = rule.getTpDst().end;
|
||||
}
|
||||
|
||||
// cidr, protocol, dstIp, dstPortStart, dstPortEnd, icmpType, icmpCode);
|
||||
}
|
||||
|
||||
public static String protocolNumberToString(int protocolNumber) {
|
||||
return protocolNumberToString.get(protocolNumber);
|
||||
}
|
||||
|
||||
public static int stringToProtocolNumber(String protoString) {
|
||||
return protocolNumberToString.inverse().get(protoString);
|
||||
}
|
||||
|
||||
public int getFieldOne() {
|
||||
if (protocol.equals("icmp")) {
|
||||
return icmpType;
|
||||
|
||||
} else {
|
||||
return dstPortStart;
|
||||
}
|
||||
}
|
||||
|
||||
public int getFieldTwo() {
|
||||
if (protocol.equals("icmp")) {
|
||||
return icmpCode;
|
||||
} else {
|
||||
return dstPortEnd;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] toStringArray() {
|
||||
List<String> stringRules = new ArrayList<String>();
|
||||
|
||||
// Create a rule string per source CIDR, since each MidoNet
|
||||
// rule is for one CIDR
|
||||
for (String sourceCidr : sourceCidrs) {
|
||||
|
||||
// Follows the rule String format defined in SetFirewallRulesCommand.java::generateFirewallRules()
|
||||
int field1 = getFieldOne();
|
||||
int field2 = getFieldTwo();
|
||||
|
||||
String stringRule = String.format("%s:%s:%d:%d:%s:", dstIp, protocol, field1, field2, sourceCidr);
|
||||
stringRules.add(stringRule);
|
||||
}
|
||||
String[] stringArray = new String[stringRules.size()];
|
||||
return stringRules.toArray(stringArray);
|
||||
}
|
||||
}
|
||||
@ -1,160 +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.guru;
|
||||
|
||||
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.PhysicalNetwork;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Component
|
||||
public class MidoNetGuestNetworkGuru extends GuestNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(MidoNetGuestNetworkGuru.class);
|
||||
|
||||
@Inject
|
||||
AccountDao _accountDao;
|
||||
|
||||
public MidoNetGuestNetworkGuru() {
|
||||
super();
|
||||
_isolationMethods = new PhysicalNetwork.IsolationMethod[] {new PhysicalNetwork.IsolationMethod("MIDO")};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canHandle(NetworkOffering offering, NetworkType networkType, PhysicalNetwork physicalNetwork) {
|
||||
// This guru handles only Guest Isolated network that supports Source nat service
|
||||
if (networkType == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) && offering.getGuestType() == Network.GuestType.Isolated &&
|
||||
isMyIsolationMethod(physicalNetwork)) {
|
||||
return true;
|
||||
} else {
|
||||
s_logger.trace("We only take care of Guest networks of type " + Network.GuestType.Isolated + " in zone of type " + NetworkType.Advanced +
|
||||
" using isolation method MIDO.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
||||
s_logger.debug("design called");
|
||||
// Check if the isolation type of the related physical network is MIDO
|
||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
||||
if (physnet == null || physnet.getIsolationMethods() == null || !physnet.getIsolationMethods().contains("MIDO")) {
|
||||
s_logger.debug("Refusing to design this network, the physical isolation type is not MIDO");
|
||||
return null;
|
||||
}
|
||||
|
||||
s_logger.debug("Physical isolation type is MIDO, asking GuestNetworkGuru to design this network");
|
||||
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
|
||||
if (networkObject == null) {
|
||||
return null;
|
||||
}
|
||||
// Override the broadcast domain type - do we need to do this?
|
||||
networkObject.setBroadcastDomainType(Networks.BroadcastDomainType.Mido);
|
||||
|
||||
return networkObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapacityException {
|
||||
assert (network.getState() == Network.State.Implementing) : "Why are we implementing " + network;
|
||||
s_logger.debug("implement called network: " + network.toString());
|
||||
|
||||
long dcId = dest.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented =
|
||||
new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), Network.State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId, offering.getRedundantRouter());
|
||||
|
||||
if (network.getGateway() != null) {
|
||||
implemented.setGateway(network.getGateway());
|
||||
}
|
||||
|
||||
if (network.getCidr() != null) {
|
||||
implemented.setCidr(network.getCidr());
|
||||
}
|
||||
|
||||
AccountVO acc = _accountDao.findById(network.getAccountId());
|
||||
String accountUUIDStr = acc.getUuid();
|
||||
String routerName = "";
|
||||
if (network.getVpcId() != null) {
|
||||
routerName = "VPC" + String.valueOf(network.getVpcId());
|
||||
} else {
|
||||
routerName = String.valueOf(network.getId());
|
||||
}
|
||||
|
||||
String broadcastUriStr = accountUUIDStr + "." + String.valueOf(network.getId()) + ":" + routerName;
|
||||
|
||||
implemented.setBroadcastUri(Networks.BroadcastDomainType.Mido.toUri(broadcastUriStr));
|
||||
s_logger.debug("Broadcast URI set to " + broadcastUriStr);
|
||||
|
||||
return implemented;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
|
||||
s_logger.debug("reserve called with network: " + network.toString() + " nic: " + nic.toString() + " vm: " + vm.toString());
|
||||
|
||||
super.reserve(nic, network, vm, dest, context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
|
||||
s_logger.debug("release called with nic: " + nic.toString() + " vm: " + vm.toString());
|
||||
return super.release(nic, vm, reservationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
||||
s_logger.debug("shutdown called");
|
||||
|
||||
super.shutdown(profile, offering);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
s_logger.debug("trash called with network: " + network.toString());
|
||||
|
||||
return super.trash(network, offering);
|
||||
}
|
||||
}
|
||||
@ -1,252 +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.guru;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.deploy.DeployDestination;
|
||||
import com.cloud.deploy.DeploymentPlan;
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
||||
import com.cloud.network.IpAddressManager;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkModel;
|
||||
import com.cloud.network.NetworkProfile;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.TransactionCallbackNoReturn;
|
||||
import com.cloud.utils.db.TransactionStatus;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
public class MidoNetPublicNetworkGuru extends PublicNetworkGuru {
|
||||
private static final Logger s_logger = Logger.getLogger(MidoNetPublicNetworkGuru.class);
|
||||
|
||||
// Inject any stuff we need to use (DAOs etc)
|
||||
@Inject
|
||||
NetworkModel _networkModel;
|
||||
@Inject
|
||||
AccountDao _accountDao;
|
||||
@Inject
|
||||
IpAddressManager _ipAddrMgr;
|
||||
|
||||
// Don't need to change traffic type stuff, public is fine
|
||||
|
||||
// Only change is to make broadcast domain type Mido
|
||||
@Override
|
||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network network, Account owner) {
|
||||
s_logger.debug("design called with network: " + network);
|
||||
if (!canHandle(offering)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (offering.getTrafficType() == Networks.TrafficType.Public) {
|
||||
NetworkVO ntwk =
|
||||
new NetworkVO(offering.getTrafficType(), Networks.Mode.Static, Networks.BroadcastDomainType.Mido, offering.getId(), Network.State.Allocated,
|
||||
plan.getDataCenterId(), plan.getPhysicalNetworkId(), offering.getRedundantRouter());
|
||||
return ntwk;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected MidoNetPublicNetworkGuru() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void getIp(NicProfile nic, DataCenter dc, VirtualMachineProfile vm, Network network) throws InsufficientVirtualNetworkCapacityException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
if (nic.getIPv4Address() == null) {
|
||||
PublicIp ip = _ipAddrMgr.assignPublicIpAddress(dc.getId(), null, vm.getOwner(), Vlan.VlanType.VirtualNetwork, null, null, false);
|
||||
nic.setIPv4Address(ip.getAddress().addr());
|
||||
|
||||
nic.setIPv4Gateway(ip.getGateway());
|
||||
|
||||
// Set netmask to /24 for now
|
||||
// TDO make it /32 and go via router for anything else on the subnet
|
||||
nic.setIPv4Netmask("255.255.255.0");
|
||||
|
||||
// Make it the default nic so that a default route is set up.
|
||||
nic.setDefaultNic(true);
|
||||
|
||||
//nic.setIsolationUri(Networks.IsolationType..Mido.toUri(ip.getVlanTag()));
|
||||
nic.setBroadcastUri(network.getBroadcastUri());
|
||||
//nic.setBroadcastType(Networks.BroadcastDomainType.Vlan);
|
||||
nic.setFormat(Networks.AddressFormat.Ip4);
|
||||
nic.setReservationId(String.valueOf(ip.getVlanTag()));
|
||||
nic.setMacAddress(ip.getMacAddress());
|
||||
}
|
||||
|
||||
nic.setIPv4Dns1(dc.getDns1());
|
||||
nic.setIPv4Dns2(dc.getDns2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNicProfile(NicProfile profile, Network network) {
|
||||
s_logger.debug("updateNicProfile called with network: " + network + " profile: " + profile);
|
||||
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
if (profile != null) {
|
||||
profile.setIPv4Dns1(dc.getDns1());
|
||||
profile.setIPv4Dns2(dc.getDns2());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
|
||||
if (nic == null) {
|
||||
nic = new NicProfile(Nic.ReservationStrategy.Create, null, null, null, null);
|
||||
}
|
||||
s_logger.debug("allocate called with network: " + network + " nic: " + nic + " vm: " + vm);
|
||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
||||
|
||||
if (nic.getRequestedIPv4() != null) {
|
||||
throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
|
||||
}
|
||||
|
||||
getIp(nic, dc, vm, network);
|
||||
|
||||
if (nic.getIPv4Address() == null) {
|
||||
nic.setReservationStrategy(Nic.ReservationStrategy.Start);
|
||||
} else if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
|
||||
nic.setReservationStrategy(Nic.ReservationStrategy.Managed);
|
||||
} else {
|
||||
nic.setReservationStrategy(Nic.ReservationStrategy.Create);
|
||||
}
|
||||
|
||||
nic.setBroadcastUri(generateBroadcastUri(network));
|
||||
|
||||
return nic;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
s_logger.debug("reserve called with network: " + network + " nic: " + nic + " vm: " + vm);
|
||||
if (nic.getIPv4Address() == null) {
|
||||
getIp(nic, dest.getDataCenter(), vm, network);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean release(NicProfile nic, VirtualMachineProfile vm, String reservationId) {
|
||||
s_logger.debug("release called with nic: " + nic + " vm: " + vm);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Network implement(Network network, NetworkOffering offering, DeployDestination destination, ReservationContext context)
|
||||
throws InsufficientVirtualNetworkCapacityException {
|
||||
s_logger.debug("implement called with network: " + network);
|
||||
long dcId = destination.getDataCenter().getId();
|
||||
|
||||
//get physical network id
|
||||
long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
||||
|
||||
NetworkVO implemented =
|
||||
new NetworkVO(network.getTrafficType(), network.getMode(), network.getBroadcastDomainType(), network.getNetworkOfferingId(), Network.State.Allocated,
|
||||
network.getDataCenterId(), physicalNetworkId, offering.getRedundantRouter());
|
||||
|
||||
if (network.getGateway() != null) {
|
||||
implemented.setGateway(network.getGateway());
|
||||
}
|
||||
|
||||
if (network.getCidr() != null) {
|
||||
implemented.setCidr(network.getCidr());
|
||||
}
|
||||
|
||||
implemented.setBroadcastUri(generateBroadcastUri(network));
|
||||
|
||||
return implemented;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
|
||||
s_logger.debug("deallocate called with network: " + network + " nic: " + nic + " vm: " + vm);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("public network deallocate network: networkId: " + nic.getNetworkId() + ", ip: " + nic.getIPv4Address());
|
||||
}
|
||||
|
||||
final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nic.getNetworkId(), nic.getIPv4Address());
|
||||
if (ip != null && nic.getReservationStrategy() != Nic.ReservationStrategy.Managed) {
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
_ipAddrMgr.markIpAsUnavailable(ip.getId());
|
||||
_ipAddressDao.unassignIpAddress(ip.getId());
|
||||
}
|
||||
});
|
||||
}
|
||||
nic.deallocate();
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Deallocated nic: " + nic);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown(NetworkProfile network, NetworkOffering offering) {
|
||||
s_logger.debug("shutdown called with network: " + network);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean trash(Network network, NetworkOffering offering) {
|
||||
s_logger.debug("trash called with network: " + network);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNetworkProfile(NetworkProfile networkProfile) {
|
||||
DataCenter dc = _dcDao.findById(networkProfile.getDataCenterId());
|
||||
networkProfile.setDns1(dc.getDns1());
|
||||
networkProfile.setDns2(dc.getDns2());
|
||||
}
|
||||
|
||||
private URI generateBroadcastUri(Network network) {
|
||||
AccountVO acc = _accountDao.findById(network.getAccountId());
|
||||
String accountUUIDStr = acc.getUuid();
|
||||
String networkUUIDStr = String.valueOf(network.getId());
|
||||
return Networks.BroadcastDomainType.Mido.toUri(accountUUIDStr + "." + networkUUIDStr + ":" + networkUUIDStr);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,169 +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.resource;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.LibvirtException;
|
||||
import org.midonet.client.MidonetApi;
|
||||
import org.midonet.client.resource.Bridge;
|
||||
import org.midonet.client.resource.BridgePort;
|
||||
import org.midonet.client.resource.Host;
|
||||
|
||||
import com.sun.jersey.core.util.MultivaluedMapImpl;
|
||||
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.hypervisor.kvm.resource.LibvirtVMDef;
|
||||
import com.cloud.hypervisor.kvm.resource.VifDriverBase;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.script.OutputInterpreter;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
public class MidoNetVifDriver extends VifDriverBase {
|
||||
|
||||
private static final Logger s_logger = Logger.getLogger(MidoNetVifDriver.class);
|
||||
private int _timeout;
|
||||
private String _midoApiLocation = "http://localhost:8081/";
|
||||
private static final String midoPostfix = "mnet";
|
||||
|
||||
@Override
|
||||
public void configure(Map<String, Object> params) throws ConfigurationException {
|
||||
|
||||
super.configure(params);
|
||||
|
||||
String value = (String)params.get("scripts.timeout");
|
||||
_timeout = NumbersUtil.parseInt(value, 30 * 60) * 1000;
|
||||
|
||||
// Load Midonet API server location
|
||||
String midoLoc = (String)params.get("midonet.apiserver.address");
|
||||
if (midoLoc != null) {
|
||||
_midoApiLocation = midoLoc;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Grab our host id in a file written by Midonet, then
|
||||
* return a Host.
|
||||
*/
|
||||
private Host getMyHost(MidonetApi api) {
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
command.add("awk -F'=' '{if ($1~/host/) print $2}' /etc/midolman/host_uuid.properties");
|
||||
|
||||
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
|
||||
command.execute(parser);
|
||||
String host_uuid = parser.getLines().split("\\n")[0];
|
||||
for (Host host : api.getHosts()) {
|
||||
if (host.getId().toString().equals(host_uuid)) {
|
||||
return host;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* simple script to add the tap to the host and bring it up.
|
||||
*/
|
||||
private String addTap() {
|
||||
OutputInterpreter.AllLinesParser parser = new OutputInterpreter.AllLinesParser();
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
command.add("ip tuntap add mode tap dev '%d" + midoPostfix + "' && ip link | grep " + midoPostfix + " | sort -n | tail -1 | awk -F': ' '{print $2}'");
|
||||
command.execute(parser);
|
||||
String tapName = parser.getLines().split("\\n")[0];
|
||||
command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
command.add("ip link set " + tapName + " up");
|
||||
command.execute();
|
||||
return tapName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter) throws InternalErrorException, LibvirtException {
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("nic=" + nic);
|
||||
}
|
||||
|
||||
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
|
||||
|
||||
String trafficLabel = nic.getName();
|
||||
|
||||
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Mido && (nic.getType() == Networks.TrafficType.Guest || nic.getType() == Networks.TrafficType.Public)) {
|
||||
/*
|
||||
* create the tap.
|
||||
*/
|
||||
String tapName = addTap();
|
||||
|
||||
/*
|
||||
* grab the tenant id and the network id from the Broadcast URI.
|
||||
* We need to pluck the values out of the String. The string
|
||||
* should look like "mido://[tenant_id].[bridge_name]"
|
||||
*/
|
||||
MultivaluedMap qNet = new MultivaluedMapImpl();
|
||||
String nicAuthority = nic.getBroadcastUri().getAuthority();
|
||||
String tenantId = nicAuthority.split("\\.")[0];
|
||||
qNet.add("tenant_id", tenantId);
|
||||
String url = nicAuthority.split("\\.")[1];
|
||||
String netName = url.split(":")[0];
|
||||
|
||||
MidonetApi api = new MidonetApi(_midoApiLocation);
|
||||
api.enableLogging();
|
||||
|
||||
for (Bridge b : api.getBridges(qNet)) {
|
||||
if (b.getName().equals(netName)) {
|
||||
for (BridgePort p : b.getPorts()) {
|
||||
UUID pvif = p.getVifId();
|
||||
if (pvif != null && p.getVifId().toString().equals(nic.getUuid())) {
|
||||
getMyHost(api).addHostInterfacePort().interfaceName(tapName).portId(p.getId()).create();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
intf.defEthernet(tapName, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), "");
|
||||
|
||||
} else {
|
||||
throw new InternalErrorException("Only NICs of BroadcastDomain type Mido are supported by the MidoNetVifDriver");
|
||||
}
|
||||
|
||||
return intf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unplug(LibvirtVMDef.InterfaceDef iface) {
|
||||
String netName = iface.getBrName();
|
||||
|
||||
if (netName != null && netName.contains(midoPostfix)) {
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
command.add("ip tuntap del " + iface.getBrName() + " mode tap");
|
||||
command.execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,199 +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.element;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyLong;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.midonet.client.MidonetApi;
|
||||
import org.midonet.client.resource.Bridge;
|
||||
import org.midonet.client.resource.BridgePort;
|
||||
import org.midonet.client.resource.DhcpHost;
|
||||
import org.midonet.client.resource.DhcpSubnet;
|
||||
import org.midonet.client.resource.Port;
|
||||
import org.midonet.client.resource.ResourceCollection;
|
||||
import org.midonet.client.resource.Router;
|
||||
import org.midonet.client.resource.RouterPort;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks;
|
||||
import com.cloud.user.AccountVO;
|
||||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class MidoNetElementTest extends TestCase {
|
||||
|
||||
/*
|
||||
* Test the standard case of addDhcpEntry with no errors.
|
||||
*/
|
||||
public void testAddDhcpEntry() {
|
||||
|
||||
//mockMgmt
|
||||
MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);
|
||||
|
||||
//mockDhcpHost
|
||||
DhcpHost mockDhcpHost = mock(DhcpHost.class);
|
||||
|
||||
//mockHostCollection
|
||||
ResourceCollection<DhcpHost> hosts = new ResourceCollection<DhcpHost>(new ArrayList<DhcpHost>());
|
||||
|
||||
//mockDhcpSubnet
|
||||
DhcpSubnet mockSub = mock(DhcpSubnet.class);
|
||||
when(mockSub.addDhcpHost()).thenReturn(mockDhcpHost);
|
||||
when(mockSub.getDhcpHosts()).thenReturn(hosts);
|
||||
|
||||
//mockSubnetCollection
|
||||
ResourceCollection mockSubnetCollection = mock(ResourceCollection.class);
|
||||
when(mockSubnetCollection.get(anyInt())).thenReturn(mockSub);
|
||||
|
||||
//mockBridge
|
||||
Bridge mockBridge = mock(Bridge.class);
|
||||
when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
|
||||
when(mockBridge.getDhcpSubnets()).thenReturn(mockSubnetCollection);
|
||||
|
||||
//mockRouter
|
||||
Router mockRouter = mock(Router.class);
|
||||
when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
|
||||
|
||||
//mockNetwork
|
||||
Network mockNetwork = mock(Network.class);
|
||||
when(mockNetwork.getAccountId()).thenReturn((long)1);
|
||||
when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
|
||||
when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
|
||||
when(mockNetwork.getId()).thenReturn((long)2);
|
||||
when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
|
||||
when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Guest);
|
||||
|
||||
//mockAccountDao
|
||||
AccountDao mockAccountDao = mock(AccountDao.class);
|
||||
AccountVO mockAccountVO = mock(AccountVO.class);
|
||||
when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
|
||||
when(mockAccountVO.getUuid()).thenReturn("1");
|
||||
|
||||
//mockNic
|
||||
NicProfile mockNic = mock(NicProfile.class);
|
||||
when(mockNic.getIPv4Address()).thenReturn("10.10.10.170");
|
||||
when(mockNic.getMacAddress()).thenReturn("02:00:73:3e:00:01");
|
||||
when(mockNic.getName()).thenReturn("Fake Name");
|
||||
|
||||
//mockVm
|
||||
@SuppressWarnings("unchecked")
|
||||
VirtualMachineProfile mockVm = mock(VirtualMachineProfile.class);
|
||||
when(mockVm.getType()).thenReturn(VirtualMachine.Type.User);
|
||||
|
||||
MidoNetElement elem = new MidoNetElement();
|
||||
elem.setMidonetApi(api);
|
||||
elem.setAccountDao(mockAccountDao);
|
||||
|
||||
boolean result = false;
|
||||
try {
|
||||
result = elem.addDhcpEntry(mockNetwork, mockNic, mockVm, null, null);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
fail(e.getMessage());
|
||||
} catch (InsufficientCapacityException e) {
|
||||
fail(e.getMessage());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
assertEquals(result, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Test the standard case of implement with no errors.
|
||||
*/
|
||||
public void testImplement() {
|
||||
//mock
|
||||
MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);
|
||||
|
||||
//mockAccountDao
|
||||
AccountDao mockAccountDao = mock(AccountDao.class);
|
||||
AccountVO mockAccountVO = mock(AccountVO.class);
|
||||
when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
|
||||
when(mockAccountVO.getUuid()).thenReturn("1");
|
||||
MidoNetElement elem = new MidoNetElement();
|
||||
|
||||
elem.setMidonetApi(api);
|
||||
elem.setAccountDao(mockAccountDao);
|
||||
|
||||
//mockRPort
|
||||
RouterPort mockRPort = mock(RouterPort.class);
|
||||
when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));
|
||||
|
||||
//mockBPort
|
||||
BridgePort mockBPort = mock(BridgePort.class);
|
||||
when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);
|
||||
|
||||
//mockPort
|
||||
Port mockPort = mock(Port.class);
|
||||
|
||||
ResourceCollection<Port> peerPorts = new ResourceCollection<Port>(new ArrayList<Port>());
|
||||
|
||||
peerPorts.add(mockPort);
|
||||
|
||||
//mockBridge
|
||||
Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
|
||||
when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
|
||||
when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
|
||||
when(mockBridge.getPeerPorts()).thenReturn(peerPorts);
|
||||
|
||||
//mockRouter
|
||||
Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
|
||||
when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
|
||||
when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);
|
||||
|
||||
//mockNetwork
|
||||
Network mockNetwork = mock(Network.class);
|
||||
when(mockNetwork.getAccountId()).thenReturn((long)1);
|
||||
when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
|
||||
when(mockNetwork.getCidr()).thenReturn("1.2.3.0/24");
|
||||
when(mockNetwork.getId()).thenReturn((long)2);
|
||||
when(mockNetwork.getBroadcastDomainType()).thenReturn(Networks.BroadcastDomainType.Mido);
|
||||
when(mockNetwork.getTrafficType()).thenReturn(Networks.TrafficType.Public);
|
||||
|
||||
boolean result = false;
|
||||
try {
|
||||
result = elem.implement(mockNetwork, null, null, null);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
fail(e.getMessage());
|
||||
} catch (InsufficientCapacityException e) {
|
||||
fail(e.getMessage());
|
||||
} catch (ResourceUnavailableException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
|
||||
assertEquals(result, true);
|
||||
}
|
||||
}
|
||||
@ -207,11 +207,5 @@
|
||||
<module>hypervisors/simulator</module>
|
||||
</modules>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>midonet</id>
|
||||
<modules>
|
||||
<module>network-elements/midonet</module>
|
||||
</modules>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
@ -1449,9 +1449,6 @@
|
||||
<Component Id="cmpE79D8DE0A3F5641D63029C9C5BB84D0D" Guid="{71A421D6-EC6B-4410-BEB8-D8A13CBF2F76}">
|
||||
<File Id="fil26BE9842DE6416E8946A2295439E129D" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\cloud-plugin-network-internallb-4.4.0-SNAPSHOT.jar" />
|
||||
</Component>
|
||||
<Component Id="cmpA6C72B638E002C5141944F120B6B9711" Guid="{02C8CA2E-826F-452D-AC54-2E8787451C2B}">
|
||||
<File Id="filB57FEF496D3CF0EDD6B9DC7FA5E08D31" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\cloud-plugin-network-midonet-4.4.0-SNAPSHOT.jar" />
|
||||
</Component>
|
||||
<Component Id="cmpBA53547354F4749AB6DB53E652729729" Guid="{0026D30B-04AA-45D9-9582-743650497E99}">
|
||||
<File Id="filC6F3205D9E0721B202FECAD231D0E72B" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\cloud-plugin-network-netscaler-4.4.0-SNAPSHOT.jar" />
|
||||
</Component>
|
||||
@ -1704,9 +1701,6 @@
|
||||
<Component Id="cmp6114379A976905B2F2770C6E5934AC79" Guid="{8CCECB3F-062A-439E-863E-950BA2B0062F}">
|
||||
<File Id="fil6A0D7E786C6E6FD2FF2C2D52A4A7FB3E" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\mail-1.4.jar" />
|
||||
</Component>
|
||||
<Component Id="cmpCF3E965E2D26D7E48F44F280084D6836" Guid="{7A9845D3-BF3E-495C-9CFB-BA1D37199DAB}">
|
||||
<File Id="fil7B2A7C3FF6D92CABA0F6015F9D1FCB7E" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\midonet-client-1.1.0.jar" />
|
||||
</Component>
|
||||
<Component Id="cmp2210FF2D22610D7C6B5B50F74A6CCFF6" Guid="{8B4D96E1-E8D0-415D-BC1E-0D6B9C2896EB}">
|
||||
<File Id="fil79A9A35E5D30D89644135E92F334EBC6" KeyPath="yes" Source="!(wix.SourceClient)\WEB-INF\lib\nekohtml-1.9.12.jar" />
|
||||
</Component>
|
||||
|
||||
@ -16,6 +16,15 @@
|
||||
// under the License.
|
||||
package com.cloud.configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.consoleproxy.ConsoleProxyManager;
|
||||
import com.cloud.ha.HighAvailabilityManager;
|
||||
@ -29,14 +38,6 @@ import com.cloud.storage.snapshot.SnapshotManager;
|
||||
import com.cloud.template.TemplateManager;
|
||||
import com.cloud.vm.UserVmManager;
|
||||
import com.cloud.vm.snapshot.VMSnapshotManager;
|
||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.StoragePoolAllocator;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public enum Config {
|
||||
|
||||
@ -1209,24 +1210,6 @@ public enum Config {
|
||||
VmwareHungWorkerTimeout("Advanced", ManagementServer.class, Long.class, "vmware.hung.wokervm.timeout", "7200", "Worker VM timeout in seconds", null),
|
||||
VmwareVcenterSessionTimeout("Advanced", ManagementServer.class, Long.class, "vmware.vcenter.session.timeout", "1200", "VMware client timeout in seconds", null),
|
||||
|
||||
// Midonet
|
||||
MidoNetAPIServerAddress(
|
||||
"Network",
|
||||
ManagementServer.class,
|
||||
String.class,
|
||||
"midonet.apiserver.address",
|
||||
"http://localhost:8081",
|
||||
"Specify the address at which the Midonet API server can be contacted (if using Midonet)",
|
||||
null),
|
||||
MidoNetProviderRouterId(
|
||||
"Network",
|
||||
ManagementServer.class,
|
||||
String.class,
|
||||
"midonet.providerrouter.id",
|
||||
"d7c5e6a3-e2f4-426b-b728-b7ce6a0448e5",
|
||||
"Specifies the UUID of the Midonet provider router (if using Midonet)",
|
||||
null),
|
||||
|
||||
// KVM
|
||||
KvmPublicNetwork("Hidden", ManagementServer.class, String.class, "kvm.public.network.device", null, "Specify the public bridge on host for public network", null),
|
||||
KvmPrivateNetwork("Hidden", ManagementServer.class, String.class, "kvm.private.network.device", null, "Specify the private bridge on host for private network", null),
|
||||
|
||||
@ -248,3 +248,6 @@ ALTER TABLE `cloud`.`oobm` MODIFY COLUMN port VARCHAR(255);
|
||||
|
||||
-- CLOUDSTACK-9902: Console proxy SSL toggle
|
||||
INSERT IGNORE INTO `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`, `default_value`, `is_dynamic`) VALUES ('Console Proxy', 'DEFAULT', 'AgentManager', 'consoleproxy.sslEnabled', 'false', 'Enable SSL for console proxy', 'false', 0);
|
||||
|
||||
-- CLOUDSTACK-9859: Retirement of midonet plugin (final removal)
|
||||
delete from `cloud`.`configuration` where name in ('midonet.apiserver.address', 'midonet.providerrouter.id');
|
||||
@ -428,7 +428,7 @@
|
||||
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
|
||||
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
/instance/org.eclipse.wst.sse.core/task-tag-projects-already-scanned=cloud-agent,cloud-api,cloud-apidoc,cloud-cli,cloud-client-ui,cloud-console-proxy,cloud-core,cloud-devcloud,cloud-devcloud-kvm,cloud-developer,cloud-engine,cloud-engine-api,cloud-engine-components-api,cloud-engine-compute,cloud-engine-network,cloud-engine-orchestration,cloud-engine-schema,cloud-engine-service,cloud-engine-storage,cloud-engine-storage-backup,cloud-engine-storage-image,cloud-engine-storage-imagemotion,cloud-engine-storage-integration-test,cloud-engine-storage-snapshot,cloud-engine-storage-volume,cloud-framework-events,cloud-framework-ipc,cloud-framework-rest,cloud-marvin,cloud-mom-rabbitmq,cloud-patches,cloud-plugin-acl-static-role-based,cloud-plugin-api-discovery,cloud-plugin-api-limit-account-based,cloud-plugin-console-proxy,cloud-plugin-example-dns-notifier,cloud-plugin-host-allocator-random,cloud-plugin-hypervisor-baremetal,cloud-plugin-hypervisor-kvm,cloud-plugin-hypervisor-ovm,cloud-plugin-hypervisor-simulator,cloud-plugin-hypervisor-ucs,cloud-plugin-hypervisor-vmware,cloud-plugin-hypervisor-xen,cloud-plugin-netapp,cloud-plugin-network-elb,cloud-plugin-network-f5,cloud-plugin-network-netscaler,cloud-plugin-network-nvp,cloud-plugin-network-ovs,cloud-plugin-network-srx,cloud-plugin-network-bigswitch,cloud-plugin-planner-user-concentrated-pod,cloud-plugin-planner-user-dispersing,cloud-plugin-snmp-alerts,cloud-plugin-storage-allocator-random,cloud-plugin-storage-image-s3,cloud-plugin-storage-volume-default,cloud-plugin-storage-volume-solidfire,cloud-plugin-syslog-alerts,cloud-plugin-user-authenticator-ldap,cloud-plugin-user-authenticator-md5,cloud-plugin-user-authenticator-plaintext,cloud-plugin-user-authenticator-saml2,cloud-plugin-user-authenticator-sha256salted,cloud-server,cloud-testclient,cloud-tools,cloud-usage,cloud-utils,cloud-vmware-base,cloudstack,cloudstack-framework,cloudstack-plugins,xapi,cloud-framework-jobs,cloud-plugin-host-anti-affinity,cloud-plugin-network-cisco-vnmc,cloud-plugin-network-midonet,cloud-secondary-storage,cloudstack-services,cloud-plugin-network-internallb,cloud-plugin-planner-implicit-dedication,cloudstack-service-console-proxy
|
||||
/instance/org.eclipse.wst.sse.core/task-tag-projects-already-scanned=cloud-agent,cloud-api,cloud-apidoc,cloud-cli,cloud-client-ui,cloud-console-proxy,cloud-core,cloud-devcloud,cloud-devcloud-kvm,cloud-developer,cloud-engine,cloud-engine-api,cloud-engine-components-api,cloud-engine-compute,cloud-engine-network,cloud-engine-orchestration,cloud-engine-schema,cloud-engine-service,cloud-engine-storage,cloud-engine-storage-backup,cloud-engine-storage-image,cloud-engine-storage-imagemotion,cloud-engine-storage-integration-test,cloud-engine-storage-snapshot,cloud-engine-storage-volume,cloud-framework-events,cloud-framework-ipc,cloud-framework-rest,cloud-marvin,cloud-mom-rabbitmq,cloud-patches,cloud-plugin-acl-static-role-based,cloud-plugin-api-discovery,cloud-plugin-api-limit-account-based,cloud-plugin-console-proxy,cloud-plugin-example-dns-notifier,cloud-plugin-host-allocator-random,cloud-plugin-hypervisor-baremetal,cloud-plugin-hypervisor-kvm,cloud-plugin-hypervisor-ovm,cloud-plugin-hypervisor-simulator,cloud-plugin-hypervisor-ucs,cloud-plugin-hypervisor-vmware,cloud-plugin-hypervisor-xen,cloud-plugin-netapp,cloud-plugin-network-elb,cloud-plugin-network-f5,cloud-plugin-network-netscaler,cloud-plugin-network-nvp,cloud-plugin-network-ovs,cloud-plugin-network-srx,cloud-plugin-network-bigswitch,cloud-plugin-planner-user-concentrated-pod,cloud-plugin-planner-user-dispersing,cloud-plugin-snmp-alerts,cloud-plugin-storage-allocator-random,cloud-plugin-storage-image-s3,cloud-plugin-storage-volume-default,cloud-plugin-storage-volume-solidfire,cloud-plugin-syslog-alerts,cloud-plugin-user-authenticator-ldap,cloud-plugin-user-authenticator-md5,cloud-plugin-user-authenticator-plaintext,cloud-plugin-user-authenticator-saml2,cloud-plugin-user-authenticator-sha256salted,cloud-server,cloud-testclient,cloud-tools,cloud-usage,cloud-utils,cloud-vmware-base,cloudstack,cloudstack-framework,cloudstack-plugins,xapi,cloud-framework-jobs,cloud-plugin-host-anti-affinity,cloud-plugin-network-cisco-vnmc,cloud-secondary-storage,cloudstack-services,cloud-plugin-network-internallb,cloud-plugin-planner-implicit-dedication,cloudstack-service-console-proxy
|
||||
/instance/org.eclipse.jdt.debug.ui/org.eclipse.debug.ui.ExpressionView.org.eclipse.jdt.debug.ui.show_null_entries=true
|
||||
/instance/org.eclipse.jdt.ui/sp_cleanup.correct_indentation=false
|
||||
/instance/org.eclipse.jdt.core/org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||
|
||||
@ -6150,127 +6150,6 @@
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
// MidoNet provider detailView
|
||||
midoNet: {
|
||||
id: 'midoNet',
|
||||
label: 'label.midoNet',
|
||||
isMaximized: true,
|
||||
type: 'detailView',
|
||||
fields: {
|
||||
name: {
|
||||
label: 'label.name'
|
||||
},
|
||||
//ipaddress: { label: 'label.ip.address' },
|
||||
state: {
|
||||
label: 'label.status',
|
||||
indicator: {
|
||||
'Enabled': 'on'
|
||||
}
|
||||
}
|
||||
},
|
||||
tabs: {
|
||||
details: {
|
||||
title: 'label.network',
|
||||
fields:[ {
|
||||
name: {
|
||||
label: 'label.name'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: {
|
||||
label: 'label.id'
|
||||
},
|
||||
state: {
|
||||
label: 'label.state'
|
||||
},
|
||||
physicalnetworkid: {
|
||||
label: 'label.physical.network.ID'
|
||||
},
|
||||
destinationphysicalnetworkid: {
|
||||
label: 'label.destination.physical.network.id'
|
||||
},
|
||||
supportedServices: {
|
||||
label: 'label.supported.services'
|
||||
}
|
||||
}],
|
||||
dataProvider: function (args) {
|
||||
refreshNspData("MidoNet");
|
||||
args.response.success({
|
||||
actionFilter: virtualRouterProviderActionFilter,
|
||||
data: $.extend(nspMap[ "midoNet"], {
|
||||
supportedServices: nspMap[ "midoNet"].servicelist.join(', ')
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
enable: {
|
||||
label: 'label.enable.provider',
|
||||
action: function (args) {
|
||||
$.ajax({
|
||||
url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "midoNet"].id + "&state=Enabled"),
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
var jid = json.updatenetworkserviceproviderresponse.jobid;
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: jid,
|
||||
getUpdatedItem: function (json) {
|
||||
$(window).trigger('cloudStack.fullRefresh');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
messages: {
|
||||
confirm: function (args) {
|
||||
return 'message.confirm.enable.provider';
|
||||
},
|
||||
notification: function () {
|
||||
return 'label.enable.provider';
|
||||
}
|
||||
},
|
||||
notification: {
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
},
|
||||
disable: {
|
||||
label: 'label.disable.provider',
|
||||
action: function (args) {
|
||||
$.ajax({
|
||||
url: createURL("updateNetworkServiceProvider&id=" + nspMap[ "midoNet"].id + "&state=Disabled"),
|
||||
dataType: "json",
|
||||
success: function (json) {
|
||||
var jid = json.updatenetworkserviceproviderresponse.jobid;
|
||||
args.response.success({
|
||||
_custom: {
|
||||
jobId: jid,
|
||||
getUpdatedItem: function (json) {
|
||||
$(window).trigger('cloudStack.fullRefresh');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
messages: {
|
||||
confirm: function (args) {
|
||||
return 'message.confirm.disable.provider';
|
||||
},
|
||||
notification: function () {
|
||||
return 'label.disable.provider';
|
||||
}
|
||||
},
|
||||
notification: {
|
||||
poll: pollAsyncJobResult
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//ovs
|
||||
Ovs: {
|
||||
id: 'ovsProviders',
|
||||
@ -22001,9 +21880,6 @@
|
||||
case "Netscaler":
|
||||
nspMap[ "netscaler"] = items[i];
|
||||
break;
|
||||
case "MidoNet":
|
||||
nspMap[ "midoNet"] = items[i];
|
||||
break;
|
||||
case "BaremetalDhcpProvider":
|
||||
nspMap[ "BaremetalDhcpProvider"] = items[i];
|
||||
break;
|
||||
@ -22103,12 +21979,6 @@
|
||||
state: nspMap.securityGroups ? nspMap.securityGroups.state: 'Disabled'
|
||||
});
|
||||
} else if (selectedZoneObj.networktype == "Advanced") {
|
||||
nspHardcodingArray.push({
|
||||
id: 'midoNet',
|
||||
name: 'MidoNet',
|
||||
state: nspMap.midoNet ? nspMap.midoNet.state: 'Disabled'
|
||||
});
|
||||
|
||||
nspHardcodingArray.push({
|
||||
id: 'nuageVsp',
|
||||
name: 'Nuage Vsp',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user