mirror of https://github.com/apache/cloudstack.git
Merge remote-tracking branch 'origin/4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
bd9880003f
|
|
@ -21,6 +21,9 @@ import java.net.URI;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang.builder.ToStringStyle;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity;
|
||||
import org.apache.cloudstack.api.Displayable;
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
|
|
@ -95,6 +98,12 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
return success;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append("name", name)
|
||||
.toString();
|
||||
}
|
||||
|
||||
public static Service getService(String serviceName) {
|
||||
for (Service service : supportedServices) {
|
||||
if (service.getName().equalsIgnoreCase(serviceName)) {
|
||||
|
|
@ -186,6 +195,12 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append("name", name)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Capability {
|
||||
|
|
@ -241,6 +256,12 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
|
||||
.append("name", name)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
enum Event {
|
||||
|
|
|
|||
|
|
@ -16,12 +16,12 @@
|
|||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class NetworkProfile implements Network {
|
||||
private final long id;
|
||||
private final String uuid;
|
||||
|
|
@ -33,6 +33,7 @@ public class NetworkProfile implements Network {
|
|||
private URI broadcastUri;
|
||||
private final State state;
|
||||
private boolean isRedundant;
|
||||
private boolean isRollingRestart = false;
|
||||
private final String name;
|
||||
private final Mode mode;
|
||||
private final BroadcastDomainType broadcastDomainType;
|
||||
|
|
@ -92,6 +93,7 @@ public class NetworkProfile implements Network {
|
|||
guruName = network.getGuruName();
|
||||
strechedL2Subnet = network.isStrechedL2Network();
|
||||
isRedundant = network.isRedundant();
|
||||
isRollingRestart = network.isRollingRestart();
|
||||
externalId = network.getExternalId();
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +159,7 @@ public class NetworkProfile implements Network {
|
|||
|
||||
@Override
|
||||
public boolean isRollingRestart() {
|
||||
return false;
|
||||
return isRollingRestart;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ import com.cloud.vm.VirtualMachine;
|
|||
public interface NicDao extends GenericDao<NicVO, Long> {
|
||||
List<NicVO> listByVmId(long instanceId);
|
||||
|
||||
List<NicVO> listByVmIdOrderByDeviceId(long instanceId);
|
||||
|
||||
List<String> listIpAddressInNetwork(long networkConfigId);
|
||||
|
||||
List<NicVO> listByVmIdIncludingRemoved(long instanceId);
|
||||
|
|
|
|||
|
|
@ -118,6 +118,13 @@ public class NicDaoImpl extends GenericDaoBase<NicVO, Long> implements NicDao {
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicVO> listByVmIdOrderByDeviceId(long instanceId) {
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
sc.setParameters("instance", instanceId);
|
||||
return customSearch(sc, new Filter(NicVO.class, "deviceId", true, null, null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NicVO> listByVmIdIncludingRemoved(long instanceId) {
|
||||
SearchCriteria<NicVO> sc = AllFieldsSearch.create();
|
||||
|
|
|
|||
|
|
@ -19,6 +19,17 @@
|
|||
|
||||
package com.cloud.network.element;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.withSettings;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -26,19 +37,12 @@ import java.util.Arrays;
|
|||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
|
||||
|
||||
import com.cloud.NuageTest;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -50,6 +54,7 @@ import com.cloud.exception.CloudException;
|
|||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.exception.UnsupportedServiceException;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.network.Network;
|
||||
|
|
@ -62,7 +67,9 @@ import com.cloud.network.NuageVspDeviceVO;
|
|||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.IPAddressVO;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.dao.NetworkVO;
|
||||
import com.cloud.network.dao.NuageVspDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
||||
|
|
@ -77,19 +84,14 @@ import com.cloud.offerings.NetworkOfferingVO;
|
|||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
||||
import com.cloud.resource.ResourceManager;
|
||||
import com.cloud.tags.dao.ResourceTagDao;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.util.NuageVspEntityBuilder;
|
||||
import com.cloud.vm.DomainRouterVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.Mockito.withSettings;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
public class NuageVspElementTest extends NuageTest {
|
||||
|
||||
|
|
@ -233,6 +235,18 @@ public class NuageVspElementTest extends NuageTest {
|
|||
Service.Connectivity,
|
||||
Service.Firewall);
|
||||
assertTrue(_nuageVspElement.verifyServicesCombination(services));
|
||||
|
||||
|
||||
services = Sets.newHashSet(
|
||||
Service.Dhcp,
|
||||
Service.StaticNat,
|
||||
Service.Firewall);
|
||||
try {
|
||||
_nuageVspElement.verifyServicesCombination(services);
|
||||
fail("Expected Exception");
|
||||
} catch (UnsupportedServiceException e) {
|
||||
assertThat(e.getMessage(), is("Provider Network.Provider[name=NuageVsp] requires services: [Network.Service[name=Connectivity]]"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
final List<Pair<Nic, Network>> publicNics = new ArrayList<Pair<Nic, Network>>();
|
||||
final Map<String, String> vlanMacAddress = new HashMap<String, String>();
|
||||
|
||||
final List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
|
||||
final List<? extends Nic> routerNics = _nicDao.listByVmIdOrderByDeviceId(profile.getId());
|
||||
for (final Nic routerNic : routerNics) {
|
||||
final Network network = _networkModel.getNetwork(routerNic.getNetworkId());
|
||||
if (network.getTrafficType() == TrafficType.Guest) {
|
||||
|
|
|
|||
|
|
@ -16,9 +16,21 @@
|
|||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
from netaddr import *
|
||||
|
||||
|
||||
def macdevice_map():
|
||||
device_map = {}
|
||||
for eth in os.listdir('/sys/class/net'):
|
||||
if not eth.startswith('eth'):
|
||||
continue
|
||||
with open('/sys/class/net/%s/address' % eth) as f:
|
||||
mac_address = f.read().replace('\n', '')
|
||||
device_map[mac_address] = eth[3:]
|
||||
return device_map
|
||||
|
||||
|
||||
def merge(dbag, ip):
|
||||
nic_dev_id = None
|
||||
for dev in dbag:
|
||||
|
|
@ -33,6 +45,11 @@ def merge(dbag, ip):
|
|||
ipo = IPNetwork(ip['public_ip'] + '/' + ip['netmask'])
|
||||
if 'nic_dev_id' in ip:
|
||||
nic_dev_id = ip['nic_dev_id']
|
||||
if 'vif_mac_address' in ip:
|
||||
mac_address = ip['vif_mac_address']
|
||||
device_map = macdevice_map()
|
||||
if mac_address in device_map:
|
||||
nic_dev_id = device_map[mac_address]
|
||||
ip['device'] = 'eth' + str(nic_dev_id)
|
||||
ip['broadcast'] = str(ipo.broadcast)
|
||||
ip['cidr'] = str(ipo.ip) + '/' + str(ipo.prefixlen)
|
||||
|
|
|
|||
|
|
@ -37,13 +37,13 @@ import java.net.UnknownHostException;
|
|||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import com.googlecode.ipv6.IPv6Network;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils.SupersetOrSubset;
|
||||
import com.googlecode.ipv6.IPv6Address;
|
||||
import com.googlecode.ipv6.IPv6Network;
|
||||
|
||||
public class NetUtilsTest {
|
||||
|
||||
|
|
@ -697,6 +697,8 @@ public class NetUtilsTest {
|
|||
|
||||
public void testAllIpsOfDefaultNic() {
|
||||
final String defaultHostIp = NetUtils.getDefaultHostIp();
|
||||
assertTrue(NetUtils.getAllDefaultNicIps().stream().anyMatch(defaultHostIp::contains));
|
||||
if (defaultHostIp != null) {
|
||||
assertTrue(NetUtils.getAllDefaultNicIps().stream().anyMatch(defaultHostIp::contains));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue