mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
parent
4c60a5b1ff
commit
e11f7ee1ba
@ -480,9 +480,6 @@ public class EventTypes {
|
|||||||
public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE";
|
public static final String EVENT_EXTERNAL_OVS_CONTROLLER_DELETE = "PHYSICAL.OVSCONTROLLER.DELETE";
|
||||||
|
|
||||||
// external network mapping events
|
// external network mapping events
|
||||||
public static final String EVENT_EXTERNAL_VSP_VSD_ADD = "PHYSICAL.NUAGE.VSD.ADD";
|
|
||||||
public static final String EVENT_EXTERNAL_VSP_VSD_UPDATE = "PHYSICAL.NUAGE.VSD.UPDATE";
|
|
||||||
public static final String EVENT_EXTERNAL_VSP_VSD_DELETE = "PHYSICAL.NUAGE.VSD.DELETE";
|
|
||||||
// AutoScale
|
// AutoScale
|
||||||
public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE";
|
public static final String EVENT_COUNTER_CREATE = "COUNTER.CREATE";
|
||||||
public static final String EVENT_COUNTER_DELETE = "COUNTER.DELETE";
|
public static final String EVENT_COUNTER_DELETE = "COUNTER.DELETE";
|
||||||
@ -924,8 +921,6 @@ public class EventTypes {
|
|||||||
entityEventDetails.put(EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE, "NvpController");
|
entityEventDetails.put(EVENT_EXTERNAL_NVP_CONTROLLER_CONFIGURE, "NvpController");
|
||||||
|
|
||||||
// external network mapping events
|
// external network mapping events
|
||||||
entityEventDetails.put(EVENT_EXTERNAL_VSP_VSD_ADD, "NuageVsp");
|
|
||||||
entityEventDetails.put(EVENT_EXTERNAL_VSP_VSD_DELETE, "NuageVsp");
|
|
||||||
|
|
||||||
// AutoScale
|
// AutoScale
|
||||||
entityEventDetails.put(EVENT_COUNTER_CREATE, AutoScaleCounter.class);
|
entityEventDetails.put(EVENT_COUNTER_CREATE, AutoScaleCounter.class);
|
||||||
|
|||||||
@ -144,8 +144,6 @@ public interface Network extends ControlledEntity, StateObject<Network.State>, I
|
|||||||
// add new Ovs provider
|
// add new Ovs provider
|
||||||
public static final Provider Ovs = new Provider("Ovs", false);
|
public static final Provider Ovs = new Provider("Ovs", false);
|
||||||
public static final Provider Opendaylight = new Provider("Opendaylight", false);
|
public static final Provider Opendaylight = new Provider("Opendaylight", false);
|
||||||
// add Nuage Vsp Providers
|
|
||||||
public static final Provider NuageVsp = new Provider("NuageVsp", false);
|
|
||||||
public static final Provider BrocadeVcs = new Provider("BrocadeVcs", false);
|
public static final Provider BrocadeVcs = new Provider("BrocadeVcs", false);
|
||||||
// add GloboDns provider
|
// add GloboDns provider
|
||||||
public static final Provider GloboDns = new Provider("GloboDns", true);
|
public static final Provider GloboDns = new Provider("GloboDns", true);
|
||||||
|
|||||||
@ -125,8 +125,8 @@ public class Networks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
UnDecided(null, null), OpenDaylight("opendaylight", String.class),
|
UnDecided(null, null),
|
||||||
Vsp("vsp", String.class),;
|
OpenDaylight("opendaylight", String.class);
|
||||||
|
|
||||||
private final String scheme;
|
private final String scheme;
|
||||||
private final Class<?> type;
|
private final Class<?> type;
|
||||||
|
|||||||
@ -213,11 +213,6 @@
|
|||||||
<artifactId>cloud-plugin-network-vcs</artifactId>
|
<artifactId>cloud-plugin-network-vcs</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
|
||||||
<artifactId>cloud-plugin-network-vsp</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
<groupId>org.apache.cloudstack</groupId>
|
||||||
<artifactId>cloud-plugin-hypervisor-xenserver</artifactId>
|
<artifactId>cloud-plugin-hypervisor-xenserver</artifactId>
|
||||||
@ -802,7 +797,7 @@
|
|||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!-- Copy the systemvm in the package phase as it is generated by console-proxy in the package
|
<!-- Copy the systemvm in the package phase as it is generated by console-proxy in the package
|
||||||
phase. -->
|
phase. -->
|
||||||
<execution>
|
<execution>
|
||||||
<id>copy-systemvm</id>
|
<id>copy-systemvm</id>
|
||||||
|
|||||||
@ -166,7 +166,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`,
|
|||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVMPassword', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVMPassword', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVirtualMachineUserData', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'getVirtualMachineUserData', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'importLdapUsers', 'ALLOW', 145) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'importLdapUsers', 'ALLOW', 145) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'issueNuageVspResourceRequest', 'ALLOW', 146) ON DUPLICATE KEY UPDATE rule=rule;
|
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'ldapCreateAccount', 'ALLOW', 147) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'ldapCreateAccount', 'ALLOW', 147) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'linkDomainToLdap', 'ALLOW', 148) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'linkDomainToLdap', 'ALLOW', 148) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'listAccounts', 'ALLOW', 149) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 2, 'listAccounts', 'ALLOW', 149) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
@ -479,7 +478,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`,
|
|||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getUploadParamsForVolume', 'ALLOW', 138) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getUploadParamsForVolume', 'ALLOW', 138) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVMPassword', 'ALLOW', 139) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVMPassword', 'ALLOW', 139) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVirtualMachineUserData', 'ALLOW', 140) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'getVirtualMachineUserData', 'ALLOW', 140) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'issueNuageVspResourceRequest', 'ALLOW', 141) ON DUPLICATE KEY UPDATE rule=rule;
|
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAccounts', 'ALLOW', 142) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAccounts', 'ALLOW', 142) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroupTypes', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroupTypes', 'ALLOW', 143) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroups', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 3, 'listAffinityGroups', 'ALLOW', 144) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
@ -759,7 +757,6 @@ INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`,
|
|||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getUploadParamsForVolume', 'ALLOW', 116) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getUploadParamsForVolume', 'ALLOW', 116) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVMPassword', 'ALLOW', 117) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVMPassword', 'ALLOW', 117) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVirtualMachineUserData', 'ALLOW', 118) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'getVirtualMachineUserData', 'ALLOW', 118) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'issueNuageVspResourceRequest', 'ALLOW', 119) ON DUPLICATE KEY UPDATE rule=rule;
|
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAccounts', 'ALLOW', 120) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAccounts', 'ALLOW', 120) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroupTypes', 'ALLOW', 121) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroupTypes', 'ALLOW', 121) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroups', 'ALLOW', 122) ON DUPLICATE KEY UPDATE rule=rule;
|
INSERT INTO `cloud`.`role_permissions` (`uuid`, `role_id`, `rule`, `permission`, `sort_order`) values (UUID(), 4, 'listAffinityGroups', 'ALLOW', 122) ON DUPLICATE KEY UPDATE rule=rule;
|
||||||
|
|||||||
@ -25,3 +25,8 @@ DROP TABLE IF EXISTS `cloud`.`iam_group_policy_map`;
|
|||||||
DROP TABLE IF EXISTS `cloud`.`iam_group`;
|
DROP TABLE IF EXISTS `cloud`.`iam_group`;
|
||||||
DROP TABLE IF EXISTS `cloud`.`iam_policy_permission`;
|
DROP TABLE IF EXISTS `cloud`.`iam_policy_permission`;
|
||||||
DROP TABLE IF EXISTS `cloud`.`iam_policy`;
|
DROP TABLE IF EXISTS `cloud`.`iam_policy`;
|
||||||
|
|
||||||
|
-- Cleanup Nuage VSP
|
||||||
|
DELETE FROM `cloud`.`host` WHERE id in (SELECT vsp.host_id FROM `cloud`.`external_nuage_vsp_devices` vsp);
|
||||||
|
DROP TABLE IF EXISTS `cloud`.`external_nuage_vsp_devices`;
|
||||||
|
delete from `cloud`.`role_permissions` where rule = 'issueNuageVspResourceRequest';
|
||||||
|
|||||||
@ -2491,16 +2491,6 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
|
private void createVif(final LibvirtVMDef vm, final NicTO nic, final String nicAdapter, Map<String, String> extraConfig) throws InternalErrorException, LibvirtException {
|
||||||
|
|
||||||
if (nic.getType().equals(TrafficType.Guest) && nic.getBroadcastType().equals(BroadcastDomainType.Vsp)) {
|
|
||||||
String vrIp = nic.getBroadcastUri().getPath().substring(1);
|
|
||||||
vm.getMetaData().getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension(nic.getMac(), vrIp);
|
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NIC with MAC " + nic.getMac() + " and BroadcastDomainType " + nic.getBroadcastType() + " in network(" + nic.getGateway() + "/" + nic.getNetmask()
|
|
||||||
+ ") is " + nic.getType() + " traffic type. So, vsp-vr-ip " + vrIp + " is set in the metadata");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vm.getDevices() == null) {
|
if (vm.getDevices() == null) {
|
||||||
s_logger.error("LibvirtVMDef object get devices with null result");
|
s_logger.error("LibvirtVMDef object get devices with null result");
|
||||||
throw new InternalErrorException("LibvirtVMDef object get devices with null result");
|
throw new InternalErrorException("LibvirtVMDef object get devices with null result");
|
||||||
|
|||||||
@ -26,8 +26,6 @@ import org.apache.commons.lang.StringEscapeUtils;
|
|||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
public class LibvirtVMDef {
|
public class LibvirtVMDef {
|
||||||
private static final Logger s_logger = Logger.getLogger(LibvirtVMDef.class);
|
private static final Logger s_logger = Logger.getLogger(LibvirtVMDef.class);
|
||||||
|
|
||||||
@ -1665,28 +1663,6 @@ public class LibvirtVMDef {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NuageExtensionDef {
|
|
||||||
private Map<String, String> addresses = Maps.newHashMap();
|
|
||||||
|
|
||||||
public void addNuageExtension(String macAddress, String vrIp) {
|
|
||||||
addresses.put(macAddress, vrIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
StringBuilder fsBuilder = new StringBuilder();
|
|
||||||
fsBuilder.append("<nuage-extension xmlns='nuagenetworks.net/nuage/cna'>\n");
|
|
||||||
for (Map.Entry<String, String> address : addresses.entrySet()) {
|
|
||||||
fsBuilder.append(" <interface mac='")
|
|
||||||
.append(address.getKey())
|
|
||||||
.append("' vsp-vr-ip='")
|
|
||||||
.append(address.getValue())
|
|
||||||
.append("'></interface>\n");
|
|
||||||
}
|
|
||||||
return fsBuilder.append("</nuage-extension>\n").toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class RngDef {
|
public static class RngDef {
|
||||||
enum RngModel {
|
enum RngModel {
|
||||||
VIRTIO("virtio");
|
VIRTIO("virtio");
|
||||||
|
|||||||
@ -183,10 +183,6 @@ public class OvsVifDriver extends VifDriverBase {
|
|||||||
String brName = "OVSTunnel" + vnetId;
|
String brName = "OVSTunnel" + vnetId;
|
||||||
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + brName);
|
s_logger.debug("nic " + nic + " needs to be connected to LogicalSwitch " + brName);
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
|
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
|
||||||
} else if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vsp) {
|
|
||||||
intf.setVirtualPortInterfaceId(nic.getUuid());
|
|
||||||
String brName = (trafficLabel != null && !trafficLabel.isEmpty()) ? _pifs.get(trafficLabel) : _pifs.get("private");
|
|
||||||
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
|
|
||||||
} else {
|
} else {
|
||||||
intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
|
intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -292,23 +292,4 @@ public class LibvirtVMDefTest extends TestCase {
|
|||||||
"</controller>\n";
|
"</controller>\n";
|
||||||
assertEquals(str, expected);
|
assertEquals(str, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testMetadataDef() {
|
|
||||||
LibvirtVMDef.MetadataDef metadataDef = new LibvirtVMDef.MetadataDef();
|
|
||||||
|
|
||||||
metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac1", "ip1");
|
|
||||||
metadataDef.getMetadataNode(LibvirtVMDef.NuageExtensionDef.class).addNuageExtension("mac2", "ip2");
|
|
||||||
|
|
||||||
String xmlDef = metadataDef.toString();
|
|
||||||
String expectedXml = "<metadata>\n" +
|
|
||||||
"<nuage-extension xmlns='nuagenetworks.net/nuage/cna'>\n" +
|
|
||||||
" <interface mac='mac2' vsp-vr-ip='ip2'></interface>\n" +
|
|
||||||
" <interface mac='mac1' vsp-vr-ip='ip1'></interface>\n" +
|
|
||||||
"</nuage-extension>\n" +
|
|
||||||
"</metadata>\n";
|
|
||||||
|
|
||||||
assertEquals(xmlDef, expectedXml);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,6 +56,7 @@ import com.cloud.vm.VirtualMachine;
|
|||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest(value = {Script.class, MemStat.class})
|
@PrepareForTest(value = {Script.class, MemStat.class})
|
||||||
public class LibvirtReplugNicCommandWrapperTest {
|
public class LibvirtReplugNicCommandWrapperTest {
|
||||||
|
|
||||||
private static final String part_1 =
|
private static final String part_1 =
|
||||||
"<domain type='kvm' id='143'>\n"
|
"<domain type='kvm' id='143'>\n"
|
||||||
+ " <name>i-85-285-VM</name>\n"
|
+ " <name>i-85-285-VM</name>\n"
|
||||||
@ -180,6 +181,7 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
+ "</domain>\n";
|
+ "</domain>\n";
|
||||||
|
|
||||||
private static final String fullfile = part_1 + part_2 + part_3;
|
private static final String fullfile = part_1 + part_2 + part_3;
|
||||||
|
public static final String GUEST_BR = "guestbr0";
|
||||||
|
|
||||||
private LibvirtComputingResource res;
|
private LibvirtComputingResource res;
|
||||||
private final Domain _domain = mock(Domain.class);
|
private final Domain _domain = mock(Domain.class);
|
||||||
@ -213,7 +215,7 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
BDDMockito.given(Script.findScript(anyString(), anyString())).willReturn("dummypath/tofile.sh");
|
BDDMockito.given(Script.findScript(anyString(), anyString())).willReturn("dummypath/tofile.sh");
|
||||||
|
|
||||||
Map<String, String> pifs = new HashMap<>();
|
Map<String, String> pifs = new HashMap<>();
|
||||||
pifs.put("alubr0", "alubr0");
|
pifs.put(GUEST_BR, "eth0");
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
params.put("libvirt.computing.resource", res);
|
params.put("libvirt.computing.resource", res);
|
||||||
@ -227,7 +229,7 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
|
|
||||||
doReturn(helper).when(res).getLibvirtUtilitiesHelper();
|
doReturn(helper).when(res).getLibvirtUtilitiesHelper();
|
||||||
doReturn(bridgeVifDriver).when(res).getVifDriver(eq(Networks.TrafficType.Guest), anyString());
|
doReturn(bridgeVifDriver).when(res).getVifDriver(eq(Networks.TrafficType.Guest), anyString());
|
||||||
doReturn(ovsVifDriver).when(res).getVifDriver(Networks.TrafficType.Guest, "alubr0");
|
doReturn(ovsVifDriver).when(res).getVifDriver(Networks.TrafficType.Guest, GUEST_BR);
|
||||||
doReturn(bridgeVifDriver).when(res).getVifDriver(not(eq(Networks.TrafficType.Guest)));
|
doReturn(bridgeVifDriver).when(res).getVifDriver(not(eq(Networks.TrafficType.Guest)));
|
||||||
doReturn(Arrays.asList(bridgeVifDriver, ovsVifDriver)).when(res).getAllVifDrivers();
|
doReturn(Arrays.asList(bridgeVifDriver, ovsVifDriver)).when(res).getAllVifDrivers();
|
||||||
|
|
||||||
@ -237,7 +239,6 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testReplugNic() throws LibvirtException {
|
public void testReplugNic() throws LibvirtException {
|
||||||
|
|
||||||
final String expectedDetachXml =
|
final String expectedDetachXml =
|
||||||
"<interface type='bridge'>\n"
|
"<interface type='bridge'>\n"
|
||||||
+ "<source bridge='breth2-234'/>\n"
|
+ "<source bridge='breth2-234'/>\n"
|
||||||
@ -248,23 +249,29 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
+ "</interface>\n";
|
+ "</interface>\n";
|
||||||
final String expectedAttachXml =
|
final String expectedAttachXml =
|
||||||
"<interface type='bridge'>\n"
|
"<interface type='bridge'>\n"
|
||||||
+ "<source bridge='alubr0'/>\n"
|
+ "<source bridge='eth0'/>\n"
|
||||||
+ "<target dev='vnet10'/>\n"
|
+ "<target dev='vnet10'/>\n"
|
||||||
+ "<mac address='02:00:7c:98:00:02'/>\n"
|
+ "<mac address='02:00:7c:98:00:02'/>\n"
|
||||||
+ "<model type='virtio'/>\n"
|
+ "<model type='virtio'/>\n"
|
||||||
+ "<virtualport type='openvswitch'>\n"
|
+ "<virtualport type='openvswitch'>\n"
|
||||||
+ "</virtualport>\n"
|
+ "</virtualport>\n"
|
||||||
|
+ "<vlan trunk='no'>\n"
|
||||||
|
+ "<tag id='100'/>\n"
|
||||||
|
+ "</vlan>"
|
||||||
+ "<link state='down'/>\n"
|
+ "<link state='down'/>\n"
|
||||||
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n"
|
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n"
|
||||||
+ "</interface>\n";
|
+ "</interface>\n";
|
||||||
final String expectedUpdateXml =
|
final String expectedUpdateXml =
|
||||||
"<interface type='bridge'>\n"
|
"<interface type='bridge'>\n"
|
||||||
+ "<source bridge='alubr0'/>\n"
|
+ "<source bridge='eth0'/>\n"
|
||||||
+ "<target dev='vnet10'/>\n"
|
+ "<target dev='vnet10'/>\n"
|
||||||
+ "<mac address='02:00:7c:98:00:02'/>\n"
|
+ "<mac address='02:00:7c:98:00:02'/>\n"
|
||||||
+ "<model type='virtio'/>\n"
|
+ "<model type='virtio'/>\n"
|
||||||
+ "<virtualport type='openvswitch'>\n"
|
+ "<virtualport type='openvswitch'>\n"
|
||||||
+ "</virtualport>\n"
|
+ "</virtualport>\n"
|
||||||
|
+ "<vlan trunk='no'>\n"
|
||||||
|
+ "<tag id='100'/>\n"
|
||||||
|
+ "</vlan>"
|
||||||
+ "<link state='up'/>\n"
|
+ "<link state='up'/>\n"
|
||||||
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n"
|
+ "<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>\n"
|
||||||
+ "</interface>\n";
|
+ "</interface>\n";
|
||||||
@ -272,9 +279,10 @@ public class LibvirtReplugNicCommandWrapperTest {
|
|||||||
final LibvirtReplugNicCommandWrapper wrapper = new LibvirtReplugNicCommandWrapper();
|
final LibvirtReplugNicCommandWrapper wrapper = new LibvirtReplugNicCommandWrapper();
|
||||||
final NicTO nic = new NicTO();
|
final NicTO nic = new NicTO();
|
||||||
nic.setType(Networks.TrafficType.Guest);
|
nic.setType(Networks.TrafficType.Guest);
|
||||||
nic.setName("alubr0");
|
nic.setName(GUEST_BR);
|
||||||
nic.setBroadcastType(Networks.BroadcastDomainType.Vsp);
|
nic.setBroadcastType(Networks.BroadcastDomainType.Vlan);
|
||||||
nic.setMac("02:00:7c:98:00:02");
|
nic.setMac("02:00:7c:98:00:02");
|
||||||
|
nic.setBroadcastUri(Networks.BroadcastDomainType.Vlan.toUri(100));
|
||||||
final ReplugNicCommand command = new ReplugNicCommand(nic, "i-85-285-VM", VirtualMachine.Type.User);
|
final ReplugNicCommand command = new ReplugNicCommand(nic, "i-85-285-VM", VirtualMachine.Type.User);
|
||||||
final Answer result = wrapper.execute(command, res);
|
final Answer result = wrapper.execute(command, res);
|
||||||
|
|
||||||
|
|||||||
@ -1171,7 +1171,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
|
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
|
||||||
|
|
||||||
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
||||||
setNuageVspVrIpInExtraConfig(vmConfigSpec.getExtraConfig(), nicTo, dvSwitchUuid);
|
|
||||||
if (!vmMo.configureVm(vmConfigSpec)) {
|
if (!vmMo.configureVm(vmConfigSpec)) {
|
||||||
throw new Exception("Failed to configure devices when running PlugNicCommand");
|
throw new Exception("Failed to configure devices when running PlugNicCommand");
|
||||||
}
|
}
|
||||||
@ -1252,7 +1251,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
|
deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
|
||||||
|
|
||||||
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
vmConfigSpec.getDeviceChange().add(deviceConfigSpec);
|
||||||
setNuageVspVrIpInExtraConfig(vmConfigSpec.getExtraConfig(), nicTo, dvSwitchUuid);
|
|
||||||
if (!vmMo.configureVm(vmConfigSpec)) {
|
if (!vmMo.configureVm(vmConfigSpec)) {
|
||||||
throw new Exception("Failed to configure devices when running ReplugNicCommand");
|
throw new Exception("Failed to configure devices when running ReplugNicCommand");
|
||||||
}
|
}
|
||||||
@ -2632,36 +2630,11 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
newVal.setKey("nvp.iface-id." + nicNum);
|
newVal.setKey("nvp.iface-id." + nicNum);
|
||||||
newVal.setValue(nicTo.getUuid());
|
newVal.setValue(nicTo.getUuid());
|
||||||
extraOptions.add(newVal);
|
extraOptions.add(newVal);
|
||||||
setNuageVspVrIpInExtraConfig(extraOptions, nicTo, nicUuidToDvSwitchUuid.get(nicTo.getUuid()));
|
|
||||||
}
|
}
|
||||||
nicNum++;
|
nicNum++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setNuageVspVrIpInExtraConfig(List<OptionValue> extraOptions, NicTO nicTo, String dvSwitchUuid) {
|
|
||||||
if (nicTo.getBroadcastType() != BroadcastDomainType.Vsp) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
OptionValue newVal;
|
|
||||||
if (nicTo.getType().equals(TrafficType.Guest) && dvSwitchUuid != null && nicTo.getGateway() != null && nicTo.getNetmask() != null) {
|
|
||||||
String vrIp = nicTo.getBroadcastUri().getPath().substring(1);
|
|
||||||
newVal = new OptionValue();
|
|
||||||
newVal.setKey("vsp.vr-ip." + nicTo.getMac());
|
|
||||||
newVal.setValue(vrIp);
|
|
||||||
extraOptions.add(newVal);
|
|
||||||
newVal = new OptionValue();
|
|
||||||
newVal.setKey("vsp.dvswitch." + nicTo.getMac());
|
|
||||||
newVal.setValue(dvSwitchUuid);
|
|
||||||
extraOptions.add(newVal);
|
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NIC with MAC " + nicTo.getMac() + " and BroadcastDomainType " + nicTo.getBroadcastType() + " in network(" + nicTo.getGateway() + "/"
|
|
||||||
+ nicTo.getNetmask() + ") is " + nicTo.getType() + " traffic type. So, vsp-vr-ip is set in the extraconfig");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void configCustomExtraOption(List<OptionValue> extraOptions, VirtualMachineTO vmSpec) {
|
private static void configCustomExtraOption(List<OptionValue> extraOptions, VirtualMachineTO vmSpec) {
|
||||||
// we no longer to validation anymore
|
// we no longer to validation anymore
|
||||||
for (Map.Entry<String, String> entry : vmSpec.getDetails().entrySet()) {
|
for (Map.Entry<String, String> entry : vmSpec.getDetails().entrySet()) {
|
||||||
|
|||||||
@ -1225,14 +1225,6 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
// group VIF's & tunnel ports as part of tier
|
// group VIF's & tunnel ports as part of tier
|
||||||
// when bridge is setup for distributed routing
|
// when bridge is setup for distributed routing
|
||||||
vifr.otherConfig.put("cloudstack-network-id", nic.getNetworkUuid());
|
vifr.otherConfig.put("cloudstack-network-id", nic.getNetworkUuid());
|
||||||
|
|
||||||
// Nuage Vsp needs Virtual Router IP to be passed in the otherconfig
|
|
||||||
// get the virtual router IP information from broadcast uri
|
|
||||||
final URI broadcastUri = nic.getBroadcastUri();
|
|
||||||
if (broadcastUri != null && broadcastUri.getScheme().equalsIgnoreCase(Networks.BroadcastDomainType.Vsp.scheme())) {
|
|
||||||
final String path = broadcastUri.getPath();
|
|
||||||
vifr.otherConfig.put("vsp-vr-ip", path.substring(1));
|
|
||||||
}
|
|
||||||
vifr.network = getNetwork(conn, nic);
|
vifr.network = getNetwork(conn, nic);
|
||||||
|
|
||||||
if (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) {
|
if (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) {
|
||||||
@ -2776,7 +2768,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Vlan;
|
assert BroadcastDomainType.getSchemeValue(uri) == BroadcastDomainType.Vlan;
|
||||||
final long vlan = Long.parseLong(BroadcastDomainType.getValue(uri));
|
final long vlan = Long.parseLong(BroadcastDomainType.getValue(uri));
|
||||||
return enableVlanNetwork(conn, vlan, network);
|
return enableVlanNetwork(conn, vlan, network);
|
||||||
} else if (type == BroadcastDomainType.Native || type == BroadcastDomainType.LinkLocal || type == BroadcastDomainType.Vsp) {
|
} else if (type == BroadcastDomainType.Native || type == BroadcastDomainType.LinkLocal) {
|
||||||
return network.getNetwork();
|
return network.getNetwork();
|
||||||
} else if (uri != null && type == BroadcastDomainType.Vswitch) {
|
} else if (uri != null && type == BroadcastDomainType.Vswitch) {
|
||||||
final String header = uri.toString().substring(Networks.BroadcastDomainType.Vswitch.scheme().length() + "://".length());
|
final String header = uri.toString().substring(Networks.BroadcastDomainType.Vswitch.scheme().length() + "://".length());
|
||||||
|
|||||||
@ -1,46 +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-vsp</artifactId>
|
|
||||||
<name>Apache CloudStack Plugin - Nuage VSP</name>
|
|
||||||
<parent>
|
|
||||||
<groupId>org.apache.cloudstack</groupId>
|
|
||||||
<artifactId>cloudstack-plugins</artifactId>
|
|
||||||
<version>4.13.0.0-SNAPSHOT</version>
|
|
||||||
<relativePath>../../pom.xml</relativePath>
|
|
||||||
</parent>
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>nuage-vsp</id>
|
|
||||||
<url>http://cs.mv.nuagenetworks.net/releases/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
<properties>
|
|
||||||
<nuage.vsp.client.version>1.0.8</nuage.vsp.client.version>
|
|
||||||
</properties>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.nuagenetworks.vsp</groupId>
|
|
||||||
<artifactId>nuage-vsp-acs-client</artifactId>
|
|
||||||
<version>${nuage.vsp.client.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@ -1,24 +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.agent.api;
|
|
||||||
|
|
||||||
public interface CmdBuilder<T> {
|
|
||||||
T build();
|
|
||||||
}
|
|
||||||
@ -1,57 +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.agent.api;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
|
|
||||||
public class PingNuageVspCommand extends PingCommand {
|
|
||||||
|
|
||||||
private final boolean shouldAudit;
|
|
||||||
|
|
||||||
public PingNuageVspCommand(Host.Type type, long id, boolean shouldAudit) {
|
|
||||||
super(type, id);
|
|
||||||
this.shouldAudit = shouldAudit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean shouldAudit() {
|
|
||||||
return shouldAudit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof PingNuageVspCommand)) return false;
|
|
||||||
|
|
||||||
PingNuageVspCommand that = (PingNuageVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& shouldAudit == that.shouldAudit;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(shouldAudit)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,34 +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.agent.api;
|
|
||||||
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The super class implementations for equals and hashCode are acceptable because this class does not track any state
|
|
||||||
* in addition to the super class.
|
|
||||||
*/
|
|
||||||
public class StartupVspCommand extends StartupCommand {
|
|
||||||
|
|
||||||
public StartupVspCommand() {
|
|
||||||
super(Host.Type.L2Networking);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,96 +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.agent.api.element;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ApplyAclRuleVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspAclRule.ACLType _aclType;
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final List<VspAclRule> _aclRules;
|
|
||||||
private final boolean _networkReset;
|
|
||||||
|
|
||||||
public ApplyAclRuleVspCommand(VspAclRule.ACLType aclType, VspNetwork network, List<VspAclRule> aclRules, boolean networkReset) {
|
|
||||||
super();
|
|
||||||
this._aclType = aclType;
|
|
||||||
this._network = network;
|
|
||||||
this._aclRules = aclRules;
|
|
||||||
this._networkReset = networkReset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspAclRule.ACLType getAclType() {
|
|
||||||
return _aclType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspAclRule> getAclRules() {
|
|
||||||
return _aclRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isNetworkReset() {
|
|
||||||
return _networkReset;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ApplyAclRuleVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyAclRuleVspCommand that = (ApplyAclRuleVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& _networkReset == that._networkReset
|
|
||||||
&& Objects.equals(_aclType, that._aclType)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_aclRules, that._aclRules);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_aclType)
|
|
||||||
.append(_network)
|
|
||||||
.append(_networkReset)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,80 +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.agent.api.element;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ApplyStaticNatVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final List<VspStaticNat> _staticNatDetails;
|
|
||||||
|
|
||||||
public ApplyStaticNatVspCommand(VspNetwork network, List<VspStaticNat> staticNatDetails) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._staticNatDetails = staticNatDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspStaticNat> getStaticNatDetails() {
|
|
||||||
return _staticNatDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ApplyStaticNatVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApplyStaticNatVspCommand that = (ApplyStaticNatVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_staticNatDetails, that._staticNatDetails);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,86 +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.agent.api.element;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ExtraDhcpOptionsVspCommand extends Command {
|
|
||||||
private final VspNetwork network;
|
|
||||||
private final String nicUuid;
|
|
||||||
private final Map<Integer, String> dhcpOptions;
|
|
||||||
|
|
||||||
public ExtraDhcpOptionsVspCommand (VspNetwork network, String nicUuid, Map<Integer, String> dhcpOptions) {
|
|
||||||
super();
|
|
||||||
this.network = network;
|
|
||||||
this.nicUuid = nicUuid;
|
|
||||||
this.dhcpOptions = dhcpOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNicUuid() {
|
|
||||||
return nicUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Integer, String> getDhcpOptions() {
|
|
||||||
return dhcpOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ExtraDhcpOptionsVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ExtraDhcpOptionsVspCommand that = (ExtraDhcpOptionsVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(network, that.network)
|
|
||||||
&& Objects.equals(nicUuid, that.nicUuid)
|
|
||||||
&& Objects.equals(dhcpOptions, that.dhcpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(nicUuid)
|
|
||||||
.append(network)
|
|
||||||
.append(dhcpOptions)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,104 +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.agent.api.element;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ImplementVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final List<VspAclRule> _ingressFirewallRules;
|
|
||||||
private final List<VspAclRule> _egressFirewallRules;
|
|
||||||
private final List<String> _floatingIpUuids;
|
|
||||||
private final VspDhcpDomainOption _dhcpOption;
|
|
||||||
|
|
||||||
public ImplementVspCommand(VspNetwork network, List<VspAclRule> ingressFirewallRules,
|
|
||||||
List<VspAclRule> egressFirewallRules, List<String> floatingIpUuids, VspDhcpDomainOption dhcpOption) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._ingressFirewallRules = ingressFirewallRules;
|
|
||||||
this._egressFirewallRules = egressFirewallRules;
|
|
||||||
this._floatingIpUuids = floatingIpUuids;
|
|
||||||
this._dhcpOption = dhcpOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspAclRule> getIngressFirewallRules() {
|
|
||||||
return _ingressFirewallRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspAclRule> getEgressFirewallRules() {
|
|
||||||
return _egressFirewallRules;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getFloatingIpUuids() {
|
|
||||||
return _floatingIpUuids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDhcpDomainOption getDhcpOption() {
|
|
||||||
return _dhcpOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ImplementVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImplementVspCommand that = (ImplementVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_dhcpOption, that._dhcpOption)
|
|
||||||
&& Objects.equals(_floatingIpUuids, that._floatingIpUuids)
|
|
||||||
&& Objects.equals(_ingressFirewallRules, that._ingressFirewallRules)
|
|
||||||
&& Objects.equals(_egressFirewallRules, that._egressFirewallRules);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.append(_dhcpOption)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,107 +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.agent.api.element;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
|
|
||||||
public class ShutDownVpcVspCommand extends Command {
|
|
||||||
|
|
||||||
private final String _domainUuid;
|
|
||||||
private final String _vpcUuid;
|
|
||||||
private final String _domainTemplateName;
|
|
||||||
private final List<String> _domainRouterUuids;
|
|
||||||
private final NetworkRelatedVsdIds _relatedVsdIds;
|
|
||||||
|
|
||||||
public ShutDownVpcVspCommand(String domainUuid, String vpcUuid, String domainTemplateName, List<String> domainRouterUuids, Map<String, String> details) {
|
|
||||||
super();
|
|
||||||
this._domainUuid = domainUuid;
|
|
||||||
this._vpcUuid = vpcUuid;
|
|
||||||
this._domainTemplateName = domainTemplateName;
|
|
||||||
this._domainRouterUuids = domainRouterUuids;
|
|
||||||
this._relatedVsdIds = new NetworkRelatedVsdIds.Builder()
|
|
||||||
.vsdDomainId(details.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID))
|
|
||||||
.vsdZoneId(details.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID))
|
|
||||||
.withVsdManaged(details.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED) != null && details.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED).equals("true"))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomainUuid() {
|
|
||||||
return _domainUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVpcUuid() {
|
|
||||||
return _vpcUuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomainTemplateName() {
|
|
||||||
return _domainTemplateName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getDomainRouterUuids() {
|
|
||||||
return _domainRouterUuids;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetworkRelatedVsdIds getRelatedVsdIds() {
|
|
||||||
return _relatedVsdIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof ShutDownVpcVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
|
|
||||||
ShutDownVpcVspCommand that = (ShutDownVpcVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_domainUuid, that._domainUuid)
|
|
||||||
&& Objects.equals(_vpcUuid, that._vpcUuid)
|
|
||||||
&& Objects.equals(_domainTemplateName, that._domainTemplateName)
|
|
||||||
&& Objects.equals(_domainRouterUuids, that._domainRouterUuids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_domainUuid)
|
|
||||||
.append(_vpcUuid)
|
|
||||||
.append(_domainTemplateName)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,84 +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.agent.api.element;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ShutDownVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final VspDhcpDomainOption _dhcpOptions;
|
|
||||||
|
|
||||||
public ShutDownVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOptions) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._dhcpOptions = dhcpOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDhcpDomainOption getDhcpOptions() {
|
|
||||||
return _dhcpOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!(o instanceof ShutDownVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShutDownVspCommand that = (ShutDownVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_dhcpOptions, that._dhcpOptions)
|
|
||||||
&& Objects.equals(_network, that._network);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hash(_network, _dhcpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDetailString() {
|
|
||||||
return new ToStringBuilder(this)
|
|
||||||
.append("network", _network)
|
|
||||||
.append("dhcpOptions", _dhcpOptions)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,90 +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.agent.api.guru;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNic;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspVm;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
|
|
||||||
public class DeallocateVmVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final VspVm _vm;
|
|
||||||
private final VspNic _nic;
|
|
||||||
|
|
||||||
public DeallocateVmVspCommand(VspNetwork network, VspVm vm, VspNic nic) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._vm = vm;
|
|
||||||
this._nic = nic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return this._network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspVm getVm() {
|
|
||||||
return this._vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNic getNic() {
|
|
||||||
return this._nic;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof DeallocateVmVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeallocateVmVspCommand that = (DeallocateVmVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_nic, that._nic)
|
|
||||||
&& Objects.equals(_vm, that._vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.append(_vm)
|
|
||||||
.append(_nic)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,94 +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.agent.api.guru;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ImplementNetworkVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final VspDhcpDomainOption _dhcpOption;
|
|
||||||
private final boolean _isVsdManaged;
|
|
||||||
|
|
||||||
public ImplementNetworkVspCommand(VspNetwork network, VspDhcpDomainOption dhcpOption, boolean isVsdManaged) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._dhcpOption = dhcpOption;
|
|
||||||
this._isVsdManaged = isVsdManaged;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDhcpDomainOption getDhcpOption() {
|
|
||||||
return _dhcpOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ImplementNetworkVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImplementNetworkVspCommand that = (ImplementNetworkVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_dhcpOption, that._dhcpOption)
|
|
||||||
&& Objects.equals(_network, that._network);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.append(_dhcpOption)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDetailString() {
|
|
||||||
return new ToStringBuilder(this)
|
|
||||||
.append("network", _network)
|
|
||||||
.append("dhcpOption", _dhcpOption)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVsdManaged() {
|
|
||||||
return _isVsdManaged;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,107 +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.agent.api.guru;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNic;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspVm;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class ReserveVmInterfaceVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
private final VspVm _vm;
|
|
||||||
private final VspNic _nic;
|
|
||||||
private final VspStaticNat _staticNat;
|
|
||||||
private final VspDhcpVMOption _dhcpOption;
|
|
||||||
|
|
||||||
public ReserveVmInterfaceVspCommand(VspNetwork network, VspVm vm, VspNic nic, VspStaticNat staticNat, VspDhcpVMOption dhcpOption) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
this._vm = vm;
|
|
||||||
this._nic = nic;
|
|
||||||
this._staticNat = staticNat;
|
|
||||||
this._dhcpOption = dhcpOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspVm getVm() {
|
|
||||||
return _vm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNic getNic() {
|
|
||||||
return _nic;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspStaticNat getStaticNat() {
|
|
||||||
return _staticNat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDhcpVMOption getDhcpOption() {
|
|
||||||
return _dhcpOption;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof ReserveVmInterfaceVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReserveVmInterfaceVspCommand that = (ReserveVmInterfaceVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_nic, that._nic)
|
|
||||||
&& Objects.equals(_dhcpOption, that._dhcpOption)
|
|
||||||
&& Objects.equals(_staticNat, that._staticNat)
|
|
||||||
&& Objects.equals(_vm, that._vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.append(_vm)
|
|
||||||
.append(_nic)
|
|
||||||
.append(_staticNat)
|
|
||||||
.append(_dhcpOption)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,71 +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.agent.api.guru;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class TrashNetworkVspCommand extends Command {
|
|
||||||
|
|
||||||
private final VspNetwork _network;
|
|
||||||
|
|
||||||
public TrashNetworkVspCommand(VspNetwork network) {
|
|
||||||
super();
|
|
||||||
this._network = network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof TrashNetworkVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
TrashNetworkVspCommand that = (TrashNetworkVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,87 +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.agent.api.guru;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class UpdateDhcpOptionVspCommand extends Command {
|
|
||||||
|
|
||||||
private final List<VspDhcpVMOption> _dhcpOptions;
|
|
||||||
private final VspNetwork _network;
|
|
||||||
|
|
||||||
public UpdateDhcpOptionVspCommand(List<VspDhcpVMOption> dhcpOptions, VspNetwork network) {
|
|
||||||
this._dhcpOptions = dhcpOptions;
|
|
||||||
this._network = network;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspDhcpVMOption> getDhcpOptions() {
|
|
||||||
return _dhcpOptions;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getNetwork() {
|
|
||||||
return _network;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof UpdateDhcpOptionVspCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateDhcpOptionVspCommand that = (UpdateDhcpOptionVspCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_network, that._network)
|
|
||||||
&& Objects.equals(_dhcpOptions, that._dhcpOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_network)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toDetailString() {
|
|
||||||
return new ToStringBuilder(this)
|
|
||||||
.append("network", _network)
|
|
||||||
.append("dhcpOptions", _dhcpOptions)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,72 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp;
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class CleanUpDomainCommand extends Command {
|
|
||||||
|
|
||||||
private final VspDomainCleanUp _domainCleanUp;
|
|
||||||
|
|
||||||
public CleanUpDomainCommand(VspDomainCleanUp domainCleanUp) {
|
|
||||||
super();
|
|
||||||
Preconditions.checkNotNull(domainCleanUp);
|
|
||||||
this._domainCleanUp = domainCleanUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDomainCleanUp getDomainCleanUp() {
|
|
||||||
return _domainCleanUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof CleanUpDomainCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CleanUpDomainCommand that = (CleanUpDomainCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_domainCleanUp, that._domainCleanUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_domainCleanUp)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,85 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class EntityExistsCommand<T> extends Command {
|
|
||||||
|
|
||||||
private transient Class<T> _type;
|
|
||||||
private final String _className;
|
|
||||||
private final String _uuid;
|
|
||||||
|
|
||||||
public EntityExistsCommand(Class<T> type, String uuid) {
|
|
||||||
super();
|
|
||||||
this._type = type;
|
|
||||||
this._className = type.getName();
|
|
||||||
this._uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Class<T> getType() {
|
|
||||||
if (_type == null) {
|
|
||||||
try {
|
|
||||||
_type = (Class<T>)Class.forName(_className);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid() {
|
|
||||||
return _uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof EntityExistsCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityExistsCommand that = (EntityExistsCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(getType(), that.getType())
|
|
||||||
&& Objects.equals(_uuid, that._uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(getType())
|
|
||||||
.append(_uuid)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,70 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspApiDefaults;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
|
|
||||||
public class GetApiDefaultsAnswer extends Answer {
|
|
||||||
|
|
||||||
private VspApiDefaults _apiDefaults;
|
|
||||||
|
|
||||||
public GetApiDefaultsAnswer(GetApiDefaultsCommand cmd, VspApiDefaults defaults) {
|
|
||||||
super(cmd);
|
|
||||||
this._apiDefaults = defaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GetApiDefaultsAnswer(GetApiDefaultsCommand cmd, Exception e) {
|
|
||||||
super(cmd, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspApiDefaults getApiDefaults() {
|
|
||||||
return _apiDefaults;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof GetApiDefaultsAnswer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
GetApiDefaultsAnswer that = (GetApiDefaultsAnswer) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_apiDefaults, that._apiDefaults);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_apiDefaults)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The super class implementations for equals and hashCode are acceptable because this class does not track any state
|
|
||||||
* in addition to the super class.
|
|
||||||
*/
|
|
||||||
public class GetApiDefaultsCommand extends Command {
|
|
||||||
|
|
||||||
public GetApiDefaultsCommand() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,53 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by sgoeminn on 3/24/17.
|
|
||||||
*/
|
|
||||||
public class ImplementNetworkVspAnswer extends Answer {
|
|
||||||
private NetworkRelatedVsdIds networkRelatedVsdIds;
|
|
||||||
|
|
||||||
private VspNetwork vspNetwork;
|
|
||||||
|
|
||||||
public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, VspNetwork vspNetwork, NetworkRelatedVsdIds networkRelatedVsdIds) {
|
|
||||||
super(command);
|
|
||||||
this.vspNetwork = vspNetwork;
|
|
||||||
this.networkRelatedVsdIds = networkRelatedVsdIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ImplementNetworkVspAnswer(ImplementNetworkVspCommand command, Exception e) {
|
|
||||||
super(command, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public NetworkRelatedVsdIds getNetworkRelatedVsdIds() {
|
|
||||||
return networkRelatedVsdIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork getVspNetwork() {
|
|
||||||
return vspNetwork;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,44 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomainTemplate;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public class ListVspDomainTemplatesAnswer extends Answer {
|
|
||||||
private List<VspDomainTemplate> domainTemplates;
|
|
||||||
|
|
||||||
public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, List<VspDomainTemplate> domainTemplates) {
|
|
||||||
super(command);
|
|
||||||
|
|
||||||
this.domainTemplates = domainTemplates;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ListVspDomainTemplatesAnswer(ListVspDomainTemplatesCommand command, Exception e) {
|
|
||||||
super(command, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VspDomainTemplate> getDomainTemplates() {
|
|
||||||
return domainTemplates;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,47 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomain;
|
|
||||||
|
|
||||||
|
|
||||||
public class ListVspDomainTemplatesCommand extends Command {
|
|
||||||
private final VspDomain _domain;
|
|
||||||
private final String _name;
|
|
||||||
|
|
||||||
public ListVspDomainTemplatesCommand(VspDomain domain, String name) {
|
|
||||||
this._domain = domain;
|
|
||||||
this._name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDomain getDomain() {
|
|
||||||
return _domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,70 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class SupportedApiVersionCommand extends Command {
|
|
||||||
|
|
||||||
private final String _apiVersion;
|
|
||||||
|
|
||||||
public SupportedApiVersionCommand(String apiVersion) {
|
|
||||||
super();
|
|
||||||
this._apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApiVersion() {
|
|
||||||
return _apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof SupportedApiVersionCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SupportedApiVersionCommand that = (SupportedApiVersionCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_apiVersion, that._apiVersion);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_apiVersion)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,70 +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.agent.api.manager;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.network.resource.NuageVspResourceConfiguration;
|
|
||||||
|
|
||||||
public class UpdateNuageVspDeviceCommand extends Command {
|
|
||||||
|
|
||||||
private final NuageVspResourceConfiguration configuration;
|
|
||||||
|
|
||||||
public UpdateNuageVspDeviceCommand(NuageVspResourceConfiguration configuration) {
|
|
||||||
super();
|
|
||||||
this.configuration = configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration getConfiguration() {
|
|
||||||
return configuration;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof UpdateNuageVspDeviceCommand)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateNuageVspDeviceCommand that = (UpdateNuageVspDeviceCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(configuration, that.configuration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(configuration)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,64 +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.agent.api.sync;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
|
|
||||||
public class SyncDomainAnswer extends Answer {
|
|
||||||
|
|
||||||
private final boolean _success;
|
|
||||||
|
|
||||||
public SyncDomainAnswer(boolean success) {
|
|
||||||
super();
|
|
||||||
this._success = success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSuccess() {
|
|
||||||
return _success;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof SyncDomainAnswer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncDomainAnswer that = (SyncDomainAnswer) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& _success == that._success;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_success)
|
|
||||||
.toHashCode();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,84 +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.agent.api.sync;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomain;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class SyncDomainCommand extends Command {
|
|
||||||
|
|
||||||
public enum Type { ADD, REMOVE }
|
|
||||||
private final VspDomain _domain;
|
|
||||||
private final Type _action;
|
|
||||||
|
|
||||||
public SyncDomainCommand(VspDomain domain, Type action) {
|
|
||||||
super();
|
|
||||||
this._domain = domain;
|
|
||||||
this._action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDomain getDomain() {
|
|
||||||
return _domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type getAction() {
|
|
||||||
return _action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isToAdd() {
|
|
||||||
return Type.ADD.equals(_action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isToRemove() {
|
|
||||||
return Type.REMOVE.equals(_action);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof SyncDomainCommand)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
|
|
||||||
SyncDomainCommand that = (SyncDomainCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_action, that._action)
|
|
||||||
&& Objects.equals(_domain, that._domain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_domain)
|
|
||||||
.append(_action)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,88 +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.agent.api.sync;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class SyncNuageVspCmsIdAnswer extends Answer {
|
|
||||||
|
|
||||||
private final boolean _success;
|
|
||||||
private final String _nuageVspCmsId;
|
|
||||||
private final SyncNuageVspCmsIdCommand.SyncType _syncType;
|
|
||||||
|
|
||||||
public SyncNuageVspCmsIdAnswer(boolean success, String nuageVspCmsId, SyncNuageVspCmsIdCommand.SyncType syncType) {
|
|
||||||
super();
|
|
||||||
this._success = success;
|
|
||||||
this._nuageVspCmsId = nuageVspCmsId;
|
|
||||||
this._syncType = syncType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncNuageVspCmsIdAnswer(Command command, Exception e, SyncNuageVspCmsIdCommand.SyncType syncType) {
|
|
||||||
super(command, e);
|
|
||||||
this._nuageVspCmsId = null;
|
|
||||||
this._success = false;
|
|
||||||
this._syncType = syncType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getSuccess() {
|
|
||||||
return _success;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNuageVspCmsId() {
|
|
||||||
return _nuageVspCmsId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncNuageVspCmsIdCommand.SyncType getSyncType() {
|
|
||||||
return _syncType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof SyncNuageVspCmsIdAnswer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
SyncNuageVspCmsIdAnswer that = (SyncNuageVspCmsIdAnswer) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& _success == that._success
|
|
||||||
&& Objects.equals(_syncType, that._syncType)
|
|
||||||
&& Objects.equals(_nuageVspCmsId, that._nuageVspCmsId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_syncType)
|
|
||||||
.append(_nuageVspCmsId)
|
|
||||||
.append(_success)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,75 +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.agent.api.sync;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
|
|
||||||
public class SyncNuageVspCmsIdCommand extends Command {
|
|
||||||
|
|
||||||
public static enum SyncType { AUDIT, AUDIT_ONLY, REGISTER, UNREGISTER }
|
|
||||||
|
|
||||||
private final SyncType _syncType;
|
|
||||||
private final String _nuageVspCmsId;
|
|
||||||
|
|
||||||
public SyncNuageVspCmsIdCommand(SyncType syncType, String nuageVspCmsId) {
|
|
||||||
super();
|
|
||||||
this._syncType = syncType;
|
|
||||||
this._nuageVspCmsId = nuageVspCmsId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SyncType getSyncType() {
|
|
||||||
return _syncType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNuageVspCmsId() {
|
|
||||||
return _nuageVspCmsId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeInSequence() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (!(o instanceof SyncNuageVspCmsIdCommand)) return false;
|
|
||||||
if (!super.equals(o)) return false;
|
|
||||||
|
|
||||||
SyncNuageVspCmsIdCommand that = (SyncNuageVspCmsIdCommand) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_syncType, that._syncType)
|
|
||||||
&& Objects.equals(_nuageVspCmsId, that._nuageVspCmsId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_syncType)
|
|
||||||
.append(_nuageVspCmsId)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,182 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDeviceResponse;
|
|
||||||
import com.cloud.event.EventTypes;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
@APICommand(name = AddNuageVspDeviceCmd.APINAME, description = "Adds a Nuage VSP device", responseObject = NuageVspDeviceResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.5",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class AddNuageVspDeviceCmd extends BaseAsyncCmd {
|
|
||||||
public static final String APINAME = "addNuageVspDevice";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = BaseCmd.CommandType.UUID, entityType = PhysicalNetworkResponse.class,
|
|
||||||
required = true, description = "the ID of the physical network in to which Nuage VSP is added")
|
|
||||||
private Long physicalNetworkId;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_PORT, type = CommandType.INTEGER, required = true, description = "the port to communicate to Nuage VSD")
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, required = true, description = "the hostname of the Nuage VSD")
|
|
||||||
private String hostName;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "the user name of the CMS user in Nuage VSD")
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the password of CMS user in Nuage VSD")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_VERSION, type = CommandType.STRING, description = "the version of the API to use to communicate to Nuage VSD")
|
|
||||||
private String apiVersion;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_COUNT, type = CommandType.INTEGER, description = "the number of retries on failure to communicate to Nuage VSD")
|
|
||||||
private Integer apiRetryCount;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_INTERVAL, type = CommandType.LONG, description = "the time to wait after failure before retrying to communicate to Nuage VSD")
|
|
||||||
private Long apiRetryInterval;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() {
|
|
||||||
return physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostName() {
|
|
||||||
return hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHostName(String hostName) {
|
|
||||||
this.hostName = hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApiVersion() {
|
|
||||||
return apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiVersion(String apiVersion) {
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getApiRetryCount() {
|
|
||||||
return apiRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryCount(int apiRetryCount) {
|
|
||||||
this.apiRetryCount = apiRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getApiRetryInterval() {
|
|
||||||
return apiRetryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryInterval(long apiRetryInterval) {
|
|
||||||
this.apiRetryInterval = apiRetryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
NuageVspDeviceVO nuageVspDeviceVO = _nuageVspManager.addNuageVspDevice(this);
|
|
||||||
if (nuageVspDeviceVO != null) {
|
|
||||||
NuageVspDeviceResponse response = _nuageVspManager.createNuageVspDeviceResponse(nuageVspDeviceVO);
|
|
||||||
response.setObjectName("nuagevspdevice");
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nuage VSP device due to internal error.");
|
|
||||||
}
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return EventTypes.EVENT_EXTERNAL_VSP_VSD_ADD;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Adding a Nuage VSD";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,114 +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.api.commands;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
|
||||||
import org.apache.cloudstack.api.response.VpcResponse;
|
|
||||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
|
|
||||||
@APICommand(name = AssociateNuageVspDomainTemplateCmd.APINAME, responseObject = SuccessResponse.class,
|
|
||||||
description = "associate a vpc with a domain template", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User},
|
|
||||||
since = "4.11.0")
|
|
||||||
public class AssociateNuageVspDomainTemplateCmd extends BaseCmd {
|
|
||||||
static final String APINAME = "associateNuageVspDomainTemplate";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.VPC_ID, type = CommandType.UUID, entityType = VpcResponse.class, required = true, description = "VPC ID")
|
|
||||||
private Long vpcId;
|
|
||||||
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_DOMAIN_TEMPLATE, type = CommandType.STRING, required = true, description = "the name of the domain template")
|
|
||||||
private String domainTemplate;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the physical network ID")
|
|
||||||
private Long physicalNetworkId;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, description = "the zone ID")
|
|
||||||
private Long zoneId;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Long getVpcId() {
|
|
||||||
return vpcId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomainTemplate() { return domainTemplate; }
|
|
||||||
|
|
||||||
public Long getZoneId() { return zoneId; }
|
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() { return physicalNetworkId; }
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
_nuageVspManager.associateNuageVspDomainTemplate(this);
|
|
||||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
response.setSuccess(true);
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,110 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDeviceResponse;
|
|
||||||
import com.cloud.event.EventTypes;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
@APICommand(name = DeleteNuageVspDeviceCmd.APINAME, description = "delete a nuage vsp device", responseObject = SuccessResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.5",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class DeleteNuageVspDeviceCmd extends BaseAsyncCmd {
|
|
||||||
public static final String APINAME = "deleteNuageVspDevice";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_DEVICE_ID, type = CommandType.UUID, entityType = NuageVspDeviceResponse.class, required = true, description = "Nuage device ID")
|
|
||||||
private Long nuageVspDeviceId;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Long getNuageVspDeviceId() {
|
|
||||||
return nuageVspDeviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
boolean result = _nuageVspManager.deleteNuageVspDevice(this);
|
|
||||||
if (result) {
|
|
||||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete Nuage device.");
|
|
||||||
}
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return EventTypes.EVENT_EXTERNAL_VSP_VSD_DELETE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Deleting Nuage VSD";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,110 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
|
||||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
@APICommand(name = DisableNuageUnderlayVlanIpRangeCmd.APINAME, description = "disable Nuage underlay on vlan ip range", responseObject = SuccessResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.10",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class DisableNuageUnderlayVlanIpRangeCmd extends BaseAsyncCmd {
|
|
||||||
public static final String APINAME = "disableNuageUnderlayVlanIpRange";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VlanIpRangeResponse.class, required = true, description = "VLAN IP Range ID")
|
|
||||||
private long vlanIpRangeId;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public long getVlanIpRangeId() {
|
|
||||||
return vlanIpRangeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
boolean result = _nuageVspManager.updateNuageUnderlayVlanIpRange(vlanIpRangeId, false);
|
|
||||||
if (result) {
|
|
||||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to disable underlay, VLAN IP range is already pushed to the Nuage VSP device.");
|
|
||||||
}
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return "VLAN.DISABLE.NUAGE.UNDERLAY";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Disable VLAN IP range Nuage underlay";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,110 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
|
||||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
@APICommand(name = EnableNuageUnderlayVlanIpRangeCmd.APINAME, description = "enable Nuage underlay on vlan ip range", responseObject = SuccessResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.10",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class EnableNuageUnderlayVlanIpRangeCmd extends BaseAsyncCmd {
|
|
||||||
public static final String APINAME = "enableNuageUnderlayVlanIpRange";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = VlanIpRangeResponse.class, required = true, description = "VLAN IP Range ID")
|
|
||||||
private long vlanIpRangeId;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public long getVlanIpRangeId() {
|
|
||||||
return vlanIpRangeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
boolean result = _nuageVspManager.updateNuageUnderlayVlanIpRange(vlanIpRangeId, true);
|
|
||||||
if (result) {
|
|
||||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable underlay, VLAN IP range is already pushed to the Nuage VSP device.");
|
|
||||||
}
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return "VLAN.ENABLE.NUAGE.UNDERLAY";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Enable VLAN IP range Nuage underlay";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,80 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVlanIpRangeResponse;
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.command.admin.vlan.ListVlanIpRangesCmd;
|
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@APICommand(name = "listNuageUnderlayVlanIpRanges", description = "enable Nuage underlay on vlan ip range", responseObject = NuageVlanIpRangeResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.10",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class ListNuageUnderlayVlanIpRangesCmd extends ListVlanIpRangesCmd {
|
|
||||||
public static final String APINAME = "listNuageUnderlayVlanIpRanges";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_UNDERLAY, type = CommandType.BOOLEAN, description = "true to list only underlay enabled, false if not, empty for all")
|
|
||||||
private Boolean underlay;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Boolean getUnderlay() {
|
|
||||||
return underlay;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() {
|
|
||||||
Pair<List<? extends Vlan>, Integer> vlans = _mgr.searchForVlans(this);
|
|
||||||
ListResponse<NuageVlanIpRangeResponse> response = new ListResponse<NuageVlanIpRangeResponse>();
|
|
||||||
List<NuageVlanIpRangeResponse> vlanIpRanges = _nuageVspManager.filterNuageVlanIpRanges(vlans.first(), underlay);
|
|
||||||
response.setResponses(vlanIpRanges);
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,111 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDeviceResponse;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseListCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@APICommand(name = ListNuageVspDevicesCmd.APINAME, description = "Lists Nuage VSP devices", responseObject = NuageVspDeviceResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.5",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class ListNuageVspDevicesCmd extends BaseListCmd {
|
|
||||||
public static final String APINAME = "listNuageVspDevices";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class, description = "the Physical Network ID")
|
|
||||||
private Long physicalNetworkId;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_DEVICE_ID, type = CommandType.UUID, entityType = NuageVspDeviceResponse.class, description = "the Nuage VSP device ID")
|
|
||||||
private Long nuageVspDeviceId;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Long getNuageVspDeviceId() {
|
|
||||||
return nuageVspDeviceId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() {
|
|
||||||
return physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
List<NuageVspDeviceVO> nuageDevices = _nuageVspManager.listNuageVspDevices(this);
|
|
||||||
ListResponse<NuageVspDeviceResponse> response = new ListResponse<NuageVspDeviceResponse>();
|
|
||||||
List<NuageVspDeviceResponse> nuageDevicesResponse = new ArrayList<NuageVspDeviceResponse>();
|
|
||||||
|
|
||||||
if (nuageDevices != null && !nuageDevices.isEmpty()) {
|
|
||||||
for (NuageVspDeviceVO nuageDeviceVO : nuageDevices) {
|
|
||||||
NuageVspDeviceResponse nuageDeviceResponse = _nuageVspManager.createNuageVspDeviceResponse(nuageDeviceVO);
|
|
||||||
nuageDevicesResponse.add(nuageDeviceResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
response.setResponses(nuageDevicesResponse);
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,120 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDomainTemplateResponse;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.DomainResponse;
|
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
|
||||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@APICommand(name = ListNuageVspDomainTemplatesCmd.APINAME, responseObject = BaseResponse.class, description = "Lists Nuage VSP domain templates", since = "4.11.0", responseHasSensitiveInfo = false, authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User})
|
|
||||||
public class ListNuageVspDomainTemplatesCmd extends BaseCmd {
|
|
||||||
static final String APINAME = "listNuageVspDomainTemplates";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class,
|
|
||||||
description = "the domain ID")
|
|
||||||
private Long domainId;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = CommandType.UUID, entityType = PhysicalNetworkResponse.class,
|
|
||||||
description = "the physical network ID")
|
|
||||||
private Long physicalNetworkId;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class,
|
|
||||||
description = "the zone ID")
|
|
||||||
private Long zoneId;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.KEYWORD, type = CommandType.STRING,
|
|
||||||
description = "filters the domain templates which contain the keyword")
|
|
||||||
private String keyword;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public String getKeyword() {
|
|
||||||
return keyword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getDomainId() {
|
|
||||||
return domainId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() {
|
|
||||||
return physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getZoneId() { return zoneId; }
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
List<NuageVspDomainTemplateResponse> responses = _nuageVspManager.listNuageVspDomainTemplates(this);
|
|
||||||
ListResponse<NuageVspDomainTemplateResponse> response = new ListResponse<>();
|
|
||||||
response.setResponses(responses);
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException e) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public long getEntityOwnerId() {
|
|
||||||
return 0; //not owned by anyone
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@ -1,81 +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.api.commands;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.ListResponse;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDomainTemplateResponse;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.NetworkRuleConflictException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
|
|
||||||
@APICommand(name = ListNuageVspGlobalDomainTemplateCmd.APINAME, responseObject = BaseResponse.class,
|
|
||||||
description = "Lists Nuage VSP domain templates", authorized = {RoleType.Admin, RoleType.DomainAdmin, RoleType.User},
|
|
||||||
since = "4.11.0")
|
|
||||||
public class ListNuageVspGlobalDomainTemplateCmd extends BaseCmd {
|
|
||||||
static final String APINAME = "listNuageVspGlobalDomainTemplate";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
|
|
||||||
try {
|
|
||||||
List<NuageVspDomainTemplateResponse> responses = new LinkedList<>();
|
|
||||||
NuageVspDomainTemplateResponse answer = new NuageVspDomainTemplateResponse(_nuageVspManager.NuageVspVpcDomainTemplateName.value(),_nuageVspManager.NuageVspVpcDomainTemplateName.value());
|
|
||||||
responses.add(answer);
|
|
||||||
|
|
||||||
ListResponse<NuageVspDomainTemplateResponse> response = new ListResponse<>();
|
|
||||||
response.setResponses(responses);
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException e) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public long getEntityOwnerId() {
|
|
||||||
return Account.ACCOUNT_ID_SYSTEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,182 +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.api.commands;
|
|
||||||
|
|
||||||
import com.cloud.api.response.NuageVspDeviceResponse;
|
|
||||||
import com.cloud.event.EventTypes;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.InvalidParameterValueException;
|
|
||||||
import com.cloud.exception.ResourceAllocationException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.acl.RoleType;
|
|
||||||
import org.apache.cloudstack.api.APICommand;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.ApiErrorCode;
|
|
||||||
import org.apache.cloudstack.api.BaseAsyncCmd;
|
|
||||||
import org.apache.cloudstack.api.BaseCmd;
|
|
||||||
import org.apache.cloudstack.api.Parameter;
|
|
||||||
import org.apache.cloudstack.api.ServerApiException;
|
|
||||||
import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
|
|
||||||
import org.apache.cloudstack.context.CallContext;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
@APICommand(name = UpdateNuageVspDeviceCmd.APINAME, description = "Update a Nuage VSP device", responseObject = NuageVspDeviceResponse.class,
|
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false,
|
|
||||||
since = "4.6",
|
|
||||||
authorized = {RoleType.Admin})
|
|
||||||
public class UpdateNuageVspDeviceCmd extends BaseAsyncCmd {
|
|
||||||
public static final String APINAME = "updateNuageVspDevice";
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
//////////////// API parameters /////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PHYSICAL_NETWORK_ID, type = BaseCmd.CommandType.UUID, entityType = PhysicalNetworkResponse.class,
|
|
||||||
required = true, description = "the ID of the physical network in to which Nuage VSP is added")
|
|
||||||
private Long physicalNetworkId;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_PORT, type = CommandType.INTEGER, description = "the port to communicate to Nuage VSD")
|
|
||||||
private Integer port;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.HOST_NAME, type = CommandType.STRING, description = "the hostname of the Nuage VSD")
|
|
||||||
private String hostName;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the user name of the CMS user in Nuage VSD")
|
|
||||||
private String userName;
|
|
||||||
|
|
||||||
@Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "the password of CMS user in Nuage VSD")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_VERSION, type = CommandType.STRING, description = "the version of the API to use to communicate to Nuage VSD")
|
|
||||||
private String apiVersion;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_COUNT, type = CommandType.INTEGER, description = "the number of retries on failure to communicate to Nuage VSD")
|
|
||||||
private Integer apiRetryCount;
|
|
||||||
|
|
||||||
@Parameter(name = VspConstants.NUAGE_VSP_API_RETRY_INTERVAL, type = CommandType.LONG, description = "the time to wait after failure before retrying to communicate to Nuage VSD")
|
|
||||||
private Long apiRetryInterval;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////////// Accessors ///////////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public Long getPhysicalNetworkId() {
|
|
||||||
return physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPort() {
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(Integer port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getHostName() {
|
|
||||||
return hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHostName(String hostName) {
|
|
||||||
this.hostName = hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserName() {
|
|
||||||
return userName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApiVersion() {
|
|
||||||
return apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiVersion(String apiVersion) {
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getApiRetryCount() {
|
|
||||||
return apiRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryCount(Integer apiRetryCount) {
|
|
||||||
this.apiRetryCount = apiRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getApiRetryInterval() {
|
|
||||||
return apiRetryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryInterval(Long apiRetryInterval) {
|
|
||||||
this.apiRetryInterval = apiRetryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
/////////////// API Implementation///////////////////
|
|
||||||
/////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
|
|
||||||
try {
|
|
||||||
NuageVspDeviceVO nuageVspDeviceVO = _nuageVspManager.updateNuageVspDevice(this);
|
|
||||||
if (nuageVspDeviceVO != null) {
|
|
||||||
NuageVspDeviceResponse response = _nuageVspManager.createNuageVspDeviceResponse(nuageVspDeviceVO);
|
|
||||||
response.setObjectName("nuagevspdevice");
|
|
||||||
response.setResponseName(getCommandName());
|
|
||||||
this.setResponseObject(response);
|
|
||||||
} else {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Nuage VSP device due to internal error.");
|
|
||||||
}
|
|
||||||
} catch (InvalidParameterValueException invalidParamExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
|
|
||||||
} catch (CloudRuntimeException runtimeExcp) {
|
|
||||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getEntityOwnerId() {
|
|
||||||
return CallContext.current().getCallingAccount().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventType() {
|
|
||||||
return EventTypes.EVENT_EXTERNAL_VSP_VSD_UPDATE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getEventDescription() {
|
|
||||||
return "Updating a Nuage VSD";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,38 +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.api.commands;
|
|
||||||
|
|
||||||
public class VspConstants {
|
|
||||||
public static final String NUAGE_VSP_DEVICE_ID = "vspdeviceid";
|
|
||||||
public static final String NUAGE_VSP_DEVICE_NAME = "nuagedevicename";
|
|
||||||
public static final String NUAGE_VSP_API_PORT = "port";
|
|
||||||
public static final String NUAGE_VSP_API_VERSION = "apiversion";
|
|
||||||
public static final String NUAGE_VSP_API_RETRY_COUNT = "retrycount";
|
|
||||||
public static final String NUAGE_VSP_API_RETRY_INTERVAL = "retryinterval";
|
|
||||||
public static final String NUAGE_VSP_API_METHOD = "method";
|
|
||||||
public static final String NUAGE_VSP_API_RESOURCE = "resource";
|
|
||||||
public static final String NUAGE_VSP_API_RESOURCE_ID = "resourceid";
|
|
||||||
public static final String NUAGE_VSP_API_CHILD_RESOURCE = "childresource";
|
|
||||||
public static final String NUAGE_VSP_API_RESOURCE_FILTER = "resourcefilter";
|
|
||||||
public static final String NUAGE_VSP_API_RESOURCE_INFO = "resourceinfo";
|
|
||||||
public static final String NUAGE_VSP_CMS_ID = "cmsid";
|
|
||||||
public static final String NUAGE_VSP_API_UNDERLAY = "underlay";
|
|
||||||
public static final String NUAGE_VSP_API_DOMAIN_TEMPLATE = "domaintemplate";
|
|
||||||
}
|
|
||||||
@ -1,38 +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.api.response;
|
|
||||||
|
|
||||||
import com.cloud.api.commands.VspConstants;
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
|
||||||
import org.apache.cloudstack.api.response.VlanIpRangeResponse;
|
|
||||||
|
|
||||||
@EntityReference(value = Vlan.class)
|
|
||||||
public class NuageVlanIpRangeResponse extends VlanIpRangeResponse {
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_UNDERLAY)
|
|
||||||
@Param(description = "true if Nuage underlay enabled, false if not")
|
|
||||||
private boolean underlay;
|
|
||||||
|
|
||||||
public void setUnderlay(boolean underlay) {
|
|
||||||
this.underlay = underlay;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,111 +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.api.response;
|
|
||||||
|
|
||||||
import com.cloud.api.commands.VspConstants;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import org.apache.cloudstack.api.ApiConstants;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
import org.apache.cloudstack.api.EntityReference;
|
|
||||||
|
|
||||||
@EntityReference(value = NuageVspDeviceVO.class)
|
|
||||||
public class NuageVspDeviceResponse extends BaseResponse {
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_DEVICE_ID)
|
|
||||||
@Param(description = "the device id of the Nuage VSD")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.PHYSICAL_NETWORK_ID)
|
|
||||||
@Param(description = "the ID of the physical network to which this Nuage VSP belongs to")
|
|
||||||
private String physicalNetworkId;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.PROVIDER)
|
|
||||||
@Param(description = "the service provider name corresponding to this Nuage VSP device")
|
|
||||||
private String providerName;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_DEVICE_NAME)
|
|
||||||
@Param(description = "the name of the Nuage VSP device")
|
|
||||||
private String deviceName;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_PORT)
|
|
||||||
@Param(description = "the port to communicate to Nuage VSD")
|
|
||||||
private int port;
|
|
||||||
|
|
||||||
@SerializedName(ApiConstants.HOST_NAME)
|
|
||||||
@Param(description = "the hostname of the Nuage VSD")
|
|
||||||
private String hostName;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_VERSION)
|
|
||||||
@Param(description = "the version of the API to use to communicate to Nuage VSD")
|
|
||||||
private String apiVersion;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_RETRY_COUNT)
|
|
||||||
@Param(description = "the number of retries on failure to communicate to Nuage VSD")
|
|
||||||
private int apiRetryCount;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_RETRY_INTERVAL)
|
|
||||||
@Param(description = "the time to wait after failure before retrying to communicate to Nuage VSD")
|
|
||||||
private long apiRetryInterval;
|
|
||||||
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_CMS_ID)
|
|
||||||
@Param(description = "the CMS ID generated by the Nuage VSD")
|
|
||||||
private String cmsId;
|
|
||||||
|
|
||||||
public void setId(String vspDetailsId) {
|
|
||||||
this.id = vspDetailsId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPhysicalNetworkId(String physicalNetworkId) {
|
|
||||||
this.physicalNetworkId = physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setProviderName(String providerName) {
|
|
||||||
this.providerName = providerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDeviceName(String deviceName) {
|
|
||||||
this.deviceName = deviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPort(int port) {
|
|
||||||
this.port = port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHostName(String hostName) {
|
|
||||||
this.hostName = hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiVersion(String apiVersion) {
|
|
||||||
this.apiVersion = apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryCount(int apiRetryCount) {
|
|
||||||
this.apiRetryCount = apiRetryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setApiRetryInterval(long apiRetryInterval) {
|
|
||||||
this.apiRetryInterval = apiRetryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCmsId(String cmsId) {
|
|
||||||
this.cmsId = cmsId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,45 +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.api.response;
|
|
||||||
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
|
|
||||||
public class NuageVspDomainTemplateResponse extends BaseResponse {
|
|
||||||
@Param(description = "the name of the domain template")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
@Param(description = "the description of the domain template")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
public NuageVspDomainTemplateResponse(String name, String description) {
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.setObjectName("domaintemplates");
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,40 +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.api.response;
|
|
||||||
|
|
||||||
import com.cloud.api.commands.VspConstants;
|
|
||||||
import com.cloud.serializer.Param;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import org.apache.cloudstack.api.BaseResponse;
|
|
||||||
|
|
||||||
public class NuageVspResourceResponse extends BaseResponse {
|
|
||||||
@SerializedName(VspConstants.NUAGE_VSP_API_RESOURCE_INFO)
|
|
||||||
@Param(description = "the details of the Nuage VSP resource")
|
|
||||||
private String resourceInfo;
|
|
||||||
|
|
||||||
public String getResourceInfo() {
|
|
||||||
return resourceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setResourceInfo(String resourceInfo) {
|
|
||||||
this.resourceInfo = resourceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,97 +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;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.InternalIdentity;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.GenerationType;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "external_nuage_vsp_devices")
|
|
||||||
public class NuageVspDeviceVO implements InternalIdentity {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
||||||
@Column(name = "id")
|
|
||||||
private long id;
|
|
||||||
|
|
||||||
@Column(name = "uuid")
|
|
||||||
private String uuid;
|
|
||||||
|
|
||||||
@Column(name = "host_id")
|
|
||||||
private long hostId;
|
|
||||||
|
|
||||||
@Column(name = "physical_network_id")
|
|
||||||
private long physicalNetworkId;
|
|
||||||
|
|
||||||
@Column(name = "provider_name")
|
|
||||||
private String providerName;
|
|
||||||
|
|
||||||
@Column(name = "device_name")
|
|
||||||
private String deviceName;
|
|
||||||
|
|
||||||
public NuageVspDeviceVO() {
|
|
||||||
this.uuid = UUID.randomUUID().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspDeviceVO(long hostId, long physicalNetworkId,
|
|
||||||
String providerName, String deviceName){
|
|
||||||
super();
|
|
||||||
this.hostId = hostId;
|
|
||||||
this.physicalNetworkId = physicalNetworkId;
|
|
||||||
this.providerName = providerName;
|
|
||||||
this.deviceName = deviceName;
|
|
||||||
this.uuid = UUID.randomUUID().toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getHostId() {
|
|
||||||
return hostId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getPhysicalNetworkId() {
|
|
||||||
return physicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProviderName() {
|
|
||||||
return providerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeviceName() {
|
|
||||||
return deviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,44 +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.dao;
|
|
||||||
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.utils.db.GenericDao;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface NuageVspDao extends GenericDao<NuageVspDeviceVO, Long> {
|
|
||||||
/**
|
|
||||||
* List all the Nuage Vsp devices added in to this physical network
|
|
||||||
*
|
|
||||||
* @param physicalNetworkId physical Network Id
|
|
||||||
* @return list of NuageVspDeviceVO for this physical network.
|
|
||||||
*/
|
|
||||||
List<NuageVspDeviceVO> listByPhysicalNetwork(long physicalNetworkId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* List all the Nuage Vsp devices by a specific host
|
|
||||||
*
|
|
||||||
* @param hostId host Id
|
|
||||||
* @return list of NuageVspDeviceVO for this host.
|
|
||||||
*/
|
|
||||||
List<NuageVspDeviceVO> listByHost(long hostId);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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.
|
|
||||||
//
|
|
||||||
|
|
||||||
package com.cloud.network.dao;
|
|
||||||
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.utils.db.GenericDaoBase;
|
|
||||||
import com.cloud.utils.db.SearchBuilder;
|
|
||||||
import com.cloud.utils.db.SearchCriteria;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class NuageVspDaoImpl extends GenericDaoBase<NuageVspDeviceVO, Long>
|
|
||||||
implements NuageVspDao {
|
|
||||||
|
|
||||||
private final SearchBuilder<NuageVspDeviceVO> physicalNetworkIdSearch;
|
|
||||||
private final SearchBuilder<NuageVspDeviceVO> hostIdSearch;
|
|
||||||
|
|
||||||
public NuageVspDaoImpl() {
|
|
||||||
physicalNetworkIdSearch = createSearchBuilder();
|
|
||||||
physicalNetworkIdSearch.and("physicalNetworkId", physicalNetworkIdSearch.entity().getPhysicalNetworkId(), SearchCriteria.Op.EQ);
|
|
||||||
physicalNetworkIdSearch.done();
|
|
||||||
|
|
||||||
hostIdSearch = createSearchBuilder();
|
|
||||||
hostIdSearch.and("hostId", hostIdSearch.entity().getHostId(), SearchCriteria.Op.EQ);
|
|
||||||
hostIdSearch.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NuageVspDeviceVO> listByPhysicalNetwork(long physicalNetworkId) {
|
|
||||||
SearchCriteria<NuageVspDeviceVO> sc = physicalNetworkIdSearch.create();
|
|
||||||
sc.setParameters("physicalNetworkId", physicalNetworkId);
|
|
||||||
return search(sc, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<NuageVspDeviceVO> listByHost(long hostId) {
|
|
||||||
SearchCriteria<NuageVspDeviceVO> sc = hostIdSearch.create();
|
|
||||||
sc.setParameters("hostId", hostId);
|
|
||||||
return search(sc, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,788 +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.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Multimap;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.api.InternalIdentity;
|
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
|
||||||
import org.apache.cloudstack.network.ExternalNetworkDeviceManager;
|
|
||||||
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
|
|
||||||
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
|
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.agent.api.StartupCommand;
|
|
||||||
import com.cloud.agent.api.StartupVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ExtraDhcpOptionsVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ImplementVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ShutDownVpcVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ShutDownVspCommand;
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.dao.VlanDao;
|
|
||||||
import com.cloud.dc.dao.VlanDetailsDao;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientCapacityException;
|
|
||||||
import com.cloud.exception.ResourceUnavailableException;
|
|
||||||
import com.cloud.exception.UnsupportedServiceException;
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.Network.Capability;
|
|
||||||
import com.cloud.network.Network.Provider;
|
|
||||||
import com.cloud.network.Network.Service;
|
|
||||||
import com.cloud.network.NetworkMigrationManager;
|
|
||||||
import com.cloud.network.NetworkModel;
|
|
||||||
import com.cloud.network.Networks;
|
|
||||||
import com.cloud.network.PhysicalNetworkServiceProvider;
|
|
||||||
import com.cloud.network.PublicIpAddress;
|
|
||||||
import com.cloud.network.dao.FirewallRulesCidrsDao;
|
|
||||||
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.PhysicalNetworkDao;
|
|
||||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.network.manager.NuageVspManagerImpl;
|
|
||||||
import com.cloud.network.rules.FirewallRule;
|
|
||||||
import com.cloud.network.rules.FirewallRule.FirewallRuleType;
|
|
||||||
import com.cloud.network.rules.FirewallRuleVO;
|
|
||||||
import com.cloud.network.rules.StaticNat;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItem;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItemDao;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItemVO;
|
|
||||||
import com.cloud.network.vpc.PrivateGateway;
|
|
||||||
import com.cloud.network.vpc.StaticRouteProfile;
|
|
||||||
import com.cloud.network.vpc.Vpc;
|
|
||||||
import com.cloud.network.vpc.VpcOfferingServiceMapVO;
|
|
||||||
import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
|
||||||
import com.cloud.resource.ResourceManager;
|
|
||||||
import com.cloud.resource.ResourceStateAdapter;
|
|
||||||
import com.cloud.resource.ServerResource;
|
|
||||||
import com.cloud.resource.UnableDeleteHostException;
|
|
||||||
import com.cloud.server.ResourceTag;
|
|
||||||
import com.cloud.tags.dao.ResourceTagDao;
|
|
||||||
import com.cloud.util.NuageVspEntityBuilder;
|
|
||||||
import com.cloud.util.NuageVspUtil;
|
|
||||||
import com.cloud.utils.Pair;
|
|
||||||
import com.cloud.utils.component.AdapterBase;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.utils.net.NetUtils;
|
|
||||||
import com.cloud.vm.DomainRouterVO;
|
|
||||||
import com.cloud.vm.NicProfile;
|
|
||||||
import com.cloud.vm.NicVO;
|
|
||||||
import com.cloud.vm.ReservationContext;
|
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
|
||||||
import com.cloud.vm.dao.NicDao;
|
|
||||||
|
|
||||||
public class NuageVspElement extends AdapterBase implements ConnectivityProvider, IpDeployer, SourceNatServiceProvider, StaticNatServiceProvider, FirewallServiceProvider,
|
|
||||||
DhcpServiceProvider, ResourceStateAdapter, VpcProvider, NetworkACLServiceProvider {
|
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(NuageVspElement.class);
|
|
||||||
|
|
||||||
private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
|
|
||||||
|
|
||||||
private static final Set<Service> REQUIRED_SERVICES = ImmutableSet.of(
|
|
||||||
Service.Connectivity,
|
|
||||||
Service.Dhcp
|
|
||||||
);
|
|
||||||
private static final Set<Service> NUAGE_ONLY_SERVICES = ImmutableSet.of(
|
|
||||||
Service.SourceNat,
|
|
||||||
Service.StaticNat,
|
|
||||||
Service.Gateway
|
|
||||||
);
|
|
||||||
private static final Set<Service> UNSUPPORTED_SERVICES = ImmutableSet.of(
|
|
||||||
Service.Vpn,
|
|
||||||
Service.Dns,
|
|
||||||
Service.PortForwarding,
|
|
||||||
Service.SecurityGroup
|
|
||||||
);
|
|
||||||
private static final Set<Pair<Service, Service>> ANY_REQUIRED_SERVICES = ImmutableSet.of(
|
|
||||||
new Pair<>(Service.SourceNat, Service.StaticNat)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
public static final ExternalNetworkDeviceManager.NetworkDevice NuageVspDevice = new ExternalNetworkDeviceManager.NetworkDevice("NuageVsp", Provider.NuageVsp.getName());
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
ResourceManager _resourceMgr;
|
|
||||||
@Inject
|
|
||||||
NetworkModel _networkModel;
|
|
||||||
@Inject
|
|
||||||
NetworkServiceMapDao _ntwkSrvcDao;
|
|
||||||
@Inject
|
|
||||||
NetworkDao _networkDao;
|
|
||||||
@Inject
|
|
||||||
DomainDao _domainDao;
|
|
||||||
@Inject
|
|
||||||
IPAddressDao _ipAddressDao;
|
|
||||||
@Inject
|
|
||||||
VlanDao _vlanDao;
|
|
||||||
@Inject
|
|
||||||
VlanDetailsDao _vlanDetailsDao;
|
|
||||||
@Inject
|
|
||||||
NicDao _nicDao;
|
|
||||||
@Inject
|
|
||||||
VpcOfferingServiceMapDao _vpcOfferingSrvcDao;
|
|
||||||
@Inject
|
|
||||||
AgentManager _agentMgr;
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingDao _ntwkOfferingDao;
|
|
||||||
@Inject
|
|
||||||
ConfigurationDao _configDao;
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
@Inject
|
|
||||||
FirewallRulesDao _firewallRulesDao;
|
|
||||||
@Inject
|
|
||||||
FirewallRulesCidrsDao _firewallRulesCidrsDao;
|
|
||||||
@Inject
|
|
||||||
PhysicalNetworkDao _physicalNetworkDao;
|
|
||||||
@Inject
|
|
||||||
NetworkACLItemDao _networkACLItemDao;
|
|
||||||
@Inject
|
|
||||||
NuageVspEntityBuilder _nuageVspEntityBuilder;
|
|
||||||
@Inject
|
|
||||||
VpcDetailsDao _vpcDetailsDao;
|
|
||||||
@Inject
|
|
||||||
DomainRouterDao _routerDao;
|
|
||||||
@Inject
|
|
||||||
ResourceTagDao _resourceTagDao;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyIps(Network network, List<? extends PublicIpAddress> ipAddress, Set<Service> service) throws ResourceUnavailableException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<Service, Map<Capability, String>> getCapabilities() {
|
|
||||||
return capabilities;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<Service, Map<Capability, String>> setCapabilities() {
|
|
||||||
return ImmutableMap.<Service, Map<Capability, String>>builder()
|
|
||||||
.put(Service.Connectivity, ImmutableMap.of(
|
|
||||||
Capability.NoVlan, "",
|
|
||||||
Capability.PublicAccess, ""
|
|
||||||
))
|
|
||||||
.put(Service.Gateway, ImmutableMap.<Capability, String>of())
|
|
||||||
.put(Service.SourceNat, ImmutableMap.of(
|
|
||||||
Capability.SupportedSourceNatTypes, "perzone",
|
|
||||||
Capability.RedundantRouter, "false"
|
|
||||||
))
|
|
||||||
.put(Service.StaticNat, ImmutableMap.<Capability, String>of())
|
|
||||||
.put(Service.SecurityGroup, ImmutableMap.<Capability, String>of())
|
|
||||||
.put(Service.Firewall, ImmutableMap.of(
|
|
||||||
Capability.TrafficStatistics, "per public ip",
|
|
||||||
Capability.SupportedProtocols, "tcp,udp,icmp",
|
|
||||||
Capability.SupportedEgressProtocols, "tcp,udp,icmp, all",
|
|
||||||
Capability.SupportedTrafficDirection, "ingress, egress",
|
|
||||||
Capability.MultipleIps, "true"
|
|
||||||
))
|
|
||||||
.put(Service.Dhcp, ImmutableMap.of(
|
|
||||||
Capability.DhcpAccrossMultipleSubnets, "true",
|
|
||||||
Capability.ExtraDhcpOptions, "true"
|
|
||||||
))
|
|
||||||
.put(Service.NetworkACL, ImmutableMap.of(
|
|
||||||
Capability.SupportedProtocols, "tcp,udp,icmp"
|
|
||||||
))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Provider getProvider() {
|
|
||||||
return Provider.NuageVsp;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
|
||||||
super.configure(name, params);
|
|
||||||
_resourceMgr.registerResourceStateAdapter(name, this);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Entering NuageElement implement function for network " + network.getDisplayText() + " (state " + network.getState() + ")");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getVpcId() != null) {
|
|
||||||
return applyACLRulesForVpc(network, offering);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!canHandle(network, offering, Service.Connectivity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getBroadcastUri() == null) {
|
|
||||||
s_logger.error("Nic has no broadcast Uri with the virtual router IP");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
_nuageVspManager.updateBroadcastUri(network);
|
|
||||||
network = _networkDao.findById(network.getId());
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
List<VspAclRule> ingressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Ingress);
|
|
||||||
List<VspAclRule> egressFirewallRules = getFirewallRulesToApply(network, FirewallRule.TrafficType.Egress);
|
|
||||||
|
|
||||||
List<IPAddressVO> ips = _ipAddressDao.listStaticNatPublicIps(network.getId());
|
|
||||||
List<String> floatingIpUuids = new ArrayList<String>();
|
|
||||||
for (IPAddressVO ip : ips) {
|
|
||||||
floatingIpUuids.add(ip.getUuid());
|
|
||||||
}
|
|
||||||
VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering);
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
|
|
||||||
ImplementVspCommand cmd = new ImplementVspCommand(vspNetwork, ingressFirewallRules, egressFirewallRules, floatingIpUuids, vspDhcpOptions);
|
|
||||||
send(cmd, network);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void send(Command cmd, Network network)
|
|
||||||
throws ResourceUnavailableException {
|
|
||||||
send(cmd, network.getPhysicalNetworkId(), Network.class, network);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void send(Command cmd, Vpc vpc)
|
|
||||||
throws ResourceUnavailableException {
|
|
||||||
send(cmd, getPhysicalNetworkId(vpc.getZoneId()), Vpc.class, vpc);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private <R extends InternalIdentity> void send(Command cmd, long physicalNetworkId, Class<R> resourceClass,
|
|
||||||
R resource)
|
|
||||||
throws ResourceUnavailableException {
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
if (isFailure(answer)) {
|
|
||||||
s_logger.error(cmd.getClass().getName() + " for " + resourceClass.getName() + " " + resource.getId() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
if (hasFailureDetails(answer)) {
|
|
||||||
throw new ResourceUnavailableException(answer.getDetails(), resourceClass, resource.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasFailureDetails(Answer answer) {
|
|
||||||
return (null != answer) && (null != answer.getDetails());
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isFailure(Answer answer) {
|
|
||||||
return answer == null || !answer.getResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean applyACLRulesForVpc(Network network, NetworkOffering offering) throws ResourceUnavailableException {
|
|
||||||
List<NetworkACLItemVO> rules = _networkACLItemDao.listByACL(network.getNetworkACLId());
|
|
||||||
if (_networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Network.Service.NetworkACL)) {
|
|
||||||
applyACLRules(network, rules, true, false);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<VspAclRule> getFirewallRulesToApply(final Network network, FirewallRule.TrafficType trafficType) {
|
|
||||||
List<FirewallRuleVO> firewallRulesToApply = _firewallRulesDao.listByNetworkPurposeTrafficType(network.getId(), FirewallRule.Purpose.Firewall, trafficType);
|
|
||||||
List<VspAclRule> vspAclRulesToApply = Lists.newArrayListWithExpectedSize(firewallRulesToApply.size());
|
|
||||||
|
|
||||||
for (FirewallRuleVO rule : firewallRulesToApply) {
|
|
||||||
rule.setSourceCidrList(_firewallRulesCidrsDao.getSourceCidrs(rule.getId()));
|
|
||||||
VspAclRule vspAclRule = _nuageVspEntityBuilder.buildVspAclRule(rule, network);
|
|
||||||
vspAclRulesToApply.add(vspAclRule);
|
|
||||||
}
|
|
||||||
return vspAclRulesToApply;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean prepare(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
|
||||||
ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
if (!canHandle(network, Service.Connectivity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getBroadcastUri() == null) {
|
|
||||||
s_logger.error("Nic has no broadcast Uri with the virtual router IP");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean release(Network network, NicProfile nic, VirtualMachineProfile vm, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
if (!canHandle(network, Service.Connectivity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getBroadcastUri() == null) {
|
|
||||||
s_logger.error("Nic has no broadcast Uri with the virtual router IP");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
if (!canHandle(network, Service.Connectivity)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (cleanup && isDnsSupportedByVR(network)) {
|
|
||||||
// The network is restarted, possibly the domain name is changed, update the dhcpOptions as soon as possible
|
|
||||||
NetworkOfferingVO networkOfferingVO = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
VspDhcpDomainOption vspDhcpOptions = _nuageVspEntityBuilder.buildNetworkDhcpOption(network, networkOfferingVO);
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
|
|
||||||
ShutDownVspCommand cmd = new ShutDownVspCommand(vspNetwork, vspDhcpOptions);
|
|
||||||
send(cmd, network);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReady(PhysicalNetworkServiceProvider provider) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canEnableIndividualServices() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean destroy(Network network, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
return canHandle(network, Service.Connectivity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean verifyServicesCombination(Set<Service> services) {
|
|
||||||
Preconditions.checkNotNull(services);
|
|
||||||
final Sets.SetView<Service> missingServices = Sets.difference(REQUIRED_SERVICES, services);
|
|
||||||
final Sets.SetView<Service> unsupportedServices = Sets.intersection(UNSUPPORTED_SERVICES, services);
|
|
||||||
final Sets.SetView<Service> wantedServices = Sets.intersection(NUAGE_ONLY_SERVICES, new HashSet<>());
|
|
||||||
|
|
||||||
if (!missingServices.isEmpty()) {
|
|
||||||
throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " requires services: " + missingServices);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!unsupportedServices.isEmpty()) {
|
|
||||||
// NuageVsp doesn't implement any of these services.
|
|
||||||
// So if these services are requested, we can't handle it.
|
|
||||||
s_logger.debug("Unable to support services combination. The services " + unsupportedServices + " are not supported by Nuage VSP.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!wantedServices.isEmpty()) {
|
|
||||||
throw new UnsupportedServiceException("Provider " + Provider.NuageVsp + " does not support services to be implemented by another provider: " + wantedServices);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canHandle(Network network, Service service) {
|
|
||||||
NetworkOffering networkOffering = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
return canHandle(network, networkOffering, service);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean canHandle(Network network, NetworkOffering networkOffering, Service service) {
|
|
||||||
if (network.getBroadcastDomainType() != Networks.BroadcastDomainType.Vsp) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_networkModel.isProviderForNetwork(getProvider(), network.getId())) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp is not a provider for network " + network.getDisplayText());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service != null) {
|
|
||||||
if (!_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), service, getProvider())) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't provide the " + service.getName() + " service on network " + network.getDisplayText());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service != Service.Connectivity
|
|
||||||
&& !_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.Connectivity, getProvider())) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as Connectivity provider");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (service != Service.SourceNat
|
|
||||||
&& networkOffering.getGuestType() == Network.GuestType.Isolated
|
|
||||||
&& !_ntwkSrvcDao.canProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, getProvider())) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as SourceNat provider");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (networkOffering.isSpecifyVlan()) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp doesn't support VLAN values for networks");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getVpcId() != null && !networkOffering.isPersistent()) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addDhcpEntry(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException,
|
|
||||||
InsufficientCapacityException, ResourceUnavailableException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configDhcpSupportForSubnet(Network network, NicProfile nic, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
|
||||||
throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isDnsSupportedByVR(Network network) {
|
|
||||||
return (_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Dns) &&
|
|
||||||
( _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VirtualRouter) ||
|
|
||||||
_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean removeDhcpSupportForSubnet(Network network) throws ResourceUnavailableException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setExtraDhcpOptions(Network network, long nicId, Map<Integer, String> dhcpOptions) {
|
|
||||||
if (network.isRollingRestart()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
|
|
||||||
NicVO nic = _nicDao.findById(nicId);
|
|
||||||
|
|
||||||
ExtraDhcpOptionsVspCommand extraDhcpOptionsVspCommand = new ExtraDhcpOptionsVspCommand(vspNetwork, nic.getUuid(), dhcpOptions);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), extraDhcpOptionsVspCommand);
|
|
||||||
if (isFailure(answer)) {
|
|
||||||
s_logger.error("[setExtraDhcpOptions] setting extra DHCP options for nic " + nic.getUuid() + " failed.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyStaticNats(Network config, List<? extends StaticNat> rules) throws ResourceUnavailableException {
|
|
||||||
List<VspStaticNat> vspStaticNatDetails = new ArrayList<VspStaticNat>();
|
|
||||||
for (StaticNat staticNat : rules) {
|
|
||||||
IPAddressVO sourceNatIp = _ipAddressDao.findById(staticNat.getSourceIpAddressId());
|
|
||||||
VlanVO sourceNatVlan = _vlanDao.findById(sourceNatIp.getVlanId());
|
|
||||||
checkVlanUnderlayCompatibility(sourceNatVlan);
|
|
||||||
|
|
||||||
if (!staticNat.isForRevoke()) {
|
|
||||||
final List<FirewallRuleVO> firewallRules = _firewallRulesDao.listByIpAndNotRevoked(staticNat.getSourceIpAddressId());
|
|
||||||
for (FirewallRuleVO firewallRule : firewallRules) {
|
|
||||||
_nuageVspEntityBuilder.buildVspAclRule(firewallRule, config, sourceNatIp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NicVO nicVO = _nicDao.findByIp4AddressAndNetworkId(staticNat.getDestIpAddress(), staticNat.getNetworkId());
|
|
||||||
VspStaticNat vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(staticNat.isForRevoke(), sourceNatIp, sourceNatVlan, nicVO);
|
|
||||||
vspStaticNatDetails.add(vspStaticNat);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(config);
|
|
||||||
ApplyStaticNatVspCommand cmd = new ApplyStaticNatVspCommand(vspNetwork, vspStaticNatDetails);
|
|
||||||
send(cmd,
|
|
||||||
config);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkVlanUnderlayCompatibility(VlanVO newVlan) throws ResourceUnavailableException {
|
|
||||||
List<VlanVO> vlans = _vlanDao.listByZone(newVlan.getDataCenterId());
|
|
||||||
if (CollectionUtils.isNotEmpty(vlans)) {
|
|
||||||
boolean newVlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, newVlan);
|
|
||||||
final String newCidr = NetUtils.getCidrFromGatewayAndNetmask(newVlan.getVlanGateway(), newVlan.getVlanNetmask());
|
|
||||||
|
|
||||||
for (VlanVO vlan : vlans) {
|
|
||||||
if (vlan.getId() == newVlan.getId()) continue;
|
|
||||||
|
|
||||||
final String existingCidr = NetUtils.getCidrFromGatewayAndNetmask(vlan.getVlanGateway(), vlan.getVlanNetmask());
|
|
||||||
|
|
||||||
NetUtils.SupersetOrSubset supersetOrSubset = NetUtils.isNetowrkASubsetOrSupersetOfNetworkB(newCidr, existingCidr);
|
|
||||||
if (supersetOrSubset == NetUtils.SupersetOrSubset.sameSubnet) {
|
|
||||||
boolean vlanUnderlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan);
|
|
||||||
if (newVlanUnderlay != vlanUnderlay) {
|
|
||||||
throw new ResourceUnavailableException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported", Vlan.class, newVlan.getId());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IpDeployer getIpDeployer(Network network) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyFWRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException {
|
|
||||||
if (rules == null || rules.isEmpty()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rules.size() == 1 && rules.iterator().next().getType().equals(FirewallRuleType.System)) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Default ACL added by CS as system is ignored for network " + network.getName() + " with rule " + rules);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
s_logger.info("Applying " + rules.size() + " Firewall Rules for network " + network.getName());
|
|
||||||
return applyACLRules(network, rules, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean applyACLRules(final Network network, List<? extends InternalIdentity> rules, boolean isNetworkAcl, boolean networkReset)
|
|
||||||
throws ResourceUnavailableException {
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
List<VspAclRule> vspAclRules = Lists.transform(rules, new Function<InternalIdentity, VspAclRule>() {
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public VspAclRule apply(@Nullable InternalIdentity input) {
|
|
||||||
if (input instanceof FirewallRule) {
|
|
||||||
return _nuageVspEntityBuilder.buildVspAclRule((FirewallRule) input, network);
|
|
||||||
}
|
|
||||||
return _nuageVspEntityBuilder.buildVspAclRule((NetworkACLItem) input);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
VspAclRule.ACLType vspAclType = isNetworkAcl ? VspAclRule.ACLType.NetworkACL : VspAclRule.ACLType.Firewall;
|
|
||||||
ApplyAclRuleVspCommand cmd = new ApplyAclRuleVspCommand(vspAclType, vspNetwork, vspAclRules, networkReset);
|
|
||||||
send(cmd,
|
|
||||||
network);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyNetworkACLs(Network config, List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
|
|
||||||
if (rules == null || rules.isEmpty()) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("No rules to apply. So, delete all the existing ACL in VSP from Subnet with uuid " + config.getUuid());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("New rules has to applied. So, delete all the existing ACL in VSP from Subnet with uuid " + config.getUuid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (rules != null) {
|
|
||||||
s_logger.info("Applying " + rules.size() + " Network ACLs for network " + config.getName());
|
|
||||||
applyACLRules(config, rules, true, rules.isEmpty());
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean implementVpc(Vpc vpc, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException {
|
|
||||||
List<VpcOfferingServiceMapVO> vpcOfferingServices = _vpcOfferingSrvcDao.listByVpcOffId(vpc.getVpcOfferingId());
|
|
||||||
Multimap<Service, Provider> supportedVpcServices = NuageVspManagerImpl.SUPPORTED_NUAGE_VSP_VPC_SERVICE_MAP;
|
|
||||||
for (VpcOfferingServiceMapVO vpcOfferingService : vpcOfferingServices) {
|
|
||||||
Network.Service service = Network.Service.getService(vpcOfferingService.getService());
|
|
||||||
if (!supportedVpcServices.containsKey(service)) {
|
|
||||||
s_logger.warn(String.format("NuageVsp doesn't support service %s for VPCs", service.getName()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Network.Provider provider = Network.Provider.getProvider(vpcOfferingService.getProvider());
|
|
||||||
if (!supportedVpcServices.containsEntry(service, provider)) {
|
|
||||||
s_logger.warn(String.format("NuageVsp doesn't support provider %s for service %s for VPCs", provider.getName(), service.getName()));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String globalDomainTemplate = _nuageVspManager.NuageVspVpcDomainTemplateName.value();
|
|
||||||
if (StringUtils.isNotBlank(globalDomainTemplate) && !_nuageVspManager.checkIfDomainTemplateExist(vpc.getDomainId(),globalDomainTemplate,vpc.getZoneId(),null)) {
|
|
||||||
s_logger.warn("The global pre configured domain template does not exist on the VSD.");
|
|
||||||
throw new CloudRuntimeException("The global pre configured domain template does not exist on the VSD.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shutdownVpc(Vpc vpc, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
if (vpc.getState().equals(Vpc.State.Inactive)) {
|
|
||||||
List<DomainRouterVO> routers = _routerDao.listByVpcId(vpc.getId());
|
|
||||||
if (CollectionUtils.isEmpty(routers)) {
|
|
||||||
routers = _routerDao.listIncludingRemovedByVpcId(vpc.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> domainRouterUuids = Lists.transform(routers, new Function<DomainRouterVO, String>() {
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public String apply(@Nullable DomainRouterVO input) {
|
|
||||||
return input != null ? input.getUuid() : null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Domain vpcDomain = _domainDao.findById(vpc.getDomainId());
|
|
||||||
|
|
||||||
String preConfiguredDomainTemplateName;
|
|
||||||
VpcDetailVO domainTemplateNameDetail = _vpcDetailsDao.findDetail(vpc.getId(), NuageVspManager.nuageDomainTemplateDetailName);
|
|
||||||
if (domainTemplateNameDetail != null) {
|
|
||||||
preConfiguredDomainTemplateName = domainTemplateNameDetail.getValue();
|
|
||||||
} else {
|
|
||||||
preConfiguredDomainTemplateName = _configDao.getValue(NuageVspManager.NuageVspVpcDomainTemplateName.key());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, String> vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpc.getId(), false);
|
|
||||||
|
|
||||||
cleanUpVpcCaching(vpc.getId());
|
|
||||||
//related to migration caching
|
|
||||||
List<? extends ResourceTag> vpcResourceDetails = _resourceTagDao.listByResourceUuid(vpc.getUuid());
|
|
||||||
if (vpcResourceDetails != null) {
|
|
||||||
vpcResourceDetails.stream()
|
|
||||||
.filter(item -> item.getKey().equals(NetworkMigrationManager.MIGRATION))
|
|
||||||
.findFirst()
|
|
||||||
.map(ResourceTag::getResourceId)
|
|
||||||
.ifPresent(this::cleanUpVpcCaching);
|
|
||||||
}
|
|
||||||
|
|
||||||
ShutDownVpcVspCommand cmd = new ShutDownVpcVspCommand(vpcDomain.getUuid(), vpc.getUuid(), preConfiguredDomainTemplateName, domainRouterUuids, vpcDetails);
|
|
||||||
send(cmd, vpc);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanUpVpcCaching(long vpcId) {
|
|
||||||
_vpcDetailsDao.removeDetail(vpcId, NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID);
|
|
||||||
_vpcDetailsDao.removeDetail(vpcId, NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Long getPhysicalNetworkId(Long zoneId) {
|
|
||||||
Long guestPhysicalNetworkId = 0L;
|
|
||||||
List<PhysicalNetworkVO> physicalNetworkList = _physicalNetworkDao.listByZone(zoneId);
|
|
||||||
for (PhysicalNetworkVO phyNtwk : physicalNetworkList) {
|
|
||||||
if (phyNtwk.getIsolationMethods().contains("VSP")) {
|
|
||||||
guestPhysicalNetworkId = phyNtwk.getId();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return guestPhysicalNetworkId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean createPrivateGateway(PrivateGateway gateway) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean deletePrivateGateway(PrivateGateway privateGateway) throws ConcurrentOperationException, ResourceUnavailableException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyStaticRoutes(Vpc vpc, List<StaticRouteProfile> routes) throws ResourceUnavailableException {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applyACLItemsToPrivateGw(PrivateGateway gateway, List<? extends NetworkACLItem> rules) throws ResourceUnavailableException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HostVO createHostVOForConnectedAgent(HostVO host, StartupCommand[] cmd) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HostVO createHostVOForDirectConnectAgent(HostVO host, StartupCommand[] startup, ServerResource resource, Map<String, String> details, List<String> hostTags) {
|
|
||||||
if (!(startup[0] instanceof StartupVspCommand)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
host.setType(Host.Type.L2Networking);
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DeleteHostAnswer deleteHost(HostVO host, boolean isForced, boolean isForceDeleteStorage) throws UnableDeleteHostException {
|
|
||||||
if (!(host.getType() == Host.Type.L2Networking)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new DeleteHostAnswer(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,874 +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.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomain;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNic;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspVm;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.common.collect.LinkedListMultimap;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService;
|
|
||||||
import org.apache.cloudstack.resourcedetail.VpcDetailVO;
|
|
||||||
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
|
|
||||||
|
|
||||||
import com.cloud.agent.AgentManager;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand;
|
|
||||||
import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
|
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
|
||||||
import com.cloud.dc.DataCenter;
|
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
|
||||||
import com.cloud.dc.DataCenterDetailVO;
|
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.dao.DataCenterDetailsDao;
|
|
||||||
import com.cloud.dc.dao.VlanDetailsDao;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
import com.cloud.exception.ConcurrentOperationException;
|
|
||||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
|
||||||
import com.cloud.exception.UnsupportedServiceException;
|
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.Network.GuestType;
|
|
||||||
import com.cloud.network.Network.State;
|
|
||||||
import com.cloud.network.NetworkProfile;
|
|
||||||
import com.cloud.network.Networks;
|
|
||||||
import com.cloud.network.PhysicalNetwork;
|
|
||||||
import com.cloud.network.PhysicalNetwork.IsolationMethod;
|
|
||||||
import com.cloud.network.dao.IPAddressVO;
|
|
||||||
import com.cloud.network.dao.NetworkDetailsDao;
|
|
||||||
import com.cloud.network.dao.NetworkVO;
|
|
||||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.network.router.VirtualRouter;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.user.AccountVO;
|
|
||||||
import com.cloud.user.dao.AccountDao;
|
|
||||||
import com.cloud.util.NuageVspEntityBuilder;
|
|
||||||
import com.cloud.util.NuageVspUtil;
|
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
import com.cloud.utils.db.DB;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.utils.net.Ip;
|
|
||||||
import com.cloud.vm.DomainRouterVO;
|
|
||||||
import com.cloud.vm.Nic;
|
|
||||||
import com.cloud.vm.NicProfile;
|
|
||||||
import com.cloud.vm.NicVO;
|
|
||||||
import com.cloud.vm.ReservationContext;
|
|
||||||
import com.cloud.vm.VMInstanceVO;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
|
||||||
|
|
||||||
public class NuageVspGuestNetworkGuru extends GuestNetworkGuru implements NetworkGuruAdditionalFunctions {
|
|
||||||
public static final Logger s_logger = Logger.getLogger(NuageVspGuestNetworkGuru.class);
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingDao _ntwkOfferingDao;
|
|
||||||
@Inject
|
|
||||||
DomainDao _domainDao;
|
|
||||||
@Inject
|
|
||||||
AccountDao _accountDao;
|
|
||||||
@Inject
|
|
||||||
VMInstanceDao _vmInstanceDao;
|
|
||||||
@Inject
|
|
||||||
AgentManager _agentMgr;
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
@Inject
|
|
||||||
ConfigurationManager _configMgr;
|
|
||||||
@Inject
|
|
||||||
NuageVspEntityBuilder _nuageVspEntityBuilder;
|
|
||||||
@Inject
|
|
||||||
NetworkDetailsDao _networkDetailsDao;
|
|
||||||
@Inject
|
|
||||||
VpcDetailsDao _vpcDetailsDao;
|
|
||||||
@Inject
|
|
||||||
NetworkOrchestrationService _networkOrchestrationService;
|
|
||||||
@Inject
|
|
||||||
DataCenterDetailsDao _dcDetailsDao;
|
|
||||||
@Inject
|
|
||||||
VlanDetailsDao _vlanDetailsDao;
|
|
||||||
@Inject
|
|
||||||
private DomainRouterDao _routerDao;
|
|
||||||
|
|
||||||
public NuageVspGuestNetworkGuru() {
|
|
||||||
super();
|
|
||||||
_isolationMethods = new IsolationMethod[] {new IsolationMethod("VSP")};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
|
|
||||||
PhysicalNetworkVO physnet = _physicalNetworkDao.findById(plan.getPhysicalNetworkId());
|
|
||||||
DataCenter dc = _dcDao.findById(plan.getDataCenterId());
|
|
||||||
if (!canHandle(offering, dc.getNetworkType(), physnet)) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Refusing to design network using network offering " + offering.getId() + (physnet != null ? " on physical network " + physnet.getId() : ""));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkVO networkObject = (NetworkVO)super.design(offering, plan, userSpecified, owner);
|
|
||||||
if (networkObject == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
networkObject.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp);
|
|
||||||
|
|
||||||
if (userSpecified instanceof NetworkVO && userSpecified.getExternalId() != null) {
|
|
||||||
if (owner.getType() < Account.ACCOUNT_TYPE_ADMIN) {
|
|
||||||
throw new IllegalArgumentException("vsdManaged networks are only useable by admins.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isUniqueReference(plan.getDataCenterId(), userSpecified.getExternalId())) {
|
|
||||||
s_logger.debug("Refusing to design network. VsdManaged network object already present in zone.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return networkObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isUniqueReference(long dataCenterId, String vsdSubnetId) {
|
|
||||||
DataCenterDetailVO detail = _dcDetailsDao.findDetail(dataCenterId, vsdSubnetId);
|
|
||||||
return detail == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isVsdManagedVpc(long vpcId) {
|
|
||||||
//Check if it's a vpc and if the vpc is already vsdManaged OR if it has 0 tiers
|
|
||||||
Map<String, String> vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpcId, false);
|
|
||||||
return vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED) != null && vpcDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED).equals("true");
|
|
||||||
}
|
|
||||||
|
|
||||||
/** In case an externalId is specified, we get called here, and store the id the same way as cached data */
|
|
||||||
@Override
|
|
||||||
public void finalizeNetworkDesign(long networkId, String vlanIdAsUUID) {
|
|
||||||
NetworkVO designedNetwork = _networkDao.findById(networkId);
|
|
||||||
String externalId = designedNetwork.getExternalId();
|
|
||||||
boolean isVpc = designedNetwork.getVpcId() != null;
|
|
||||||
|
|
||||||
if (isVpc && _networkDao.listByVpc(designedNetwork.getVpcId()).size() > 1) {
|
|
||||||
boolean isVsdManagedVpc = isVsdManagedVpc(designedNetwork.getVpcId());
|
|
||||||
if (isVsdManagedVpc && externalId == null) {
|
|
||||||
throw new CloudRuntimeException("Refusing to design network. Network is vsdManaged but is part of a non vsd managed vpc.");
|
|
||||||
} else if (!isVsdManagedVpc && externalId != null) {
|
|
||||||
throw new CloudRuntimeException("Refusing to design network. Network is not vsdManaged but is part of a vsd managed vpc.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (externalId == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(designedNetwork, externalId);
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(designedNetwork.getPhysicalNetworkId());
|
|
||||||
|
|
||||||
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, null, true);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
throw new CloudRuntimeException("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
}
|
|
||||||
|
|
||||||
//check if the network does not violate the uuid cidr
|
|
||||||
ImplementNetworkVspAnswer implementAnswer = (ImplementNetworkVspAnswer) answer;
|
|
||||||
VspNetwork updatedVspNetwork = implementAnswer.getVspNetwork();
|
|
||||||
NetworkVO forUpdate = _networkDao.createForUpdate(networkId);
|
|
||||||
|
|
||||||
if (isVpc && (!designedNetwork.getCidr().equals(updatedVspNetwork.getCidr()) || !designedNetwork.getGateway().equals(updatedVspNetwork.getGateway()))) {
|
|
||||||
throw new CloudRuntimeException("Tier network does not match the VsdManaged subnet cidr or gateway.");
|
|
||||||
} else {
|
|
||||||
forUpdate.setCidr(updatedVspNetwork.getCidr());
|
|
||||||
forUpdate.setGateway(updatedVspNetwork.getGateway());
|
|
||||||
}
|
|
||||||
|
|
||||||
saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), designedNetwork.getVpcId());
|
|
||||||
saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, externalId);
|
|
||||||
saveNetworkDetail(networkId, NuageVspManager.NETWORK_METADATA_VSD_MANAGED, "true");
|
|
||||||
|
|
||||||
forUpdate.setState(State.Allocated);
|
|
||||||
_networkDao.update(networkId, forUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, ? extends Object> listAdditionalNicParams(String nicUuid) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Network implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws InsufficientVirtualNetworkCapacityException {
|
|
||||||
long networkId = network.getId();
|
|
||||||
network = _networkDao.acquireInLockTable(network.getId(), 1200);
|
|
||||||
if (network == null) {
|
|
||||||
throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if an acl template is used in combination with a pre-configured DT. -> show an error if there is
|
|
||||||
Rollback of the network fails in core CS -> networkOrchestrator. */
|
|
||||||
if(network.getVpcId() != null) {
|
|
||||||
VpcDetailVO detail = _vpcDetailsDao.findDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName);
|
|
||||||
if (detail != null && network.getNetworkACLId() != null) {
|
|
||||||
s_logger.error("Pre-configured DT are used in combination with ACL lists. Which is not supported.");
|
|
||||||
throw new IllegalArgumentException("CloudStack ACLs are not supported with Nuage Pre-configured Domain Template");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(detail != null && !_nuageVspManager.checkIfDomainTemplateExist(network.getDomainId(),detail.getValue(),network.getDataCenterId(),null)){
|
|
||||||
s_logger.error("The provided domain template does not exist on the VSD.");
|
|
||||||
throw new IllegalArgumentException("The provided domain template does not exist on the VSD anymore.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkVO implemented = null;
|
|
||||||
try {
|
|
||||||
if (offering.getGuestType() == GuestType.Isolated && network.getState() != State.Implementing) {
|
|
||||||
throw new IllegalStateException("Network " + networkId + " is not in expected state Implementing, but is in state " + network.getState());
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the Account details and find the type
|
|
||||||
AccountVO networksAccount = _accountDao.findById(network.getAccountId());
|
|
||||||
if (networksAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
|
||||||
String errorMessage = "Networks created by account " + networksAccount.getAccountName() + " of type Project (" + Account.ACCOUNT_TYPE_PROJECT + ") " +
|
|
||||||
"are not yet supported by NuageVsp provider";
|
|
||||||
s_logger.error(errorMessage);
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException(errorMessage, Account.class, network.getAccountId());
|
|
||||||
}
|
|
||||||
|
|
||||||
//We don't support a shared network with UserData and multiple IP ranges at the same time.
|
|
||||||
checkMultipleSubnetsCombinedWithUseData(network);
|
|
||||||
|
|
||||||
long dcId = dest.getDataCenter().getId();
|
|
||||||
//Get physical network id
|
|
||||||
Long physicalNetworkId = network.getPhysicalNetworkId();
|
|
||||||
//Physical network id can be null in Guest Network in Basic zone, so locate the physical network
|
|
||||||
if (physicalNetworkId == null) {
|
|
||||||
physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
|
|
||||||
}
|
|
||||||
|
|
||||||
implemented = new NetworkVO(network.getId(), network, network.getNetworkOfferingId(), network.getGuruName(), network.getDomainId(), network.getAccountId(),
|
|
||||||
network.getRelated(), network.getName(), network.getDisplayText(), network.getNetworkDomain(), network.getGuestType(), network.getDataCenterId(),
|
|
||||||
physicalNetworkId, network.getAclType(), network.getSpecifyIpRanges(), network.getVpcId(), offering.isRedundantRouter(), network.getExternalId());
|
|
||||||
implemented.setUuid(network.getUuid());
|
|
||||||
implemented.setState(State.Allocated);
|
|
||||||
if (network.getGateway() != null) {
|
|
||||||
implemented.setGateway(network.getGateway());
|
|
||||||
}
|
|
||||||
if (network.getCidr() != null) {
|
|
||||||
implemented.setCidr(network.getCidr());
|
|
||||||
}
|
|
||||||
|
|
||||||
implemented.setBroadcastUri(_nuageVspManager.calculateBroadcastUri(implemented));
|
|
||||||
implemented.setBroadcastDomainType(Networks.BroadcastDomainType.Vsp);
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(implemented);
|
|
||||||
|
|
||||||
if (vspNetwork.isShared()) {
|
|
||||||
Boolean previousUnderlay= null;
|
|
||||||
for (VlanVO vlan : _vlanDao.listVlansByNetworkId(networkId)) {
|
|
||||||
boolean underlay = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, vlan);
|
|
||||||
if (previousUnderlay == null || underlay == previousUnderlay) {
|
|
||||||
previousUnderlay = underlay;
|
|
||||||
} else {
|
|
||||||
throw new CloudRuntimeException("Mixed values for the underlay flag for IP ranges in the same subnet is not supported");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (previousUnderlay != null) {
|
|
||||||
vspNetwork = new VspNetwork.Builder().fromObject(vspNetwork)
|
|
||||||
.vlanUnderlay(previousUnderlay)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean implementSucceeded = implement(network.getVpcId(), physicalNetworkId, vspNetwork, implemented, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering));
|
|
||||||
|
|
||||||
if (!implementSucceeded) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(vspNetwork.getDomainTemplateName())) {
|
|
||||||
if (network.getVpcId() != null) {
|
|
||||||
saveVpcDetail(network.getVpcId(), NuageVspManager.nuageDomainTemplateDetailName, vspNetwork.getDomainTemplateName());
|
|
||||||
} else {
|
|
||||||
saveNetworkDetail(implemented.getId(), NuageVspManager.nuageDomainTemplateDetailName, vspNetwork.getDomainTemplateName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String tenantId = context.getDomain().getName() + "-" + context.getAccount().getAccountId();
|
|
||||||
s_logger.info("Implemented OK, network " + implemented.getUuid() + " in tenant " + tenantId + " linked to " + implemented.getBroadcastUri());
|
|
||||||
} finally {
|
|
||||||
_networkDao.releaseFromLockTable(network.getId());
|
|
||||||
}
|
|
||||||
return implemented;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean implement(Long vpcId, long physicalNetworkId, VspNetwork vspNetwork, NetworkVO implemented, VspDhcpDomainOption vspDhcpDomainOption) {
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(physicalNetworkId);
|
|
||||||
final boolean isVsdManaged = vspNetwork.getNetworkRelatedVsdIds()
|
|
||||||
.getVsdSubnetId()
|
|
||||||
.isPresent();
|
|
||||||
if (isVsdManaged) {
|
|
||||||
//Implement cmd was already send in design step.
|
|
||||||
_dcDetailsDao.persist(implemented.getDataCenterId(), vspNetwork.getNetworkRelatedVsdIds().getVsdSubnetId().orElseThrow(() -> new CloudRuntimeException("Managed but no subnetId. How can this happen?")), implemented.getUuid());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImplementNetworkVspCommand cmd = new ImplementNetworkVspCommand(vspNetwork, vspDhcpDomainOption, false);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("ImplementNetworkVspCommand for network " + vspNetwork.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ImplementNetworkVspAnswer implementAnswer = (ImplementNetworkVspAnswer) answer;
|
|
||||||
saveNetworkAndVpcDetails(vspNetwork, implementAnswer.getNetworkRelatedVsdIds(), vpcId);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveNetworkAndVpcDetails(VspNetwork vspNetwork, NetworkRelatedVsdIds networkRelatedVsdIds, Long vpcId) {
|
|
||||||
if (!vspNetwork.isShared() && !vspNetwork.getNetworkRelatedVsdIds().equals(networkRelatedVsdIds)) {
|
|
||||||
Map<String, String> networkDetails = constructNetworkDetails(networkRelatedVsdIds, vspNetwork.isVpc());
|
|
||||||
|
|
||||||
long networkId = vspNetwork.getId();
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> networkDetail : networkDetails.entrySet()) {
|
|
||||||
saveNetworkDetail(vspNetwork.getId(), networkDetail.getKey(), networkDetail.getValue());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(vspNetwork.isVpc()) {
|
|
||||||
Map<String, String> vpcDetails = constructVpcDetails(networkRelatedVsdIds);
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> vpcDetail : vpcDetails.entrySet()) {
|
|
||||||
saveVpcDetail(vpcId, vpcDetail.getKey(), vpcDetail.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveVpcDetail(Long vpcId, String key, String value) {
|
|
||||||
_vpcDetailsDao.addDetail(vpcId, key, value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void saveNetworkDetail(long networkId, String key, String value) {
|
|
||||||
_networkDetailsDao.addDetail(networkId, key, value, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, String> constructNetworkDetails(NetworkRelatedVsdIds networkRelatedVsdIds, boolean isVpc) {
|
|
||||||
Map<String, String> networkDetails = Maps.newHashMap();
|
|
||||||
|
|
||||||
if (!isVpc) {
|
|
||||||
networkRelatedVsdIds.getVsdDomainId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v));
|
|
||||||
networkRelatedVsdIds.getVsdZoneId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v));
|
|
||||||
}
|
|
||||||
networkRelatedVsdIds.getVsdSubnetId().ifPresent(v -> networkDetails.put(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID, v));
|
|
||||||
|
|
||||||
return networkDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, String> constructVpcDetails(NetworkRelatedVsdIds networkRelatedVsdIds) {
|
|
||||||
Map<String, String> vpcDetails = Maps.newHashMap();
|
|
||||||
|
|
||||||
networkRelatedVsdIds.getVsdDomainId().ifPresent(v -> vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID, v));
|
|
||||||
networkRelatedVsdIds.getVsdZoneId().ifPresent(v -> vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID, v));
|
|
||||||
if (networkRelatedVsdIds.isVsdManaged()) {
|
|
||||||
vpcDetails.put(NuageVspManager.NETWORK_METADATA_VSD_MANAGED, "true");
|
|
||||||
}
|
|
||||||
|
|
||||||
return vpcDetails;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
|
|
||||||
if (vm.getType() != VirtualMachine.Type.DomainRouter && _nuageVspEntityBuilder.usesVirtualRouter(network.getNetworkOfferingId())) {
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
if (nic != null && nic.getRequestedIPv4() != null && nic.getRequestedIPv4().equals(vspNetwork.getVirtualRouterIp())) {
|
|
||||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
|
||||||
s_logger.error("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved for the VR in network " + network);
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("Unable to acquire requested Guest IP address " + nic.getRequestedIPv4() + " because it is reserved " +
|
|
||||||
"for the VR in network " + network, DataCenter.class,dc.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.allocate(network, nic, vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void reserve(NicProfile nic, Network network, VirtualMachineProfile vm, DeployDestination dest, ReservationContext context)
|
|
||||||
throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException {
|
|
||||||
boolean lockedNetwork = lockNetworkForUserVm(network, vm);
|
|
||||||
if (lockedNetwork && s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Locked network " + network.getId() + " for creation of user VM " + vm.getInstanceName());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
//We don't support a shared network with UserData and multiple IP ranges at the same time.
|
|
||||||
checkMultipleSubnetsCombinedWithUseData(network);
|
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Handling reserve() call back to with Create a new VM or add an interface to existing VM in network " + network.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
DataCenter dc = _dcDao.findById(network.getDataCenterId());
|
|
||||||
AccountVO neworkAccountDetails = _accountDao.findById(network.getAccountId());
|
|
||||||
if (neworkAccountDetails.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("CS project support is not yet implemented in NuageVsp", DataCenter.class, dc.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(network.getBroadcastUri().getPath()) || !network.getBroadcastUri().getPath().startsWith("/")) {
|
|
||||||
throw new IllegalStateException("The broadcast URI path " + network.getBroadcastUri() + " is empty or in an incorrect format.");
|
|
||||||
}
|
|
||||||
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network);
|
|
||||||
|
|
||||||
boolean vrAddedToNuage = vm.getType() == VirtualMachine.Type.DomainRouter && vspNetwork.getVirtualRouterIp()
|
|
||||||
.equals("null");
|
|
||||||
if (vrAddedToNuage) {
|
|
||||||
//In case a VR is added due to upgrade network offering - recalculate the broadcast uri before using it.
|
|
||||||
_nuageVspManager.updateBroadcastUri(network);
|
|
||||||
network = _networkDao.findById(network.getId());
|
|
||||||
vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(vm.getVirtualMachine().getDomainId(), network, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vspNetwork.isShared()) {
|
|
||||||
vspNetwork = _nuageVspEntityBuilder.updateVspNetworkByPublicIp(vspNetwork, network, nic.getIPv4Address());
|
|
||||||
|
|
||||||
if (VirtualMachine.Type.DomainRouter.equals(vm.getType()) && !nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) {
|
|
||||||
if(s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("VR got spawned with a different IP, releasing the previously allocated public IP " + nic.getIPv4Address());
|
|
||||||
}
|
|
||||||
IPAddressVO oldIpAddress = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), nic.getIPv4Address());
|
|
||||||
_ipAddressDao.unassignIpAddress(oldIpAddress.getId());
|
|
||||||
_ipAddressDao.mark(network.getDataCenterId(), new Ip(vspNetwork.getVirtualRouterIp()));
|
|
||||||
} else if (VirtualMachine.Type.User.equals(vm.getType()) && nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) {
|
|
||||||
s_logger.error("Deploying a user VM with the same IP as the VR is not allowed.");
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("Deploying a user VM with the same IP " + nic.getIPv4Address() + " as the VR is not allowed.",
|
|
||||||
Network.class, network.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure the shared network is present
|
|
||||||
NetworkOffering offering = _ntwkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
if (!implement(network.getVpcId(), network.getPhysicalNetworkId(), vspNetwork, null, _nuageVspEntityBuilder.buildNetworkDhcpOption(network, offering))) {
|
|
||||||
s_logger.error("Failed to implement shared network " + network.getUuid() + " under domain " + context.getDomain().getUuid());
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("Failed to implement shared network " + network.getUuid() + " under domain " +
|
|
||||||
context.getDomain().getUuid(), Network.class, network.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set flags for dhcp options
|
|
||||||
boolean networkHasDns = networkHasDns(network);
|
|
||||||
|
|
||||||
Map<Long, Boolean> networkHasDnsCache = Maps.newHashMap();
|
|
||||||
networkHasDnsCache.put(network.getId(), networkHasDns);
|
|
||||||
|
|
||||||
// Determine if dhcp options of the other nics in the network need to be updated
|
|
||||||
if (vm.getType() == VirtualMachine.Type.DomainRouter && network.getState() != State.Implementing) {
|
|
||||||
updateDhcpOptionsForExistingVms(network, nuageVspHost, vspNetwork, networkHasDns, networkHasDnsCache);
|
|
||||||
//update the extra DHCP options
|
|
||||||
|
|
||||||
}
|
|
||||||
// Update broadcast Uri to enable VR ip update
|
|
||||||
if (!network.getBroadcastUri().getPath().substring(1).equals(vspNetwork.getVirtualRouterIp())) {
|
|
||||||
NetworkVO networkToUpdate = _networkDao.findById(network.getId());
|
|
||||||
String broadcastUriStr = networkToUpdate.getUuid() + "/" + vspNetwork.getVirtualRouterIp();
|
|
||||||
networkToUpdate.setBroadcastUri(Networks.BroadcastDomainType.Vsp.toUri(broadcastUriStr));
|
|
||||||
_networkDao.update(network.getId(), networkToUpdate);
|
|
||||||
if (network instanceof NetworkVO) {
|
|
||||||
((NetworkVO) network).setBroadcastUri(networkToUpdate.getBroadcastUri());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nic.setBroadcastUri(network.getBroadcastUri());
|
|
||||||
nic.setIsolationUri(network.getBroadcastUri());
|
|
||||||
|
|
||||||
VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(vm.getVirtualMachine(), network);
|
|
||||||
|
|
||||||
if (vm.isRollingRestart()) {
|
|
||||||
((NetworkVO)network).setRollingRestart(true);
|
|
||||||
} else {
|
|
||||||
//NicProfile does not contain the NIC UUID. We need this information to set it in the VMInterface and VPort
|
|
||||||
//that we create in VSP
|
|
||||||
NicVO nicFromDb = _nicDao.findById(nic.getId());
|
|
||||||
IPAddressVO staticNatIp = _ipAddressDao.findByVmIdAndNetworkId(network.getId(), vm.getId());
|
|
||||||
VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic);
|
|
||||||
VspStaticNat vspStaticNat = null;
|
|
||||||
if (staticNatIp != null) {
|
|
||||||
VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId());
|
|
||||||
vspStaticNat = _nuageVspEntityBuilder.buildVspStaticNat(null, staticNatIp, staticNatVlan, vspNic);
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, nicFromDb);
|
|
||||||
VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(nicFromDb, defaultHasDns, networkHasDns);
|
|
||||||
ReserveVmInterfaceVspCommand cmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, vspStaticNat, dhcpOption);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("ReserveVmInterfaceNuageVspCommand failed for NIC " + nic.getId() + " attached to VM " + vm.getId() + " in network " + network.getId());
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage VSP.", Network.class, network.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vspVm.getDomainRouter() == Boolean.TRUE) {
|
|
||||||
nic.setIPv4Address(vspVm.getDomainRouterIp());
|
|
||||||
}
|
|
||||||
|
|
||||||
} finally {
|
|
||||||
if (network != null && lockedNetwork) {
|
|
||||||
_networkDao.releaseFromLockTable(network.getId());
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Unlocked network " + network.getId() + " for creation of user VM " + vm.getInstanceName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateExtraDhcpOptionsForExistingVm(Network network, Nic nic) {
|
|
||||||
_networkOrchestrationService.configureExtraDhcpOptions(network, nic.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateDhcpOptionsForExistingVms(Network network, HostVO nuageVspHost, VspNetwork vspNetwork, boolean networkHasDns, Map<Long, Boolean> networkHasDnsCache)
|
|
||||||
throws InsufficientVirtualNetworkCapacityException {
|
|
||||||
// Update dhcp options if a VR is added when we are not initiating the network
|
|
||||||
if(s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug(String.format("DomainRouter is added to an existing network: %s in state: %s", network.getName(), network.getState()));
|
|
||||||
}
|
|
||||||
|
|
||||||
List<NicVO> userNics = _nicDao.listByNetworkId(network.getId());
|
|
||||||
LinkedListMultimap<Long, VspDhcpVMOption> dhcpOptionsPerDomain = LinkedListMultimap.create();
|
|
||||||
|
|
||||||
for (Iterator<NicVO> iterator = userNics.iterator(); iterator.hasNext(); ) {
|
|
||||||
NicVO userNic = iterator.next();
|
|
||||||
if (userNic.getVmType() == VirtualMachine.Type.DomainRouter || userNic.getState() != Nic.State.Reserved) {
|
|
||||||
iterator.remove();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
VMInstanceVO userVm = _vmInstanceDao.findById(userNic.getInstanceId());
|
|
||||||
boolean defaultHasDns = getDefaultHasDns(networkHasDnsCache, userNic);
|
|
||||||
VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(userNic, defaultHasDns, networkHasDns);
|
|
||||||
dhcpOptionsPerDomain.put(userVm.getDomainId(), dhcpOption);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Long domainId : dhcpOptionsPerDomain.keySet()) {
|
|
||||||
VspDomain vspDomain = _nuageVspEntityBuilder.buildVspDomain(_domainDao.findById(domainId));
|
|
||||||
VspNetwork vspNetworkForDomain = new VspNetwork.Builder().fromObject(vspNetwork).domain(vspDomain).build();
|
|
||||||
List<VspDhcpVMOption> dhcpOptions = dhcpOptionsPerDomain.get(domainId);
|
|
||||||
UpdateDhcpOptionVspCommand cmd = new UpdateDhcpOptionVspCommand(dhcpOptions, vspNetworkForDomain);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("UpdateDhcpOptionVspCommand failed at \"reserve\" for network " + vspNetwork.getName() + " under domain " + vspNetwork.getVspDomain().getName());
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
throw new InsufficientVirtualNetworkCapacityException("Failed to reserve VM in Nuage VSP.", Network.class, network.getId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (NicVO userNic : userNics) {
|
|
||||||
updateExtraDhcpOptionsForExistingVm(network, userNic);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private boolean isServiceProvidedByVR(Network network, Network.Service service ) {
|
|
||||||
return (_networkModel.areServicesSupportedInNetwork(network.getId(), service) &&
|
|
||||||
( _networkModel.isProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.VirtualRouter) ||
|
|
||||||
_networkModel.isProviderSupportServiceInNetwork(network.getId(), service, Network.Provider.VPCVirtualRouter)));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkMultipleSubnetsCombinedWithUseData(Network network) {
|
|
||||||
if (isServiceProvidedByVR(network, Network.Service.UserData)) {
|
|
||||||
List<VlanVO> vlanVOs = _vlanDao.listVlansByNetworkId(network.getId());
|
|
||||||
if (vlanVOs.stream()
|
|
||||||
.map(VlanVO::getVlanGateway)
|
|
||||||
.distinct()
|
|
||||||
.count() > 1) {
|
|
||||||
s_logger.error("NuageVsp provider does not support multiple subnets in combination with user data. Network: " + network + ", vlans: " + vlanVOs);
|
|
||||||
throw new UnsupportedServiceException("NuageVsp provider does not support multiple subnets in combination with user data.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean canHandle(NetworkOffering offering, final NetworkType networkType, final PhysicalNetwork physicalNetwork) {
|
|
||||||
if (networkType == NetworkType.Advanced
|
|
||||||
&& isMyTrafficType(offering.getTrafficType())
|
|
||||||
&& isMyIsolationMethod(physicalNetwork)
|
|
||||||
&& (offering.getGuestType() == GuestType.Isolated || offering.getGuestType() == GuestType.Shared)
|
|
||||||
&& hasRequiredServices(offering)) {
|
|
||||||
if (_configMgr.isOfferingForVpc(offering) && !offering.isPersistent()) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle VPC tiers which use a network offering which are not persistent");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
} else if (offering.getGuestType() == GuestType.Shared) {
|
|
||||||
List<String> supportedSharedNetworkServices = Lists.newArrayList(Network.Service.Connectivity.getName(), Network.Service.Dhcp.getName(), Network.Service.UserData.getName());
|
|
||||||
List<String> offeringServices = _ntwkOfferingSrvcDao.listServicesForNetworkOffering(offering.getId());
|
|
||||||
if (!supportedSharedNetworkServices.containsAll(offeringServices)) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("We only support " + Iterables.toString(supportedSharedNetworkServices) + " services for shared networks");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
if (s_logger.isTraceEnabled()) {
|
|
||||||
s_logger.trace("We only take care of networks in zone of type " + NetworkType.Advanced + " without VLAN");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean hasRequiredServices(NetworkOffering networkOffering) {
|
|
||||||
final Map<Network.Service, Set<Network.Provider>> serviceProviderMap = _networkModel.getNetworkOfferingServiceProvidersMap(networkOffering.getId());
|
|
||||||
|
|
||||||
if (!serviceProviderMap.get(Network.Service.Connectivity).contains(Network.Provider.NuageVsp)) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as Connectivity provider");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (networkOffering.getGuestType() == GuestType.Isolated
|
|
||||||
&& !serviceProviderMap.get(Network.Service.SourceNat).contains(Network.Provider.NuageVsp)) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("NuageVsp can't handle networks which use a network offering without NuageVsp as SourceNat provider");
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@DB
|
|
||||||
public void deallocate(Network network, NicProfile nic, VirtualMachineProfile vm) {
|
|
||||||
boolean lockedNetwork = lockNetworkForUserVm(network, vm);
|
|
||||||
if (lockedNetwork && s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Locked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName());
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
final VirtualMachine virtualMachine = vm.getVirtualMachine();
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Handling deallocate() call back, which is called when a VM is destroyed or interface is removed, " + "to delete VM Interface with IP "
|
|
||||||
+ nic.getIPv4Address() + " from a VM " + vm.getInstanceName() + " with state " + virtualMachine
|
|
||||||
.getState());
|
|
||||||
}
|
|
||||||
|
|
||||||
NicVO nicFromDb = _nicDao.findById(nic.getId());
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(virtualMachine
|
|
||||||
.getDomainId(), network);
|
|
||||||
VspVm vspVm = _nuageVspEntityBuilder.buildVspVm(virtualMachine, network);
|
|
||||||
VspNic vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb.getUuid(), nic);
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
|
|
||||||
|
|
||||||
DeallocateVmVspCommand cmd = new DeallocateVmVspCommand(vspNetwork, vspVm, vspNic);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("DeallocateVmNuageVspCommand for VM " + vm.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// In case of shared network, when a User VM is spawned with the same IP as the VR, and it gets cleaned up, make sure we do not release the public IP
|
|
||||||
// because it is still allocated for the VR.
|
|
||||||
if (vspNetwork.isShared() && VirtualMachine.Type.User.equals(vm.getType()) && nic.getIPv4Address().equals(vspNetwork.getVirtualRouterIp())) {
|
|
||||||
nic.deallocate();
|
|
||||||
} else {
|
|
||||||
super.deallocate(network, nic, vm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virtualMachine.getType() == VirtualMachine.Type.DomainRouter) {
|
|
||||||
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(network.getId(), VirtualRouter.Role.VIRTUAL_ROUTER);
|
|
||||||
final DomainRouterVO otherRouter = routers.stream()
|
|
||||||
.filter(r -> r.getId() != vm.getId())
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
|
|
||||||
if (otherRouter != null) {
|
|
||||||
nicFromDb = _nicDao.findByNtwkIdAndInstanceId(network.getId(), otherRouter.getId());
|
|
||||||
vspVm = _nuageVspEntityBuilder.buildVspVm(otherRouter, network);
|
|
||||||
vspNic = _nuageVspEntityBuilder.buildVspNic(nicFromDb);
|
|
||||||
|
|
||||||
VspDhcpVMOption dhcpOption = _nuageVspEntityBuilder.buildVmDhcpOption(nicFromDb, false, false);
|
|
||||||
ReserveVmInterfaceVspCommand reserveCmd = new ReserveVmInterfaceVspCommand(vspNetwork, vspVm, vspNic, null, dhcpOption);
|
|
||||||
|
|
||||||
answer = _agentMgr.easySend(nuageVspHost.getId(), reserveCmd);
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("DeallocateVmNuageVspCommand for VM " + vm.getUuid() + " failed on Nuage VSD " + nuageVspHost.getDetail("hostname"));
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (network != null && lockedNetwork) {
|
|
||||||
_networkDao.releaseFromLockTable(network.getId());
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Unlocked network " + network.getId() + " for deallocation of user VM " + vm.getInstanceName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean lockNetworkForUserVm(Network network, VirtualMachineProfile vm) {
|
|
||||||
if (!vm.getVirtualMachine().getType().isUsedBySystem()) {
|
|
||||||
long networkId = network.getId();
|
|
||||||
network = _networkDao.acquireInLockTable(network.getId(), 1200);
|
|
||||||
if (network == null) {
|
|
||||||
throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void shutdown(NetworkProfile profile, NetworkOffering offering) {
|
|
||||||
super.shutdown(profile, offering);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean trash(Network network, NetworkOffering offering) {
|
|
||||||
long networkId = network.getId();
|
|
||||||
network = _networkDao.acquireInLockTable(networkId, 1200);
|
|
||||||
if (network == null) {
|
|
||||||
throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Handling trash() call back to delete the network " + network.getName() + " with uuid " + network.getUuid() + " from VSP");
|
|
||||||
}
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
|
|
||||||
|
|
||||||
boolean networkMigrationCopy = network.getRelated() != network.getId();
|
|
||||||
|
|
||||||
if (networkMigrationCopy) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Network " + network.getName() + " is a copy of a migrated network. Cleaning up network details of related network.");
|
|
||||||
}
|
|
||||||
cleanUpNetworkCaching(network.getRelated());
|
|
||||||
}
|
|
||||||
cleanUpNetworkCaching(network.getId());
|
|
||||||
|
|
||||||
//Clean up VSD managed subnet caching
|
|
||||||
if (vspNetwork.getNetworkRelatedVsdIds().isVsdManaged()) {
|
|
||||||
final long dataCenterId = network.getDataCenterId();
|
|
||||||
vspNetwork.getNetworkRelatedVsdIds().getVsdSubnetId().ifPresent(subnetId -> {
|
|
||||||
_dcDetailsDao.removeDetail(dataCenterId, subnetId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
|
|
||||||
TrashNetworkVspCommand cmd = new TrashNetworkVspCommand(vspNetwork);
|
|
||||||
Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
|
|
||||||
if (answer == null || !answer.getResult()) {
|
|
||||||
s_logger.error("TrashNetworkNuageVspCommand for network " + network.getUuid() + " failed");
|
|
||||||
if ((null != answer) && (null != answer.getDetails())) {
|
|
||||||
s_logger.error(answer.getDetails());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
_networkDao.releaseFromLockTable(network.getId());
|
|
||||||
}
|
|
||||||
return super.trash(network, offering);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void cleanUpNetworkCaching(long id) {
|
|
||||||
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID);
|
|
||||||
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID);
|
|
||||||
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID);
|
|
||||||
_networkDetailsDao.removeDetail(id, NuageVspManager.NETWORK_METADATA_VSD_MANAGED);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean networkHasDns(Network network) {
|
|
||||||
|
|
||||||
if (network != null) {
|
|
||||||
List<String> dnsProviders = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(network.getNetworkOfferingId(), Network.Service.Dns);
|
|
||||||
return dnsProviders.contains(Network.Provider.VirtualRouter.getName())
|
|
||||||
|| dnsProviders.contains(Network.Provider.VPCVirtualRouter.getName());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean getDefaultHasDns(Map<Long, Boolean> cache, Nic nic) {
|
|
||||||
Long networkId = nic.isDefaultNic()
|
|
||||||
? Long.valueOf(nic.getNetworkId())
|
|
||||||
: getDefaultNetwork(nic.getInstanceId());
|
|
||||||
|
|
||||||
Boolean hasDns = cache.computeIfAbsent(networkId, k -> networkHasDns(_networkDao.findById(networkId)));
|
|
||||||
return hasDns;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Long getDefaultNetwork(long vmId) {
|
|
||||||
NicVO defaultNic = _nicDao.findDefaultNicForVM(vmId);
|
|
||||||
if (defaultNic != null) return defaultNic.getNetworkId();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,91 +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.manager;
|
|
||||||
|
|
||||||
import com.cloud.agent.Listener;
|
|
||||||
import com.cloud.agent.api.AgentControlAnswer;
|
|
||||||
import com.cloud.agent.api.AgentControlCommand;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.agent.api.StartupCommand;
|
|
||||||
import com.cloud.exception.ConnectionException;
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
import com.cloud.host.Status;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by maximusf on 7/19/17.
|
|
||||||
*/
|
|
||||||
abstract class AbstractListener implements Listener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processAnswers(long agentId, long seq, Answer[] answers) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processCommands(long agentId, long seq, Command[] commands) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AgentControlAnswer processControlCommand(long agentId, AgentControlCommand cmd) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processHostAdded(long hostId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processConnect(Host host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processDisconnect(long agentId, Status state) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processHostAboutToBeRemoved(long hostId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processHostRemoved(long hostId, long clusterId) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isRecurring() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getTimeout() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean processTimeout(long agentId, long seq) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,173 +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.manager;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
|
||||||
import org.apache.cloudstack.framework.config.ConfigKey.Scope;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.EntityExistsCommand;
|
|
||||||
import com.cloud.api.commands.AddNuageVspDeviceCmd;
|
|
||||||
import com.cloud.api.commands.AssociateNuageVspDomainTemplateCmd;
|
|
||||||
import com.cloud.api.commands.DeleteNuageVspDeviceCmd;
|
|
||||||
import com.cloud.api.commands.ListNuageVspDevicesCmd;
|
|
||||||
import com.cloud.api.commands.ListNuageVspDomainTemplatesCmd;
|
|
||||||
import com.cloud.api.commands.UpdateNuageVspDeviceCmd;
|
|
||||||
import com.cloud.api.response.NuageVlanIpRangeResponse;
|
|
||||||
import com.cloud.api.response.NuageVspDeviceResponse;
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.api.response.NuageVspDomainTemplateResponse;
|
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.utils.component.PluggableService;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public interface NuageVspManager extends PluggableService {
|
|
||||||
|
|
||||||
String nuageVPCOfferingName = "Nuage VSP VPC Offering";
|
|
||||||
|
|
||||||
String nuageVPCOfferingDisplayText = "Nuage VSP VPC Offering";
|
|
||||||
|
|
||||||
String nuageDomainTemplateDetailName = "domainTemplateName";
|
|
||||||
|
|
||||||
String nuageUnderlayVlanIpRangeDetailKey = "nuage.underlay";
|
|
||||||
|
|
||||||
ConfigKey<Boolean> NuageVspConfigDns = new ConfigKey<Boolean>(Boolean.class, "nuagevsp.configure.dns", "Advanced", "true",
|
|
||||||
"Defines if NuageVsp plugin needs to configure DNS setting for a VM or not. True will configure the DNS and false will not configure the DNS settings", true,
|
|
||||||
Scope.Global, null);
|
|
||||||
|
|
||||||
ConfigKey<Boolean> NuageVspDnsExternal = new ConfigKey<Boolean>(
|
|
||||||
Boolean.class,
|
|
||||||
"nuagevsp.dns.external",
|
|
||||||
"Advanced",
|
|
||||||
"true",
|
|
||||||
"Defines if NuageVsp plugin needs to configure either internal or external DNS server configured during Zone provisioning. "
|
|
||||||
+ "Value true uses the external DNS and value false uses the internal DNS to configure in the VM. But, this flag depends on "
|
|
||||||
+ "nuagevsp.configure.dns. Only if nuagevsp.configure.dns is set to true, DNS server will be configured in the VM. "
|
|
||||||
+ "If nuagevsp.configure.dns is false, DNS server will not be configured in the VM. Default value for this flag is true",
|
|
||||||
true, Scope.Global, null);
|
|
||||||
|
|
||||||
ConfigKey<String> NuageVspConfigGateway = new ConfigKey<String>(String.class, "nuagevsp.configure.gateway.systemid", "Advanced", "",
|
|
||||||
"Defines the systemID of the gateway configured in VSP", true, Scope.Global, null);
|
|
||||||
|
|
||||||
ConfigKey<String> NuageVspSharedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.sharedntwk.domaintemplate.name",
|
|
||||||
"Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for shared networks", true, Scope.Global, null);
|
|
||||||
|
|
||||||
ConfigKey<String> NuageVspVpcDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.vpc.domaintemplate.name",
|
|
||||||
"Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for VPCs", true, Scope.Global, null);
|
|
||||||
|
|
||||||
ConfigKey<String> NuageVspIsolatedNetworkDomainTemplateName = new ConfigKey<String>(String.class, "nuagevsp.isolatedntwk.domaintemplate.name",
|
|
||||||
"Advanced", "", "Defines if NuageVsp plugin needs to use pre created Domain Template configured in VSP for isolated networks", true, Scope.Global, null);
|
|
||||||
|
|
||||||
String NETWORK_METADATA_VSD_DOMAIN_ID = "vsdDomainId";
|
|
||||||
|
|
||||||
String NETWORK_METADATA_VSD_ZONE_ID = "vsdZoneId";
|
|
||||||
|
|
||||||
String NETWORK_METADATA_VSD_SUBNET_ID = "vsdSubnetId";
|
|
||||||
|
|
||||||
String NETWORK_METADATA_VSD_MANAGED = "isVsdManaged";
|
|
||||||
|
|
||||||
String CMSID_CONFIG_KEY = "nuagevsp.cms.id";
|
|
||||||
|
|
||||||
String NUAGE_VSP_ISOLATION = "VSP";
|
|
||||||
|
|
||||||
NuageVspDeviceVO addNuageVspDevice(AddNuageVspDeviceCmd cmd);
|
|
||||||
|
|
||||||
NuageVspDeviceVO updateNuageVspDevice(UpdateNuageVspDeviceCmd cmd);
|
|
||||||
|
|
||||||
NuageVspDeviceResponse createNuageVspDeviceResponse(NuageVspDeviceVO nuageVspDeviceVO);
|
|
||||||
|
|
||||||
boolean deleteNuageVspDevice(DeleteNuageVspDeviceCmd cmd);
|
|
||||||
|
|
||||||
List<NuageVspDeviceVO> listNuageVspDevices(ListNuageVspDevicesCmd cmd);
|
|
||||||
|
|
||||||
List<String> getDnsDetails(long dataCenterId);
|
|
||||||
|
|
||||||
List<String> getGatewaySystemIds();
|
|
||||||
|
|
||||||
HostVO getNuageVspHost(long physicalNetworkId);
|
|
||||||
|
|
||||||
boolean updateNuageUnderlayVlanIpRange(long vlanIpRangeId, boolean enabled);
|
|
||||||
|
|
||||||
List<NuageVlanIpRangeResponse> filterNuageVlanIpRanges(List<? extends Vlan> vlanIpRanges, Boolean underlay);
|
|
||||||
|
|
||||||
List<NuageVspDomainTemplateResponse> listNuageVspDomainTemplates(ListNuageVspDomainTemplatesCmd cmd);
|
|
||||||
|
|
||||||
List<NuageVspDomainTemplateResponse> listNuageVspDomainTemplates(long domainId, String keyword, Long zoneId, Long physicalNetworkId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Associates a Nuage Vsp domain template with a
|
|
||||||
* @param cmd Associate cmd which contains all the data
|
|
||||||
*/
|
|
||||||
void associateNuageVspDomainTemplate(AssociateNuageVspDomainTemplateCmd cmd);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queries the VSD to check if the entity provided in the entityCmd exists on the VSD
|
|
||||||
* @param cmd entityCommand which contains the ACS class of the entity and the UUID
|
|
||||||
* @param hostId the hostId of the VSD
|
|
||||||
* @return true if an entity exists with the UUI on the VSD, otherwise false.
|
|
||||||
*/
|
|
||||||
boolean entityExist(EntityExistsCommand cmd, Long hostId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the preconfigured domain template for a given network
|
|
||||||
* @param network the network for which we want to set the domain template
|
|
||||||
* @param domainTemplateName the domain template name we want to use
|
|
||||||
*/
|
|
||||||
void setPreConfiguredDomainTemplateName(Network network, String domainTemplateName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current pre configured domain template for a given network
|
|
||||||
* @param network the network for which we want the domain template name
|
|
||||||
* @return the domain template name
|
|
||||||
*/
|
|
||||||
String getPreConfiguredDomainTemplateName(Network network);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a given domain template exists or not on the VSD.
|
|
||||||
* @param domainId Id of the domain to search in.
|
|
||||||
* @param domainTemplate The name of the domain template for which we need to query the VSD.
|
|
||||||
* @param zoneId zoneId OR PhysicalNetworkId needs to be provided.
|
|
||||||
* @param physicalNetworkId zoneId OR PhysicalNetworkId needs to be provided.
|
|
||||||
* @return true if the domain template exists on the VSD else false if it does not exist on the VSD
|
|
||||||
*/
|
|
||||||
boolean checkIfDomainTemplateExist(Long domainId, String domainTemplate, Long zoneId, Long physicalNetworkId);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* calculates the new broadcast uri of a network and persists it in the database
|
|
||||||
* @param network the network for which you want to calculate the broadcast uri
|
|
||||||
* @throws InsufficientVirtualNetworkCapacityException in case there is no free ip that can be used as the VR ip.
|
|
||||||
*/
|
|
||||||
void updateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the broadcast uri based on the network and the offering of the given network
|
|
||||||
* @param network the network for which you want to calculate the broadcast uri
|
|
||||||
* @return the calculated broadcast uri
|
|
||||||
* @throws InsufficientVirtualNetworkCapacityException in case there is no free ip that can be used as the VR ip.
|
|
||||||
*/
|
|
||||||
URI calculateBroadcastUri(Network network) throws InsufficientVirtualNetworkCapacityException;
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,78 +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.Hashtable;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.RequestWrapper;
|
|
||||||
import com.cloud.resource.ServerResource;
|
|
||||||
|
|
||||||
public class NuageVspRequestWrapper extends RequestWrapper {
|
|
||||||
|
|
||||||
private static NuageVspRequestWrapper instance;
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private final static Set<Class<? extends CommandWrapper>> baseSet;
|
|
||||||
|
|
||||||
static {
|
|
||||||
Reflections baseWrappers = new Reflections("com.cloud.network.vsp.resource.wrapper");
|
|
||||||
baseSet = baseWrappers.getSubTypesOf(CommandWrapper.class);
|
|
||||||
instance = new NuageVspRequestWrapper();
|
|
||||||
}
|
|
||||||
|
|
||||||
private NuageVspRequestWrapper() {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private void init() {
|
|
||||||
// NuageVspResource commands
|
|
||||||
final Hashtable<Class<? extends Command>, CommandWrapper> vspCommands = processAnnotations(baseSet);
|
|
||||||
|
|
||||||
resources.put(NuageVspResource.class, vspCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NuageVspRequestWrapper getInstance() {
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
@Override
|
|
||||||
public Answer execute(final Command command, final ServerResource serverResource) {
|
|
||||||
final Class<? extends ServerResource> resourceClass = serverResource.getClass();
|
|
||||||
|
|
||||||
final Hashtable<Class<? extends Command>, CommandWrapper> resourceCommands = retrieveResource(command, resourceClass);
|
|
||||||
|
|
||||||
CommandWrapper<Command, Answer, ServerResource> commandWrapper = retrieveCommands(command.getClass(), resourceCommands);
|
|
||||||
|
|
||||||
while (commandWrapper == null) {
|
|
||||||
//Could not find the command in the given resource, will traverse the family tree.
|
|
||||||
commandWrapper = retryWhenAllFails(command, resourceClass, resourceCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
return commandWrapper.execute(command, serverResource);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,310 +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.concurrent.atomic.AtomicLong;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
import com.google.common.base.Strings;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspAclClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspApiClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspElementClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspPluginClientLoader;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspHost;
|
|
||||||
import net.nuage.vsp.acs.client.common.RequestType;
|
|
||||||
import net.nuage.vsp.acs.client.common.model.NuageVspEntity;
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.IAgentControl;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.agent.api.PingCommand;
|
|
||||||
import com.cloud.agent.api.PingNuageVspCommand;
|
|
||||||
import com.cloud.agent.api.StartupCommand;
|
|
||||||
import com.cloud.agent.api.StartupVspCommand;
|
|
||||||
import com.cloud.host.Host;
|
|
||||||
import com.cloud.resource.ServerResource;
|
|
||||||
import com.cloud.utils.component.ManagerBase;
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import com.cloud.utils.mgmt.JmxUtil;
|
|
||||||
|
|
||||||
public class NuageVspResource extends ManagerBase implements ServerResource, VspStatisticsMBean {
|
|
||||||
private static final Logger s_logger = Logger.getLogger(NuageVspResource.class);
|
|
||||||
|
|
||||||
private String _guid;
|
|
||||||
private String _zoneId;
|
|
||||||
private String _hostName;
|
|
||||||
private boolean _shouldAudit = true;
|
|
||||||
|
|
||||||
private VspHost _vspHost;
|
|
||||||
|
|
||||||
private static final String NUAGE_VSP_PLUGIN_ERROR_MESSAGE = "Nuage Vsp plugin client is not installed";
|
|
||||||
protected NuageVspPluginClientLoader _clientLoader;
|
|
||||||
|
|
||||||
public VspHost validate(Map<String, ?> params) throws ConfigurationException {
|
|
||||||
return validate(NuageVspResourceConfiguration.fromConfiguration(params));
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspHost validate(NuageVspResourceConfiguration configuration) throws ConfigurationException {
|
|
||||||
configuration.validate();
|
|
||||||
|
|
||||||
VspHost newVspHost = configuration.buildVspHost();
|
|
||||||
|
|
||||||
|
|
||||||
if (!newVspHost.getApiVersion().isSupported()) {
|
|
||||||
s_logger.warn(String.format("[UPGRADE] API version %s of Nuage Vsp Device %s should be updated.", newVspHost.getApiVersion(), configuration.hostName()));
|
|
||||||
}
|
|
||||||
|
|
||||||
_guid = configuration.guid();
|
|
||||||
_zoneId = configuration.zoneId();
|
|
||||||
_hostName = configuration.hostName();
|
|
||||||
_name = configuration.name();
|
|
||||||
|
|
||||||
try {
|
|
||||||
final NuageVspPluginClientLoader clientLoader = getClientLoader(newVspHost);
|
|
||||||
clientLoader.getNuageVspApiClient().login();
|
|
||||||
|
|
||||||
_vspHost = newVspHost;
|
|
||||||
_clientLoader = clientLoader;
|
|
||||||
} catch (NuageVspException e) {
|
|
||||||
s_logger.error(e.getMessage(), e);
|
|
||||||
throw new CloudRuntimeException(e.getMessage(), e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return _vspHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVSDStatistics() {
|
|
||||||
return _clientLoader.getNuageVspStatistics().getVsdCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByEntityType(String entity) {
|
|
||||||
try {
|
|
||||||
NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity);
|
|
||||||
return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByRequestType(String requestType) {
|
|
||||||
try {
|
|
||||||
RequestType requestTypeValue = RequestType.valueOf(requestType);
|
|
||||||
return _clientLoader.getNuageVspStatistics().getVsdCount(requestTypeValue);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) {
|
|
||||||
try {
|
|
||||||
RequestType requestTypeValue = RequestType.valueOf(requestType);
|
|
||||||
NuageVspEntity nuageVspEntity = NuageVspEntity.valueOf(entity);
|
|
||||||
return _clientLoader.getNuageVspStatistics().getVsdCount(nuageVspEntity, requestTypeValue);
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Map<String, AtomicLong> convertHashMap(Map<RequestType, AtomicLong> map) {
|
|
||||||
return map.entrySet()
|
|
||||||
.stream()
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
e -> e.getKey().toString(),
|
|
||||||
Map.Entry::getValue)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Map<String, AtomicLong>> getVsdStatisticsReport() {
|
|
||||||
return _clientLoader.getNuageVspStatistics()
|
|
||||||
.getVsdCountReport()
|
|
||||||
.entrySet().stream()
|
|
||||||
.collect(Collectors.toMap(
|
|
||||||
e -> e.getKey().toString(),
|
|
||||||
e -> convertHashMap(e.getValue())
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
|
||||||
if(super.configure(name, params)) {
|
|
||||||
validate(params);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void login() throws ConfigurationException, NuageVspException {
|
|
||||||
getNuageVspApiClient().login();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected NuageVspPluginClientLoader getClientLoader(VspHost vspHost) {
|
|
||||||
return NuageVspPluginClientLoader.getClientLoader(vspHost);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean start() {
|
|
||||||
try {
|
|
||||||
JmxUtil.registerMBean("NuageVspResource", _name, new VspStatisticsMBeanImpl(this));
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.warn("Unable to initialize statistics Mbean", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean stop() {
|
|
||||||
|
|
||||||
try {
|
|
||||||
JmxUtil.unregisterMBean("NuageVspResource", _name);
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.warn("Unable to stop NuageVspResource", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Host.Type getType() {
|
|
||||||
return Host.Type.L2Networking;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StartupCommand[] initialize() {
|
|
||||||
StartupVspCommand sc = new StartupVspCommand();
|
|
||||||
sc.setGuid(_guid);
|
|
||||||
sc.setName(_name);
|
|
||||||
sc.setDataCenter(_zoneId);
|
|
||||||
sc.setPod("");
|
|
||||||
sc.setPrivateIpAddress("");
|
|
||||||
sc.setStorageIpAddress("");
|
|
||||||
sc.setVersion(NuageVspResource.class.getPackage().getImplementationVersion());
|
|
||||||
return new StartupCommand[] {sc};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PingCommand getCurrentStatus(long id) {
|
|
||||||
if (Strings.isNullOrEmpty(_vspHost.getRestRelativePath())) {
|
|
||||||
s_logger.error("Refusing to ping Nuage VSD because the resource configuration is missing the relative path information");
|
|
||||||
_shouldAudit = true;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Strings.isNullOrEmpty(_vspHost.getCmsUserLogin()) || Strings.isNullOrEmpty(_vspHost.getCmsUserPassword())) {
|
|
||||||
s_logger.error("Refusing to ping Nuage VSD because the resource configuration is missing the CMS user information");
|
|
||||||
_shouldAudit = true;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
login();
|
|
||||||
} catch (NuageVspException | ConfigurationException e) {
|
|
||||||
s_logger.error("Failed to ping to Nuage VSD on " + _name + " as user " +_vspHost.getCmsUserLogin(), e);
|
|
||||||
_shouldAudit = true;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
PingNuageVspCommand pingNuageVspCommand = new PingNuageVspCommand(Host.Type.L2Networking, id, _shouldAudit);
|
|
||||||
_shouldAudit = false;
|
|
||||||
return pingNuageVspCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getStatus() {
|
|
||||||
try {
|
|
||||||
login();
|
|
||||||
return true;
|
|
||||||
} catch (NuageVspException | ConfigurationException e) {
|
|
||||||
s_logger.error("Failed to ping to Nuage VSD on " + _name + " as user " +_vspHost.getCmsUserLogin(), e);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Answer executeRequest(final Command cmd) {
|
|
||||||
final NuageVspRequestWrapper wrapper = NuageVspRequestWrapper.getInstance();
|
|
||||||
try {
|
|
||||||
return wrapper.execute(cmd, this);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
|
||||||
s_logger.debug("Received unsupported command " + cmd.toString(), e);
|
|
||||||
}
|
|
||||||
return Answer.createUnsupportedCommandAnswer(cmd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void disconnected() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IAgentControl getAgentControl() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setAgentControl(IAgentControl agentControl) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void assertNuageVspClientsLoaded() throws ConfigurationException {
|
|
||||||
if (_clientLoader == null) {
|
|
||||||
throw new ConfigurationException(NUAGE_VSP_PLUGIN_ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspApiClient getNuageVspApiClient() throws ConfigurationException {
|
|
||||||
assertNuageVspClientsLoaded();
|
|
||||||
return _clientLoader.getNuageVspApiClient();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspGuruClient getNuageVspGuruClient() throws ConfigurationException {
|
|
||||||
assertNuageVspClientsLoaded();
|
|
||||||
return _clientLoader.getNuageVspGuruClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspAclClient getNuageVspAclClient() throws ConfigurationException {
|
|
||||||
assertNuageVspClientsLoaded();
|
|
||||||
return _clientLoader.getNuageVspAclClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspElementClient getNuageVspElementClient() throws ConfigurationException {
|
|
||||||
assertNuageVspClientsLoaded();
|
|
||||||
return _clientLoader.getNuageVspElementClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspManagerClient getNuageVspManagerClient() throws ConfigurationException {
|
|
||||||
assertNuageVspClientsLoaded();
|
|
||||||
return _clientLoader.getNuageVspManagerClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,360 +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.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NuageVspUser;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspHost;
|
|
||||||
import net.nuage.vsp.acs.client.common.NuageVspApiVersion;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
|
||||||
import org.apache.commons.lang.builder.ToStringBuilder;
|
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
|
|
||||||
import com.cloud.util.NuageVspUtil;
|
|
||||||
|
|
||||||
public class NuageVspResourceConfiguration {
|
|
||||||
private static final String NAME = "name";
|
|
||||||
private static final String GUID = "guid";
|
|
||||||
private static final String ZONE_ID = "zoneid";
|
|
||||||
private static final String HOST_NAME = "hostname";
|
|
||||||
private static final String CMS_USER = "cmsuser";
|
|
||||||
private static final String CMS_USER_PASSWORD = "cmsuserpass";
|
|
||||||
private static final String PORT = "port";
|
|
||||||
private static final String API_VERSION = "apiversion";
|
|
||||||
private static final String API_RELATIVE_PATH = "apirelativepath";
|
|
||||||
private static final String RETRY_COUNT = "retrycount";
|
|
||||||
private static final String RETRY_INTERVAL = "retryinterval";
|
|
||||||
private static final String NUAGE_VSP_CMS_ID = "nuagevspcmsid";
|
|
||||||
|
|
||||||
private static final String CMS_USER_ENTEPRISE_NAME = "CSP";
|
|
||||||
|
|
||||||
private String _name;
|
|
||||||
private String _guid;
|
|
||||||
private String _zoneId;
|
|
||||||
private String _hostName;
|
|
||||||
private String _cmsUser;
|
|
||||||
private String _cmsUserPassword;
|
|
||||||
private String _port;
|
|
||||||
private String _apiVersion;
|
|
||||||
private String _apiRelativePath;
|
|
||||||
private String _retryCount;
|
|
||||||
private String _retryInterval;
|
|
||||||
private String _nuageVspCmsId;
|
|
||||||
|
|
||||||
public String name() {
|
|
||||||
return _name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String guid() {
|
|
||||||
return this._guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration guid(String guid) {
|
|
||||||
this._guid = guid;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String zoneId() {
|
|
||||||
return this._zoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration zoneId(String zoneId) {
|
|
||||||
this._zoneId = zoneId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String hostName() {
|
|
||||||
return this._hostName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration hostName(String hostName) {
|
|
||||||
this._hostName = hostName;
|
|
||||||
this._name = "Nuage VSD - " + _hostName;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String cmsUser() {
|
|
||||||
return this._cmsUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration cmsUser(String cmsUser) {
|
|
||||||
this._cmsUser = cmsUser;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String cmsUserPassword() {
|
|
||||||
return this._cmsUserPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration cmsUserPassword(String cmsUserPassword) {
|
|
||||||
this._cmsUserPassword = cmsUserPassword;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String port() {
|
|
||||||
return this._port;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration port(String port) {
|
|
||||||
this._port = port;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apiVersion() {
|
|
||||||
return this._apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration apiVersion(String apiVersion) {
|
|
||||||
this._apiVersion = apiVersion;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String apiRelativePath() {
|
|
||||||
return this._apiRelativePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration apiRelativePath(String apiRelativePath) {
|
|
||||||
this._apiRelativePath = apiRelativePath;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String retryCount() {
|
|
||||||
return this._retryCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration retryCount(String retryCount) {
|
|
||||||
this._retryCount = retryCount;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String retryInterval() {
|
|
||||||
return this._retryInterval;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration retryInterval(String retryInterval) {
|
|
||||||
this._retryInterval = retryInterval;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String nuageVspCmsId() {
|
|
||||||
return this._nuageVspCmsId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspResourceConfiguration nuageVspCmsId(String nuageVspCmsId) {
|
|
||||||
this._nuageVspCmsId = nuageVspCmsId;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRootPath(){
|
|
||||||
return "https://" + _hostName + ":" + _port + "/nuage";
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getApiPath() {
|
|
||||||
return "https://" + _hostName + ":" + _port + "/nuage/api/" + _apiVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public NuageVspApiVersion getApiVersion() throws ConfigurationException {
|
|
||||||
try {
|
|
||||||
if(_apiVersion != null) {
|
|
||||||
return NuageVspApiVersion.fromString(_apiVersion);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
throw new ConfigurationException("Incorrect API version");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<String, String> build() {
|
|
||||||
Map<String, String> map = new HashMap<>();
|
|
||||||
putIfPresent(map, GUID, _guid);
|
|
||||||
putIfPresent(map, ZONE_ID, _zoneId);
|
|
||||||
putIfPresent(map, HOST_NAME, _hostName);
|
|
||||||
putIfPresent(map, CMS_USER, _cmsUser);
|
|
||||||
putIfPresent(map, CMS_USER_PASSWORD, _cmsUserPassword);
|
|
||||||
putIfPresent(map, PORT, _port);
|
|
||||||
putIfPresent(map, API_VERSION, _apiVersion);
|
|
||||||
putIfPresent(map, API_RELATIVE_PATH, _apiRelativePath);
|
|
||||||
putIfPresent(map, RETRY_COUNT, _retryCount);
|
|
||||||
putIfPresent(map, RETRY_INTERVAL, _retryInterval);
|
|
||||||
putIfPresent(map, NUAGE_VSP_CMS_ID, _nuageVspCmsId);
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void putIfPresent(Map<String, String> map, String key, String value) {
|
|
||||||
Preconditions.checkNotNull(map);
|
|
||||||
Preconditions.checkNotNull(key);
|
|
||||||
|
|
||||||
if (value != null) {
|
|
||||||
map.put(key, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NuageVspResourceConfiguration fromConfiguration(Map<String, ?> configuration) {
|
|
||||||
return new NuageVspResourceConfiguration()
|
|
||||||
.guid((String)configuration.get(GUID))
|
|
||||||
.zoneId((String)configuration.get(ZONE_ID))
|
|
||||||
.hostName((String)configuration.get(HOST_NAME))
|
|
||||||
.cmsUser((String)configuration.get(CMS_USER))
|
|
||||||
.cmsUserPassword((String)configuration.get(CMS_USER_PASSWORD))
|
|
||||||
.port((String)configuration.get(PORT))
|
|
||||||
.apiVersion((String)configuration.get(API_VERSION))
|
|
||||||
.apiRelativePath((String)configuration.get(API_RELATIVE_PATH))
|
|
||||||
.retryCount((String)configuration.get(RETRY_COUNT))
|
|
||||||
.retryInterval((String)configuration.get(RETRY_INTERVAL))
|
|
||||||
.nuageVspCmsId((String)configuration.get(NUAGE_VSP_CMS_ID));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyNotNull(String name, String value) throws ConfigurationException {
|
|
||||||
if (value == null) {
|
|
||||||
throw new ConfigurationException("Unable to find " + name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void verifyNotEmpty(String name, String value) throws ConfigurationException {
|
|
||||||
if (StringUtils.isEmpty(value)) {
|
|
||||||
throw new ConfigurationException("Unable to find " + name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int verifyInRange(String name, String value, int min, int max) throws ConfigurationException {
|
|
||||||
verifyNotEmpty(name, value);
|
|
||||||
|
|
||||||
int parsedValue;
|
|
||||||
try {
|
|
||||||
parsedValue = Integer.parseInt(value);
|
|
||||||
} catch (NumberFormatException ex) {
|
|
||||||
throw new ConfigurationException(name + " has to be between " + min + " and " + max);
|
|
||||||
}
|
|
||||||
if ((parsedValue < min) || (parsedValue > max)) {
|
|
||||||
throw new ConfigurationException(name + " has to be between " + min + " and " + max);
|
|
||||||
}
|
|
||||||
return parsedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void validate() throws ConfigurationException {
|
|
||||||
verifyNotNull("name", _name);
|
|
||||||
verifyNotNull("guid", _guid);
|
|
||||||
verifyNotNull("zone", _zoneId);
|
|
||||||
verifyNotNull("hostname", _hostName);
|
|
||||||
verifyNotNull("CMS username", _cmsUser);
|
|
||||||
verifyNotNull("CMS password", _cmsUserPassword);
|
|
||||||
verifyNotEmpty("API version", _apiVersion);
|
|
||||||
|
|
||||||
try {
|
|
||||||
NuageVspApiVersion.fromString(_apiVersion);
|
|
||||||
} catch(IllegalArgumentException e) {
|
|
||||||
throw new ConfigurationException("Incorrect API version");
|
|
||||||
}
|
|
||||||
|
|
||||||
verifyNotEmpty("number of retries", _retryCount);
|
|
||||||
verifyNotEmpty("retry interval", _retryInterval);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int parseRetryCount() throws ConfigurationException {
|
|
||||||
return verifyInRange("Number of retries", _retryCount, 1, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int parseRetryInterval() throws ConfigurationException {
|
|
||||||
return verifyInRange("Retry interval", _retryInterval, 1, 10000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspHost buildVspHost() throws ConfigurationException {
|
|
||||||
return new VspHost.Builder()
|
|
||||||
.cmsUser(new NuageVspUser(CMS_USER_ENTEPRISE_NAME, _cmsUser, NuageVspUtil.decodePassword(_cmsUserPassword)))
|
|
||||||
.apiVersion(getApiVersion())
|
|
||||||
.restRelativePath(getApiPath())
|
|
||||||
.rootPath(getRootPath())
|
|
||||||
.nuageVspCmsId(_nuageVspCmsId)
|
|
||||||
.noofRetry(parseRetryCount())
|
|
||||||
.retryInterval(parseRetryInterval())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(o instanceof NuageVspResourceConfiguration)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
NuageVspResourceConfiguration that = (NuageVspResourceConfiguration) o;
|
|
||||||
|
|
||||||
return super.equals(that)
|
|
||||||
&& Objects.equals(_name, that._name)
|
|
||||||
&& Objects.equals(_guid, that._guid)
|
|
||||||
&& Objects.equals(_zoneId, that._zoneId)
|
|
||||||
&& Objects.equals(_hostName, that._hostName)
|
|
||||||
&& Objects.equals(_cmsUser, that._cmsUser)
|
|
||||||
&& Objects.equals(_cmsUserPassword, that._cmsUserPassword)
|
|
||||||
&& Objects.equals(_port, that._port)
|
|
||||||
&& Objects.equals(_apiVersion, that._apiVersion)
|
|
||||||
&& Objects.equals(_apiRelativePath, that._apiRelativePath)
|
|
||||||
&& Objects.equals(_retryCount, that._retryCount)
|
|
||||||
&& Objects.equals(_retryInterval, that._retryInterval)
|
|
||||||
&& Objects.equals(_nuageVspCmsId, that._nuageVspCmsId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return new HashCodeBuilder()
|
|
||||||
.appendSuper(super.hashCode())
|
|
||||||
.append(_name)
|
|
||||||
.append(_guid)
|
|
||||||
.append(_zoneId)
|
|
||||||
.append(_hostName)
|
|
||||||
.append(_cmsUser)
|
|
||||||
.append(_cmsUserPassword)
|
|
||||||
.append(_port)
|
|
||||||
.append(_apiVersion)
|
|
||||||
.append(_apiRelativePath)
|
|
||||||
.append(_retryCount)
|
|
||||||
.append(_retryInterval)
|
|
||||||
.append(_nuageVspCmsId)
|
|
||||||
.toHashCode();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String toString() {
|
|
||||||
return new ToStringBuilder(this)
|
|
||||||
.append("_name", _name)
|
|
||||||
.append("_guid", _guid)
|
|
||||||
.append("_zoneId", _zoneId)
|
|
||||||
.append("_hostName", _hostName)
|
|
||||||
.append("_cmsUser", _cmsUser)
|
|
||||||
.append("_cmsUserPassword", _cmsUserPassword)
|
|
||||||
.append("_port", _port)
|
|
||||||
.append("_apiVersion", _apiVersion)
|
|
||||||
.append("_apiRelativePath", _apiRelativePath)
|
|
||||||
.append("_retryCount", _retryCount)
|
|
||||||
.append("_retryInterval", _retryInterval)
|
|
||||||
.append("_nuageVspCmsId", _nuageVspCmsId)
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,66 +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.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
import com.cloud.utils.mgmt.ManagementBean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by sgoeminn on 1/24/17.
|
|
||||||
*/
|
|
||||||
public interface VspStatisticsMBean extends ManagementBean {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the global count of all the VSD calls since start up
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long getVSDStatistics();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the count of all the vsd calls where the entityType is equal to the entity
|
|
||||||
* @param entity
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long getVsdStatisticsByEntityType(String entity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the count of all the vsd calls where the requestType is equal to the requestType
|
|
||||||
* @param requestType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long getVsdStatisticsByRequestType(String requestType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the count of all the vsd calls where the EntityType is equal to the entity
|
|
||||||
* and the RequestType is equal to the requestType string.
|
|
||||||
* @param entity
|
|
||||||
* @param requestType
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
long getVsdStatisticsByEntityAndRequestType(String entity, String requestType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the count of all VSD calls with EntityType entity and RequestType type
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
Map<String, Map<String, AtomicLong>> getVsdStatisticsReport();
|
|
||||||
}
|
|
||||||
@ -1,66 +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 javax.management.StandardMBean;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by sgoeminn on 1/24/17.
|
|
||||||
*/
|
|
||||||
public class VspStatisticsMBeanImpl extends StandardMBean implements VspStatisticsMBean{
|
|
||||||
private VspStatisticsMBean _delegate;
|
|
||||||
|
|
||||||
public VspStatisticsMBeanImpl(VspStatisticsMBean nuageVspResource) {
|
|
||||||
super(VspStatisticsMBean.class, false);
|
|
||||||
_delegate = nuageVspResource;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVSDStatistics() {
|
|
||||||
return _delegate.getVSDStatistics();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByEntityType(String entity) {
|
|
||||||
return _delegate.getVsdStatisticsByEntityType(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByRequestType(String requestType) {
|
|
||||||
return _delegate.getVsdStatisticsByRequestType(requestType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getVsdStatisticsByEntityAndRequestType(String entity, String requestType) {
|
|
||||||
return _delegate.getVsdStatisticsByEntityAndRequestType(entity, requestType);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Map<String, AtomicLong>> getVsdStatisticsReport() {
|
|
||||||
return _delegate.getVsdStatisticsReport();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return _delegate.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.SupportedApiVersionCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = SupportedApiVersionCommand.class)
|
|
||||||
public final class NuageVspApiSupportCommandWrapper extends NuageVspCommandWrapper<SupportedApiVersionCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(SupportedApiVersionCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
return nuageVspResource.getNuageVspManagerClient().isSupportedApiVersion(cmd.getApiVersion());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, SupportedApiVersionCommand cmd) {
|
|
||||||
return stringBuilder.append("Check if API version ").append(cmd.getApiVersion()).append(" is supported");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ApplyAclRuleVspCommand.class)
|
|
||||||
public final class NuageVspApplyAclRulesCommandWrapper extends NuageVspCommandWrapper<ApplyAclRuleVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ApplyAclRuleVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().applyAclRules(cmd.getAclType(), cmd.getNetwork(), cmd.getAclRules(), cmd.isNetworkReset());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ApplyAclRuleVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Applied ACL Rule to network mapping " + cmd.getNetwork().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ApplyStaticNatVspCommand.class)
|
|
||||||
public final class NuageVspApplyStaticNatCommandWrapper extends NuageVspCommandWrapper<ApplyStaticNatVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ApplyStaticNatVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().applyStaticNats(cmd.getNetwork(), cmd.getStaticNatDetails());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ApplyStaticNatVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Applied Static NAT to network mapping ").append(cmd.getNetwork().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,43 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.CheckHealthCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = CheckHealthCommand.class)
|
|
||||||
public class NuageVspCheckHealthCommandWrapper extends NuageVspCommandWrapper<CheckHealthCommand> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean executeNuageVspCommand(CheckHealthCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
return nuageVspResource.getStatus();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StringBuilder fillDetail(StringBuilder stringBuilder, CheckHealthCommand cmd) {
|
|
||||||
return stringBuilder.append("Check Health");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,41 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.CleanUpDomainCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = CleanUpDomainCommand.class)
|
|
||||||
public final class NuageVspCleanupDomainCommandWrapper extends NuageVspCommandWrapper<CleanUpDomainCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(CleanUpDomainCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
return nuageVspResource.getNuageVspManagerClient().cleanUpDomain(cmd.getDomainCleanUp());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, CleanUpDomainCommand cmd) {
|
|
||||||
return stringBuilder.append("Clean Domain ").append(cmd.getDomainCleanUp().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,57 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspUnsupportedRequestException;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.agent.api.UnsupportedAnswer;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
|
|
||||||
public abstract class NuageVspCommandWrapper<T extends Command> extends CommandWrapper<T, Answer, NuageVspResource> {
|
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(NuageVspResource.class);
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final Answer execute(final T command, final NuageVspResource nuageVspResource) {
|
|
||||||
try {
|
|
||||||
boolean success = executeNuageVspCommand(command, nuageVspResource);
|
|
||||||
String detail = fillDetail(new StringBuilder(), command).append(" on ").append(nuageVspResource.getName()).toString();
|
|
||||||
return new Answer(command, success, detail);
|
|
||||||
} catch (NuageVspUnsupportedRequestException e) {
|
|
||||||
s_logger.error("Failure during " + command + " on " + nuageVspResource.getName(), e);
|
|
||||||
return new UnsupportedAnswer(command, e.getMessage()); //New Exception so there is no stacktrace showed in the UI when changing ACL lists.
|
|
||||||
} catch (Exception e) {
|
|
||||||
s_logger.error("Failure during " + command + " on " + nuageVspResource.getName(), e);
|
|
||||||
return new Answer(command, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean executeNuageVspCommand(final T command, final NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException;
|
|
||||||
|
|
||||||
public abstract StringBuilder fillDetail(final StringBuilder stringBuilder, final T command);
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = DeallocateVmVspCommand.class)
|
|
||||||
public final class NuageVspDeallocateVmInterfaceCommandWrapper extends NuageVspCommandWrapper<DeallocateVmVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(DeallocateVmVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspGuruClient().deallocate(cmd.getNetwork(), cmd.getVm(), cmd.getNic());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, DeallocateVmVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Deallocated VM ").append(cmd.getVm().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,59 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.common.model.NuageVspEntity;
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.EntityExistsCommand;
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.network.vpc.VpcVO;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = EntityExistsCommand.class)
|
|
||||||
public final class NuageVspEntityExistsCommandWrapper extends NuageVspCommandWrapper<EntityExistsCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(EntityExistsCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
NuageVspEntity entityType = getNuageVspEntity(cmd.getType());
|
|
||||||
|
|
||||||
return nuageVspResource.getNuageVspApiClient().entityExists(entityType, cmd.getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
private NuageVspEntity getNuageVspEntity(Class clazz) {
|
|
||||||
NuageVspEntity entityType = null;
|
|
||||||
|
|
||||||
if (Vlan.class.isAssignableFrom(clazz)) {
|
|
||||||
entityType = NuageVspEntity.SHARED_NETWORK;
|
|
||||||
}
|
|
||||||
else if(VpcVO.class.isAssignableFrom(clazz)){
|
|
||||||
entityType = NuageVspEntity.ZONE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return entityType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, EntityExistsCommand cmd) {
|
|
||||||
return stringBuilder.append("Check if entity with UUID " + cmd.getUuid() + " of type " + getNuageVspEntity(cmd.getType()) + " exists");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ExtraDhcpOptionsVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles=ExtraDhcpOptionsVspCommand.class)
|
|
||||||
public class NuageVspExtraDhcpOptionsCommandWrapper extends NuageVspCommandWrapper<ExtraDhcpOptionsVspCommand> {
|
|
||||||
@Override
|
|
||||||
public boolean executeNuageVspCommand(ExtraDhcpOptionsVspCommand command, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().setDhcpOptionsNic(command.getNetwork(), command.getNicUuid(), command.getDhcpOptions());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StringBuilder fillDetail(StringBuilder stringBuilder, ExtraDhcpOptionsVspCommand command) {
|
|
||||||
return stringBuilder;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,43 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.GetApiDefaultsAnswer;
|
|
||||||
import com.cloud.agent.api.manager.GetApiDefaultsCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = GetApiDefaultsCommand.class)
|
|
||||||
public final class NuageVspGetApiDefaultsCommandWrapper extends CommandWrapper<GetApiDefaultsCommand, GetApiDefaultsAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public GetApiDefaultsAnswer execute(final GetApiDefaultsCommand command, final NuageVspResource nuageVspResource) {
|
|
||||||
try {
|
|
||||||
return new GetApiDefaultsAnswer(command, nuageVspResource.getNuageVspManagerClient().getApiDefaults());
|
|
||||||
} catch (NuageVspException|ConfigurationException e) {
|
|
||||||
return new GetApiDefaultsAnswer(command, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,50 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspGuruClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ImplementNetworkVspCommand.class)
|
|
||||||
public final class NuageVspGuruImplementNetworkCommandWrapper extends CommandWrapper<ImplementNetworkVspCommand, ImplementNetworkVspAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ImplementNetworkVspAnswer execute(ImplementNetworkVspCommand command, NuageVspResource serverResource) {
|
|
||||||
try {
|
|
||||||
NuageVspGuruClient client = serverResource.getNuageVspGuruClient();
|
|
||||||
if (command.isVsdManaged()) {
|
|
||||||
VspNetwork vspNetwork = client.addPermissionL3Network(command.getNetwork());
|
|
||||||
return new ImplementNetworkVspAnswer(command, vspNetwork, vspNetwork.getNetworkRelatedVsdIds());
|
|
||||||
} else {
|
|
||||||
NetworkRelatedVsdIds networkRelatedVsdIds = client.implement(command.getNetwork(), command.getDhcpOption());
|
|
||||||
return new ImplementNetworkVspAnswer(command, command.getNetwork(), networkRelatedVsdIds);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
return new ImplementNetworkVspAnswer(command, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = TrashNetworkVspCommand.class)
|
|
||||||
public final class NuageVspGuruTrashNetworkCommandWrapper extends NuageVspCommandWrapper<TrashNetworkVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(TrashNetworkVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspGuruClient().trash(cmd.getNetwork());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, TrashNetworkVspCommand command) {
|
|
||||||
return stringBuilder;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,43 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ImplementVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ImplementVspCommand.class)
|
|
||||||
public final class NuageVspImplementNetworkCommandWrapper extends NuageVspCommandWrapper<ImplementVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ImplementVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().implement(cmd.getNetwork(), cmd.getDhcpOption(), cmd.getIngressFirewallRules(),
|
|
||||||
cmd.getEgressFirewallRules(), cmd.getFloatingIpUuids());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ImplementVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Implemented network ").append(cmd.getNetwork().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,51 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.ListVspDomainTemplatesAnswer;
|
|
||||||
import com.cloud.agent.api.manager.ListVspDomainTemplatesCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomainTemplate;
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ListVspDomainTemplatesCommand.class)
|
|
||||||
public class NuageVspListDomainTemplatesCommandWrapper extends CommandWrapper<ListVspDomainTemplatesCommand, ListVspDomainTemplatesAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ListVspDomainTemplatesAnswer execute(ListVspDomainTemplatesCommand command, NuageVspResource serverResource) {
|
|
||||||
NuageVspManagerClient client = null;
|
|
||||||
try {
|
|
||||||
client = serverResource.getNuageVspManagerClient();
|
|
||||||
List<VspDomainTemplate> domainTemplates = client.getDomainTemplates(command.getDomain(), command.getName());
|
|
||||||
|
|
||||||
return new ListVspDomainTemplatesAnswer(command, domainTemplates);
|
|
||||||
} catch (ConfigurationException | NuageVspException e) {
|
|
||||||
return new ListVspDomainTemplatesAnswer(command, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.MaintainAnswer;
|
|
||||||
import com.cloud.agent.api.MaintainCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = MaintainCommand.class)
|
|
||||||
public final class NuageVspMaintainCommandWrapper extends CommandWrapper<MaintainCommand, MaintainAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MaintainAnswer execute(final MaintainCommand command, final NuageVspResource nuageVspResource) {
|
|
||||||
return new MaintainAnswer(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,35 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.ReadyAnswer;
|
|
||||||
import com.cloud.agent.api.ReadyCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ReadyCommand.class)
|
|
||||||
public final class NuageVspReadyCommandWrapper extends CommandWrapper<ReadyCommand, ReadyAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ReadyAnswer execute(final ReadyCommand command, final NuageVspResource nuageVspResource) {
|
|
||||||
return new ReadyAnswer(command);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ReserveVmInterfaceVspCommand.class)
|
|
||||||
public final class NuageVspReserveVmInterfaceCommandWrapper extends NuageVspCommandWrapper<ReserveVmInterfaceVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ReserveVmInterfaceVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspGuruClient().reserve(cmd.getNetwork(), cmd.getVm(), cmd.getNic(), cmd.getStaticNat(), cmd.getDhcpOption());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ReserveVmInterfaceVspCommand command) {
|
|
||||||
return stringBuilder.append("Created NIC that maps to nicUuid ").append(command.getNic().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ShutDownVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ShutDownVspCommand.class)
|
|
||||||
public final class NuageVspShutdownNetworkCommandWrapper extends NuageVspCommandWrapper<ShutDownVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ShutDownVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().shutdownNetwork(cmd.getNetwork(), cmd.getDhcpOptions());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ShutDownVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Shutdown Network " + cmd.getNetwork().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ShutDownVpcVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = ShutDownVpcVspCommand.class)
|
|
||||||
public final class NuageVspShutdownVpcCommandWrapper extends NuageVspCommandWrapper<ShutDownVpcVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(ShutDownVpcVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspElementClient().shutdownVpc(cmd.getDomainUuid(), cmd.getVpcUuid(), cmd.getDomainTemplateName(), cmd.getDomainRouterUuids(), cmd.getRelatedVsdIds());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, ShutDownVpcVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Shutdown VPC " + cmd.getVpcUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,62 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.NuageVspManagerClient;
|
|
||||||
import net.nuage.vsp.acs.client.common.model.Pair;
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.sync.SyncNuageVspCmsIdAnswer;
|
|
||||||
import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.CommandWrapper;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = SyncNuageVspCmsIdCommand.class)
|
|
||||||
public final class NuageVspSyncCmsIdCommandWrapper extends CommandWrapper<SyncNuageVspCmsIdCommand, SyncNuageVspCmsIdAnswer, NuageVspResource> {
|
|
||||||
|
|
||||||
@Override public SyncNuageVspCmsIdAnswer execute(SyncNuageVspCmsIdCommand cmd, NuageVspResource nuageVspResource) {
|
|
||||||
NuageVspManagerClient client = null;
|
|
||||||
try {
|
|
||||||
client = nuageVspResource.getNuageVspManagerClient();
|
|
||||||
|
|
||||||
Pair<Boolean, String> answer;
|
|
||||||
switch (cmd.getSyncType()) {
|
|
||||||
case REGISTER:
|
|
||||||
String registeredNuageVspCmsId = client.registerNuageVspCmsId();
|
|
||||||
answer = Pair.of(StringUtils.isNotBlank(registeredNuageVspCmsId), registeredNuageVspCmsId);
|
|
||||||
break;
|
|
||||||
case UNREGISTER:
|
|
||||||
boolean success = client.unregisterNuageVspCmsId(cmd.getNuageVspCmsId());
|
|
||||||
answer = Pair.of(success, cmd.getNuageVspCmsId());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
answer = client.auditNuageVspCmsId(cmd.getNuageVspCmsId(), cmd.getSyncType() == SyncNuageVspCmsIdCommand.SyncType.AUDIT_ONLY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return new SyncNuageVspCmsIdAnswer(answer.getLeft(), answer.getRight(), cmd.getSyncType());
|
|
||||||
} catch (ConfigurationException|NuageVspException e) {
|
|
||||||
return new SyncNuageVspCmsIdAnswer(cmd, e, cmd.getSyncType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,41 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.sync.SyncDomainCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = SyncDomainCommand.class)
|
|
||||||
public final class NuageVspSyncDomainCommandWrapper extends NuageVspCommandWrapper<SyncDomainCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(SyncDomainCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
return nuageVspResource.getNuageVspManagerClient().syncDomainWithNuageVsp(cmd.getDomain(), cmd.isToAdd(), cmd.isToRemove());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, SyncDomainCommand cmd) {
|
|
||||||
return stringBuilder.append("Synced Domain ").append(cmd.getDomain().getUuid());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,42 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.guru.UpdateDhcpOptionVspCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = UpdateDhcpOptionVspCommand.class)
|
|
||||||
public final class NuageVspUpdateDhcpOptionsCommandWrapper extends NuageVspCommandWrapper<UpdateDhcpOptionVspCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(UpdateDhcpOptionVspCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
nuageVspResource.getNuageVspGuruClient().applyDhcpOptions(cmd.getDhcpOptions(), cmd.getNetwork());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, UpdateDhcpOptionVspCommand cmd) {
|
|
||||||
return stringBuilder.append("Update DhcpOptions on VM's in network: ").append(cmd.getNetwork().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,46 +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.vsp.resource.wrapper;
|
|
||||||
|
|
||||||
import javax.naming.ConfigurationException;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.exception.NuageVspException;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.manager.UpdateNuageVspDeviceCommand;
|
|
||||||
import com.cloud.network.resource.NuageVspResource;
|
|
||||||
import com.cloud.network.resource.NuageVspResourceConfiguration;
|
|
||||||
import com.cloud.resource.ResourceWrapper;
|
|
||||||
|
|
||||||
@ResourceWrapper(handles = UpdateNuageVspDeviceCommand.class)
|
|
||||||
public final class UpdateNuageVspDeviceCommandWrapper extends NuageVspCommandWrapper<UpdateNuageVspDeviceCommand> {
|
|
||||||
|
|
||||||
@Override public boolean executeNuageVspCommand(UpdateNuageVspDeviceCommand cmd, NuageVspResource nuageVspResource) throws ConfigurationException, NuageVspException {
|
|
||||||
final NuageVspResourceConfiguration configuration = cmd.getConfiguration();
|
|
||||||
nuageVspResource.validate(configuration);
|
|
||||||
nuageVspResource.getConfigParams().putAll(configuration.build());
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public StringBuilder fillDetail(StringBuilder stringBuilder, UpdateNuageVspDeviceCommand cmd) {
|
|
||||||
return stringBuilder.append("Updated the NuageVspResource parameters");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,463 +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.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAddressRange;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomain;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomainCleanUp;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNic;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspVm;
|
|
||||||
import net.nuage.vsp.acs.client.common.model.Pair;
|
|
||||||
|
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.resourcedetail.dao.VpcDetailsDao;
|
|
||||||
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.dc.dao.VlanDao;
|
|
||||||
import com.cloud.dc.dao.VlanDetailsDao;
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.domain.DomainVO;
|
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.NetworkModel;
|
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
|
||||||
import com.cloud.network.dao.IPAddressVO;
|
|
||||||
import com.cloud.network.dao.NetworkDao;
|
|
||||||
import com.cloud.network.dao.NetworkDetailsDao;
|
|
||||||
import com.cloud.network.dao.NetworkVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.network.rules.FirewallRule;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItem;
|
|
||||||
import com.cloud.network.vpc.VpcVO;
|
|
||||||
import com.cloud.network.vpc.dao.VpcDao;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
|
||||||
import com.cloud.user.AccountVO;
|
|
||||||
import com.cloud.user.dao.AccountDao;
|
|
||||||
import com.cloud.utils.net.NetUtils;
|
|
||||||
import com.cloud.vm.NicProfile;
|
|
||||||
import com.cloud.vm.NicVO;
|
|
||||||
import com.cloud.vm.VMInstanceVO;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
import com.cloud.vm.dao.NicDao;
|
|
||||||
import com.cloud.vm.dao.NicSecondaryIpDao;
|
|
||||||
import com.cloud.vm.dao.NicSecondaryIpVO;
|
|
||||||
import com.cloud.vm.dao.VMInstanceDao;
|
|
||||||
|
|
||||||
public class NuageVspEntityBuilder {
|
|
||||||
private static final Logger s_logger = Logger.getLogger(NuageVspEntityBuilder.class);
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
NetworkDao _networkDao;
|
|
||||||
@Inject
|
|
||||||
VpcDao _vpcDao;
|
|
||||||
@Inject
|
|
||||||
DomainDao _domainDao;
|
|
||||||
@Inject
|
|
||||||
AccountDao _accountDao;
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingDao _networkOfferingDao;
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingServiceMapDao _networkOfferingServiceMapDao;
|
|
||||||
@Inject
|
|
||||||
NetworkModel _networkModel;
|
|
||||||
@Inject
|
|
||||||
VlanDao _vlanDao;
|
|
||||||
@Inject
|
|
||||||
VlanDetailsDao _vlanDetailsDao;
|
|
||||||
@Inject
|
|
||||||
IPAddressDao _ipAddressDao;
|
|
||||||
@Inject
|
|
||||||
NetworkDetailsDao _networkDetailsDao;
|
|
||||||
@Inject
|
|
||||||
VpcDetailsDao _vpcDetailsDao;
|
|
||||||
@Inject
|
|
||||||
VMInstanceDao _vmInstanceDao;
|
|
||||||
@Inject
|
|
||||||
NuageVspManager _nuageVspManager;
|
|
||||||
@Inject
|
|
||||||
NicDao _nicDao;
|
|
||||||
@Inject
|
|
||||||
NicSecondaryIpDao _nicSecondaryIpDao;
|
|
||||||
@Inject
|
|
||||||
NetworkOfferingServiceMapDao _ntwkOfferingSrvcDao;
|
|
||||||
|
|
||||||
|
|
||||||
public VspDomain buildVspDomain(Domain domain) {
|
|
||||||
return new VspDomain.Builder()
|
|
||||||
.uuid(domain.getUuid())
|
|
||||||
.name(domain.getName())
|
|
||||||
.path(domain.getPath())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspDomainCleanUp buildVspDomainCleanUp(Domain domain) {
|
|
||||||
VspDomainCleanUp.Builder vspDomainCleanUpBuilder = new VspDomainCleanUp.Builder().uuid(domain.getUuid());
|
|
||||||
|
|
||||||
Map<String, List<String>> sharedNetworkUuids = Maps.newHashMap();
|
|
||||||
List<NetworkVO> allSharedNetworks = _networkDao.listByGuestType(Network.GuestType.Shared);
|
|
||||||
for (NetworkVO sharedNetwork : allSharedNetworks) {
|
|
||||||
if (_networkModel.isNetworkAvailableInDomain(sharedNetwork.getId(), domain.getId())) {
|
|
||||||
String preConfiguredDomainTemplateName = _nuageVspManager.getPreConfiguredDomainTemplateName(sharedNetwork);
|
|
||||||
if (!sharedNetworkUuids.containsKey(preConfiguredDomainTemplateName)) {
|
|
||||||
sharedNetworkUuids.put(preConfiguredDomainTemplateName, Lists.<String>newArrayList());
|
|
||||||
}
|
|
||||||
sharedNetworkUuids.get(preConfiguredDomainTemplateName).add(sharedNetwork.getUuid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vspDomainCleanUpBuilder.sharedNetworkUuids(sharedNetworkUuids);
|
|
||||||
|
|
||||||
return vspDomainCleanUpBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork buildVspNetwork(Network network) {
|
|
||||||
return buildVspNetwork(network.getDomainId(), network, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork buildVspNetwork(Network network, String vsdSubnetId) {
|
|
||||||
return buildVspNetwork(network.getDomainId(), network, vsdSubnetId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork buildVspNetwork(long domainId, Network network) {
|
|
||||||
return buildVspNetwork(domainId, network, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork buildVspNetwork(long domainId, Network network, String vsdSubnetId) {
|
|
||||||
VspNetwork.Builder vspNetworkBuilder = new VspNetwork.Builder()
|
|
||||||
.id(network.getId())
|
|
||||||
.uuid(network.getUuid())
|
|
||||||
.name(network.getName())
|
|
||||||
.cidr(network.getCidr())
|
|
||||||
.gateway(network.getGateway());
|
|
||||||
|
|
||||||
DomainVO domain = _domainDao.findById(domainId);
|
|
||||||
VspDomain vspDomain = buildVspDomain(domain);
|
|
||||||
vspNetworkBuilder.domain(vspDomain);
|
|
||||||
|
|
||||||
|
|
||||||
AccountVO account = _accountDao.findById(network.getAccountId());
|
|
||||||
if (account != null) {
|
|
||||||
vspNetworkBuilder.accountUuid(account.getUuid()).accountName(account.getAccountName());
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
vspNetworkBuilder.egressDefaultPolicy(networkOffering.isEgressDefaultPolicy())
|
|
||||||
.publicAccess(networkOffering.isSupportingPublicAccess());
|
|
||||||
|
|
||||||
Map<String, String> networkDetails = _networkDetailsDao.listDetailsKeyPairs(network.getId(), false);
|
|
||||||
|
|
||||||
final NetworkRelatedVsdIds.Builder relatedVsdIdsBuilder = new NetworkRelatedVsdIds.Builder();
|
|
||||||
|
|
||||||
if (MapUtils.isNotEmpty(networkDetails)) {
|
|
||||||
relatedVsdIdsBuilder.vsdSubnetId(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_SUBNET_ID))
|
|
||||||
.withVsdManaged("true".equals(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED)));
|
|
||||||
} else if (vsdSubnetId != null) {
|
|
||||||
relatedVsdIdsBuilder.vsdSubnetId(vsdSubnetId)
|
|
||||||
.withVsdManaged("true".equals(networkDetails.get(NuageVspManager.NETWORK_METADATA_VSD_MANAGED)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (network.getVpcId() != null) {
|
|
||||||
long vpcId = network.getVpcId();
|
|
||||||
VpcVO vpc = _vpcDao.findById(vpcId);
|
|
||||||
vspNetworkBuilder.vpcUuid(vpc.getUuid())
|
|
||||||
.vpcName(vpc.getName())
|
|
||||||
.networkType(VspNetwork.NetworkType.Vpc);
|
|
||||||
Map<String, String> vpcDetails = _vpcDetailsDao.listDetailsKeyPairs(vpcId, false);
|
|
||||||
applyDomainAndZoneId(relatedVsdIdsBuilder, vpcDetails);
|
|
||||||
} else {
|
|
||||||
applyDomainAndZoneId(relatedVsdIdsBuilder, networkDetails);
|
|
||||||
|
|
||||||
if (networkOffering.getGuestType() == Network.GuestType.Shared) {
|
|
||||||
List<VlanVO> vlans = _vlanDao.listVlansByNetworkIdIncludingRemoved(network.getId());
|
|
||||||
List<VspAddressRange> vspAddressRanges =
|
|
||||||
vlans.stream()
|
|
||||||
.map(vlan -> new VspAddressRange.Builder().gateway(vlan.getVlanGateway()).netmask(vlan.getVlanNetmask()).build())
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
|
|
||||||
vspNetworkBuilder.networkType(VspNetwork.NetworkType.Shared)
|
|
||||||
.addressRanges(vspAddressRanges);
|
|
||||||
} else if (_networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.SourceNat)
|
|
||||||
|| _networkOfferingServiceMapDao.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.StaticNat)) {
|
|
||||||
vspNetworkBuilder.networkType(VspNetwork.NetworkType.L3);
|
|
||||||
} else {
|
|
||||||
vspNetworkBuilder.networkType(VspNetwork.NetworkType.L2);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
NetworkRelatedVsdIds networkRelatedVsdIds = relatedVsdIdsBuilder.build();
|
|
||||||
vspNetworkBuilder.networkRelatedVsdIds(networkRelatedVsdIds);
|
|
||||||
|
|
||||||
boolean firewallServiceSupported = _networkModel.areServicesSupportedByNetworkOffering(network.getNetworkOfferingId(), Network.Service.Firewall);
|
|
||||||
vspNetworkBuilder.firewallServiceSupported(firewallServiceSupported);
|
|
||||||
|
|
||||||
String preConfiguredDomainTemplateName = _nuageVspManager.getPreConfiguredDomainTemplateName(network);
|
|
||||||
vspNetworkBuilder.domainTemplateName(preConfiguredDomainTemplateName);
|
|
||||||
|
|
||||||
if (usesVirtualRouter(networkOffering.getId())) {
|
|
||||||
String virtualRouterIp = getVirtualRouterIP(network);
|
|
||||||
vspNetworkBuilder.virtualRouterIp(virtualRouterIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vspNetworkBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyDomainAndZoneId(NetworkRelatedVsdIds.Builder relatedVsdIdsBuilder, Map<String, String> details) {
|
|
||||||
if (MapUtils.isNotEmpty(details)) {
|
|
||||||
relatedVsdIdsBuilder
|
|
||||||
.vsdDomainId(details.get(NuageVspManager.NETWORK_METADATA_VSD_DOMAIN_ID))
|
|
||||||
.vsdZoneId(details.get(NuageVspManager.NETWORK_METADATA_VSD_ZONE_ID));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean usesVirtualRouter(long networkOfferingId) {
|
|
||||||
return _networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VirtualRouter) ||
|
|
||||||
_networkOfferingServiceMapDao.isProviderForNetworkOffering(networkOfferingId, Network.Provider.VPCVirtualRouter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNetwork updateVspNetworkByPublicIp(VspNetwork vspNetwork, Network network, String publicIp) {
|
|
||||||
List<VlanVO> vlans = _vlanDao.listVlansByNetworkId(network.getId());
|
|
||||||
final long ip = NetUtils.ip2Long(publicIp);
|
|
||||||
VlanVO matchingVlan = vlans.stream()
|
|
||||||
.filter(vlan -> isVlanContainingIp(vlan, ip))
|
|
||||||
.findFirst()
|
|
||||||
.get();
|
|
||||||
|
|
||||||
boolean underlayEnabled = NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, matchingVlan);
|
|
||||||
return new VspNetwork.Builder().fromObject(vspNetwork)
|
|
||||||
.gateway(matchingVlan.getVlanGateway())
|
|
||||||
.cidr(NetUtils.getCidrFromGatewayAndNetmask(matchingVlan.getVlanGateway(), matchingVlan.getVlanNetmask()))
|
|
||||||
.vlanUnderlay(underlayEnabled)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isVlanContainingIp(Vlan vlan, long ip) {
|
|
||||||
Pair<String, String> ipAddressRange = NuageVspUtil.getIpAddressRange(vlan);
|
|
||||||
long startIp = NetUtils.ip2Long(ipAddressRange.getLeft());
|
|
||||||
long endIp = NetUtils.ip2Long(ipAddressRange.getRight());
|
|
||||||
return startIp <= ip && ip <= endIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getVirtualRouterIP(Network network) {
|
|
||||||
return network.getBroadcastUri() != null ? network.getBroadcastUri().getPath().substring(1) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public VspVm buildVspVm(VirtualMachine vm, Network network) {
|
|
||||||
VspVm.Builder vspVmBuilder = new VspVm.Builder()
|
|
||||||
.uuid(vm.getUuid())
|
|
||||||
.name(vm.getInstanceName())
|
|
||||||
.state(getEnumValue(vm.getState(), VspVm.State.Unknown));
|
|
||||||
|
|
||||||
boolean isDomainRouter = vm.getType().equals(VirtualMachine.Type.DomainRouter);
|
|
||||||
vspVmBuilder.domainRouter(isDomainRouter);
|
|
||||||
|
|
||||||
if (network.getBroadcastUri() != null) {
|
|
||||||
String domainRouterIp = network.getBroadcastUri().getPath().substring(1);
|
|
||||||
vspVmBuilder.domainRouterIp(domainRouterIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vspVmBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNic buildVspNic(String nicUuid, NicProfile nicProfile) {
|
|
||||||
return buildVspNic(nicUuid, nicProfile.getMacAddress(), nicProfile.getIPv4Address(), nicProfile.getNetworkId(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNic buildVspNic(NicVO nic) {
|
|
||||||
return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspNic buildVspNic(NicVO nic, NicSecondaryIpVO nicSecondaryIp) {
|
|
||||||
return buildVspNic(nic.getUuid(), nic.getMacAddress(), nic.getIPv4Address(), nic.getNetworkId(), nicSecondaryIp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private VspNic buildVspNic(String uuid, String macAddress, String ip, long networkId, NicSecondaryIpVO nicSecondaryIp) {
|
|
||||||
VspNic.Builder vspNicBuilder = new VspNic.Builder()
|
|
||||||
.uuid(uuid)
|
|
||||||
.macAddress(macAddress)
|
|
||||||
.useStaticIp(true)
|
|
||||||
.ip(ip);
|
|
||||||
|
|
||||||
if (nicSecondaryIp != null) {
|
|
||||||
vspNicBuilder.secondaryIpUuid(nicSecondaryIp.getUuid()).secondaryIpAddress(nicSecondaryIp.getIp4Address());
|
|
||||||
}
|
|
||||||
|
|
||||||
Network network = _networkDao.findById(networkId);
|
|
||||||
NetworkOffering networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
|
|
||||||
return vspNicBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, VspNic vspNic) {
|
|
||||||
VspStaticNat.Builder vspStaticNatBuilder = new VspStaticNat.Builder()
|
|
||||||
.ipUuid(staticNatIp.getUuid())
|
|
||||||
.ipAddress(staticNatIp.getAddress().addr())
|
|
||||||
.revoke(forRevoke)
|
|
||||||
.oneToOneNat(staticNatIp.isOneToOneNat())
|
|
||||||
.state(getEnumValue(staticNatIp.getState(), VspStaticNat.State.class))
|
|
||||||
.vlanUuid(staticNatVlan.getUuid())
|
|
||||||
.vlanGateway(staticNatVlan.getVlanGateway())
|
|
||||||
.vlanNetmask(staticNatVlan.getVlanNetmask())
|
|
||||||
.vlanUnderlay(NuageVspUtil.isUnderlayEnabledForVlan(_vlanDetailsDao, staticNatVlan));
|
|
||||||
|
|
||||||
if (staticNatIp.getVmIp() != null) {
|
|
||||||
vspStaticNatBuilder.destinationIp(staticNatIp.getVmIp() + "/32");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vspNic != null) {
|
|
||||||
vspStaticNatBuilder.nic(vspNic);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vspStaticNatBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspStaticNat buildVspStaticNat(Boolean forRevoke, IPAddressVO staticNatIp, VlanVO staticNatVlan, NicVO nic) {
|
|
||||||
NicSecondaryIpVO nicSecondaryIp = null;
|
|
||||||
|
|
||||||
if (nic == null && staticNatIp.getAssociatedWithVmId() != null && staticNatIp.getVmIp() != null) {
|
|
||||||
nicSecondaryIp = _nicSecondaryIpDao.findByIp4AddressAndInstanceId(staticNatIp.getAssociatedWithVmId(), staticNatIp.getVmIp());
|
|
||||||
if (nicSecondaryIp != null) {
|
|
||||||
nic = _nicDao.findById(nicSecondaryIp.getNicId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VspNic vspNic = (nic != null) ? buildVspNic(nic, nicSecondaryIp) : null;
|
|
||||||
return buildVspStaticNat(forRevoke, staticNatIp, staticNatVlan, vspNic);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network) {
|
|
||||||
return buildVspAclRule(firewallRule, network, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspAclRule buildVspAclRule(FirewallRule firewallRule, Network network, IPAddressVO staticNat) {
|
|
||||||
VspAclRule.Builder vspAclRuleBuilder = new VspAclRule.Builder()
|
|
||||||
.uuid(firewallRule.getUuid())
|
|
||||||
.protocol(firewallRule.getProtocol())
|
|
||||||
.startPort(firewallRule.getSourcePortStart())
|
|
||||||
.endPort(firewallRule.getSourcePortEnd())
|
|
||||||
.sourceCidrList(firewallRule.getSourceCidrList())
|
|
||||||
.priority(-1)
|
|
||||||
.type(VspAclRule.ACLType.Firewall)
|
|
||||||
.state(getEnumValue(firewallRule.getState(), VspAclRule.ACLState.class))
|
|
||||||
.trafficType(getEnumValue(firewallRule.getTrafficType(), VspAclRule.ACLTrafficType.class));
|
|
||||||
|
|
||||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(network.getNetworkOfferingId());
|
|
||||||
if (firewallRule.getTrafficType() == FirewallRule.TrafficType.Egress && networkOffering.isEgressDefaultPolicy()) {
|
|
||||||
vspAclRuleBuilder.deny();
|
|
||||||
} else {
|
|
||||||
vspAclRuleBuilder.allow();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (staticNat == null && firewallRule.getSourceIpAddressId() != null) {
|
|
||||||
IPAddressVO staticNatIp = _ipAddressDao.findById(firewallRule.getSourceIpAddressId());
|
|
||||||
|
|
||||||
if (staticNatIp != null) {
|
|
||||||
VlanVO staticNatVlan = _vlanDao.findById(staticNatIp.getVlanId());
|
|
||||||
NicVO nic = _nicDao.findByIp4AddressAndNetworkId(staticNatIp.getVmIp(), staticNatIp.getAssociatedWithNetworkId());
|
|
||||||
|
|
||||||
vspAclRuleBuilder.staticNat(buildVspStaticNat(null, staticNatIp, staticNatVlan, nic));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vspAclRuleBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
public VspAclRule buildVspAclRule(NetworkACLItem networkAcl) {
|
|
||||||
return new VspAclRule.Builder()
|
|
||||||
.uuid(networkAcl.getUuid())
|
|
||||||
.protocol(networkAcl.getProtocol())
|
|
||||||
.startPort(networkAcl.getSourcePortStart())
|
|
||||||
.endPort(networkAcl.getSourcePortEnd())
|
|
||||||
.sourceIpAddress(null)
|
|
||||||
.sourceCidrList(networkAcl.getSourceCidrList())
|
|
||||||
.priority(networkAcl.getNumber())
|
|
||||||
.type(VspAclRule.ACLType.NetworkACL)
|
|
||||||
.state(getEnumValue(networkAcl.getState(), VspAclRule.ACLState.class))
|
|
||||||
.trafficType(getEnumValue(networkAcl.getTrafficType(), VspAclRule.ACLTrafficType.class))
|
|
||||||
.action(getEnumValue(networkAcl.getAction(), VspAclRule.ACLAction.class))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Build VspDhcpVMOption to put on the VM interface */
|
|
||||||
public VspDhcpVMOption buildVmDhcpOption (NicVO userNic, boolean defaultHasDns, boolean networkHasDns) {
|
|
||||||
VMInstanceVO userVm = _vmInstanceDao.findById(userNic.getInstanceId());
|
|
||||||
VspDhcpVMOption.Builder vspDhcpVMOptionBuilder = new VspDhcpVMOption.Builder()
|
|
||||||
.nicUuid(userNic.getUuid())
|
|
||||||
.defaultHasDns(defaultHasDns)
|
|
||||||
.hostname(userVm.getHostName())
|
|
||||||
.networkHasDns(networkHasDns)
|
|
||||||
.isDefaultInterface(userNic.isDefaultNic())
|
|
||||||
.domainRouter(VirtualMachine.Type.DomainRouter.equals(userNic.getVmType()));
|
|
||||||
return vspDhcpVMOptionBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Build VspDhcpVMOption to put on the subnet */
|
|
||||||
public VspDhcpDomainOption buildNetworkDhcpOption(Network network, NetworkOffering offering) {
|
|
||||||
List<String> dnsProvider = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), Network.Service.Dns);
|
|
||||||
boolean isVrDnsProvider = dnsProvider.contains("VirtualRouter") || dnsProvider.contains("VpcVirtualRouter");
|
|
||||||
VspDhcpDomainOption.Builder vspDhcpDomainBuilder = new VspDhcpDomainOption.Builder()
|
|
||||||
.dnsServers(_nuageVspManager.getDnsDetails(network.getDataCenterId()))
|
|
||||||
.vrIsDnsProvider(isVrDnsProvider);
|
|
||||||
|
|
||||||
if (isVrDnsProvider) {
|
|
||||||
vspDhcpDomainBuilder.networkDomain(network.getVpcId() != null ? _vpcDao.findById(network.getVpcId()).getNetworkDomain() : network.getNetworkDomain());
|
|
||||||
}
|
|
||||||
|
|
||||||
return vspDhcpDomainBuilder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
private <E extends Enum<E>> E getEnumValue(Enum cloudstackValue, Class<E> target) {
|
|
||||||
try {
|
|
||||||
return Enum.valueOf(target, cloudstackValue.name());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private <E extends Enum<E>> E getEnumValue(Enum cloudstackValue, E defaultValue) {
|
|
||||||
try {
|
|
||||||
return Enum.valueOf(defaultValue.getDeclaringClass(), cloudstackValue.name());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,58 +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.util;
|
|
||||||
|
|
||||||
import com.cloud.dc.Vlan;
|
|
||||||
import com.cloud.dc.VlanDetailsVO;
|
|
||||||
import com.cloud.dc.dao.VlanDetailsDao;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.utils.StringUtils;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.common.model.Pair;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
public class NuageVspUtil {
|
|
||||||
|
|
||||||
public static String encodePassword(String originalPassword) {
|
|
||||||
byte[] passwordBytes = originalPassword.getBytes(StringUtils.getPreferredCharset());
|
|
||||||
byte[] encodedPasswordBytes = Base64.encodeBase64(passwordBytes);
|
|
||||||
return new String(encodedPasswordBytes, StringUtils.getPreferredCharset());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String decodePassword(String encodedPassword) {
|
|
||||||
byte[] encodedPasswordBytes = encodedPassword.getBytes(StringUtils.getPreferredCharset());
|
|
||||||
byte[] passwordBytes = Base64.decodeBase64(encodedPasswordBytes);
|
|
||||||
return new String(passwordBytes, StringUtils.getPreferredCharset());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isUnderlayEnabledForVlan(VlanDetailsDao vlanDetailsDao, Vlan vlan) {
|
|
||||||
VlanDetailsVO nuageUnderlayDetail = vlanDetailsDao.findDetail(vlan.getId(), NuageVspManager.nuageUnderlayVlanIpRangeDetailKey);
|
|
||||||
return nuageUnderlayDetail != null && nuageUnderlayDetail.getValue().equalsIgnoreCase(String.valueOf(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Pair<String, String> getIpAddressRange(Vlan vlan) {
|
|
||||||
boolean isIpv4 = StringUtils.isNotBlank(vlan.getIpRange());
|
|
||||||
String[] range = isIpv4 ? vlan.getIpRange().split("-") : vlan.getIp6Range().split("-");
|
|
||||||
if (range.length == 2) {
|
|
||||||
return Pair.of(range[0], range[1]);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,21 +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=vsp
|
|
||||||
parent=network
|
|
||||||
@ -1,41 +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="nuageVspDaoImpl" class="com.cloud.network.dao.NuageVspDaoImpl" />
|
|
||||||
<bean id="NuageVspGuestNetworkGuru" class="com.cloud.network.guru.NuageVspGuestNetworkGuru">
|
|
||||||
<property name="name" value="NuageVspGuestNetworkGuru" />
|
|
||||||
</bean>
|
|
||||||
<bean id="NuageVspElement" class="com.cloud.network.element.NuageVspElement">
|
|
||||||
<property name="name" value="NuageVspElement" />
|
|
||||||
</bean>
|
|
||||||
<bean id="NuageVspManager" class="com.cloud.network.manager.NuageVspManagerImpl" />
|
|
||||||
<bean id="NuageVspEntityBuilder" class="com.cloud.util.NuageVspEntityBuilder" />
|
|
||||||
</beans>
|
|
||||||
@ -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;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpDomainOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDhcpVMOption;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspDomain;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNic;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspStaticNat;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspVm;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
|
||||||
import org.apache.cloudstack.framework.config.impl.ConfigDepotImpl;
|
|
||||||
import org.apache.cloudstack.framework.config.impl.ConfigurationVO;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.MockitoAnnotations;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
|
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
|
||||||
|
|
||||||
import com.cloud.dc.VlanVO;
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.NetworkModel;
|
|
||||||
import com.cloud.network.dao.IPAddressVO;
|
|
||||||
import com.cloud.network.rules.FirewallRule;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItem;
|
|
||||||
import com.cloud.util.NuageVspEntityBuilder;
|
|
||||||
import com.cloud.vm.NicProfile;
|
|
||||||
import com.cloud.vm.NicVO;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
|
|
||||||
import static com.cloud.network.manager.NuageVspManager.NuageVspIsolatedNetworkDomainTemplateName;
|
|
||||||
import static com.cloud.network.manager.NuageVspManager.NuageVspSharedNetworkDomainTemplateName;
|
|
||||||
import static com.cloud.network.manager.NuageVspManager.NuageVspVpcDomainTemplateName;
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.anyBoolean;
|
|
||||||
import static org.mockito.Matchers.anyLong;
|
|
||||||
import static org.mockito.Matchers.anyString;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
public class NuageTest {
|
|
||||||
|
|
||||||
protected static final long NETWORK_ID = 42L;
|
|
||||||
|
|
||||||
@Mock protected NetworkModel _networkModel;
|
|
||||||
@Mock protected ConfigurationDao _configDao;
|
|
||||||
@Mock protected NuageVspEntityBuilder _nuageVspEntityBuilder;
|
|
||||||
|
|
||||||
@InjectMocks
|
|
||||||
ConfigDepotImpl configDepot = new ConfigDepotImpl();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
|
|
||||||
// Standard responses
|
|
||||||
when(_networkModel.isProviderForNetwork(Network.Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
|
|
||||||
|
|
||||||
mockConfigValue(NuageVspIsolatedNetworkDomainTemplateName, "IsolatedDomainTemplate");
|
|
||||||
mockConfigValue(NuageVspVpcDomainTemplateName, "VpcDomainTemplate");
|
|
||||||
mockConfigValue(NuageVspSharedNetworkDomainTemplateName, "SharedDomainTemplate");
|
|
||||||
|
|
||||||
ConfigKey.init(configDepot);
|
|
||||||
|
|
||||||
when(_nuageVspEntityBuilder.buildVspDomain(any(Domain.class))).thenReturn(buildVspDomain());
|
|
||||||
|
|
||||||
VspNetwork vspNetwork = buildVspNetwork();
|
|
||||||
when(_nuageVspEntityBuilder.buildVspNetwork(any(Network.class))).thenReturn(vspNetwork);
|
|
||||||
when(_nuageVspEntityBuilder.buildVspNetwork(anyLong(), any(Network.class))).thenReturn(vspNetwork);
|
|
||||||
|
|
||||||
when(_nuageVspEntityBuilder.buildVspVm(any(VirtualMachine.class), any(Network.class))).thenReturn(buildVspVm());
|
|
||||||
|
|
||||||
when(_nuageVspEntityBuilder.buildVspNic(anyString(), any(NicProfile.class))).thenReturn(buildVspNic());
|
|
||||||
when(_nuageVspEntityBuilder.buildVspNic(any(NicVO.class))).thenReturn(buildVspNic());
|
|
||||||
|
|
||||||
when(_nuageVspEntityBuilder.buildVspStaticNat(anyBoolean(), any(IPAddressVO.class), any(VlanVO.class), any(NicVO.class))).thenReturn(buildVspStaticNat());
|
|
||||||
when(_nuageVspEntityBuilder.buildVspAclRule(any(FirewallRule.class), any(Network.class))).thenReturn(buildVspAclRule());
|
|
||||||
when(_nuageVspEntityBuilder.buildVspAclRule(any(NetworkACLItem.class))).thenReturn(buildVspAclRule());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected <T> void mockConfigValue(ConfigKey<T> configKey, T value) {
|
|
||||||
ConfigurationVO vo = new ConfigurationVO("test", configKey);
|
|
||||||
vo.setValue(value.toString());
|
|
||||||
when(_configDao.getValue(configKey.key())).thenReturn(value.toString());
|
|
||||||
when(_configDao.findById(configKey.key())).thenReturn(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspDomain buildVspDomain() {
|
|
||||||
return new VspDomain.Builder()
|
|
||||||
.uuid("domainUuid")
|
|
||||||
.name("domainName")
|
|
||||||
.path("domainPath")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspNetwork buildVspNetwork() {
|
|
||||||
return new VspNetwork.Builder()
|
|
||||||
.id(NETWORK_ID)
|
|
||||||
.uuid("networkUuid")
|
|
||||||
.name("networkName")
|
|
||||||
.domain(buildVspDomain())
|
|
||||||
.accountUuid("networkAccountUuid")
|
|
||||||
.accountName("networkAccountName")
|
|
||||||
.vpcUuid("vpcUuid")
|
|
||||||
.vpcName("vpcName")
|
|
||||||
.networkType(VspNetwork.NetworkType.L3)
|
|
||||||
.firewallServiceSupported(true)
|
|
||||||
.egressDefaultPolicy(true)
|
|
||||||
.domainTemplateName("domainTemplateName")
|
|
||||||
.cidr("networkCidr")
|
|
||||||
.gateway("networkGateway")
|
|
||||||
.virtualRouterIp("virtualRouterIp")
|
|
||||||
.networkRelatedVsdIds(buildNetworkRelatedIds())
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected NetworkRelatedVsdIds buildNetworkRelatedIds() {
|
|
||||||
return new NetworkRelatedVsdIds.Builder()
|
|
||||||
.vsdZoneId("vsdZoneId")
|
|
||||||
.vsdDomainId("vsdDomainId")
|
|
||||||
.vsdSubnetId("vsdSubnetId")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspVm buildVspVm() {
|
|
||||||
return new VspVm.Builder()
|
|
||||||
.state(VspVm.State.Running)
|
|
||||||
.uuid("vmUuid")
|
|
||||||
.name("vmName")
|
|
||||||
.domainRouter(true)
|
|
||||||
.domainRouterIp("domainRouterIp")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspNic buildVspNic() {
|
|
||||||
return new VspNic.Builder()
|
|
||||||
.uuid("nicUuid")
|
|
||||||
.macAddress("macAddress")
|
|
||||||
.useStaticIp(true)
|
|
||||||
.ip("ip")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspStaticNat buildVspStaticNat() {
|
|
||||||
return new VspStaticNat.Builder()
|
|
||||||
.state(VspStaticNat.State.Allocating)
|
|
||||||
.ipUuid("ipUuid")
|
|
||||||
.ipAddress("ipAddress")
|
|
||||||
.nic(buildVspNic())
|
|
||||||
.revoke(false)
|
|
||||||
.oneToOneNat(true)
|
|
||||||
.vlanUuid("vlanUuid")
|
|
||||||
.vlanGateway("vlanGateway")
|
|
||||||
.vlanNetmask("vlanNetmask")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspAclRule buildVspAclRule() {
|
|
||||||
return new VspAclRule.Builder()
|
|
||||||
.uuid("aclRuleUuid")
|
|
||||||
.protocol("protcol")
|
|
||||||
.startPort(1)
|
|
||||||
.endPort(9)
|
|
||||||
.state(VspAclRule.ACLState.Add)
|
|
||||||
.trafficType(VspAclRule.ACLTrafficType.Ingress)
|
|
||||||
.action(VspAclRule.ACLAction.Allow)
|
|
||||||
.sourceIpAddress("sourceIpAddress")
|
|
||||||
.sourceCidrList(new ArrayList<String>())
|
|
||||||
.priority(1)
|
|
||||||
.type(VspAclRule.ACLType.NetworkACL)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspDhcpDomainOption buildspDhcpDomainOption () {
|
|
||||||
return new VspDhcpDomainOption.Builder()
|
|
||||||
.vrIsDnsProvider(true)
|
|
||||||
.networkDomain("networkDomain")
|
|
||||||
.dnsServers(Lists.newArrayList("10.10.10.10", "20.20.20.20"))
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected VspDhcpVMOption buildspDhcpVMOption () {
|
|
||||||
return new VspDhcpVMOption.Builder()
|
|
||||||
.defaultHasDns(true)
|
|
||||||
.hostname("VMx")
|
|
||||||
.networkHasDns(true)
|
|
||||||
.isDefaultInterface(true)
|
|
||||||
.domainRouter(false)
|
|
||||||
.nicUuid("aaaa-bbbbbbbb-ccccccc")
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,175 +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.agent.api;
|
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.Protocol;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspAclRule;
|
|
||||||
import net.nuage.vsp.acs.client.api.model.VspNetwork;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.google.common.testing.EqualsTester;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import com.cloud.agent.api.element.ApplyAclRuleVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ApplyStaticNatVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ImplementVspCommand;
|
|
||||||
import com.cloud.agent.api.element.ShutDownVpcVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.TrashNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.manager.EntityExistsCommand;
|
|
||||||
import com.cloud.agent.api.manager.SupportedApiVersionCommand;
|
|
||||||
import com.cloud.agent.api.sync.SyncDomainCommand;
|
|
||||||
import com.cloud.agent.api.sync.SyncNuageVspCmsIdCommand;
|
|
||||||
import com.cloud.serializer.GsonHelper;
|
|
||||||
|
|
||||||
import static org.hamcrest.core.Is.is;
|
|
||||||
|
|
||||||
public class CommandsTest {
|
|
||||||
private static final Gson s_gson = GsonHelper.getGson();
|
|
||||||
|
|
||||||
private EqualsTester tester = new EqualsTester();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCommandEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
|
||||||
addCommandEqualityGroup(ApplyAclRuleVspCommand.class);
|
|
||||||
addCommandEqualityGroup(ImplementVspCommand.class);
|
|
||||||
addCommandEqualityGroup(ApplyStaticNatVspCommand.class);
|
|
||||||
addCommandEqualityGroup(ShutDownVpcVspCommand.class);
|
|
||||||
addCommandEqualityGroup(DeallocateVmVspCommand.class);
|
|
||||||
addCommandEqualityGroup(ImplementNetworkVspCommand.class);
|
|
||||||
addCommandEqualityGroup(ReserveVmInterfaceVspCommand.class);
|
|
||||||
addCommandEqualityGroup(TrashNetworkVspCommand.class);
|
|
||||||
addCommandEqualityGroup(SyncDomainCommand.class);
|
|
||||||
addCommandEqualityGroup(SyncNuageVspCmsIdCommand.class);
|
|
||||||
addCommandEqualityGroup(PingNuageVspCommand.class);
|
|
||||||
|
|
||||||
SupportedApiVersionCommand supportedApiVersionCommandA = new SupportedApiVersionCommand("3.2");
|
|
||||||
SupportedApiVersionCommand supportedApiVersionCommandB = new SupportedApiVersionCommand("3.2");
|
|
||||||
|
|
||||||
EntityExistsCommand entityExistsCommandA = new EntityExistsCommand(Command.class, "uuid");
|
|
||||||
EntityExistsCommand entityExistsCommandB = new EntityExistsCommand(Command.class, "uuid");
|
|
||||||
|
|
||||||
tester
|
|
||||||
.addEqualityGroup(supportedApiVersionCommandA, supportedApiVersionCommandB)
|
|
||||||
.addEqualityGroup(entityExistsCommandA, entityExistsCommandB)
|
|
||||||
.testEquals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCommandGsonEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
|
||||||
addCommandGsonEqualityGroup(ApplyAclRuleVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(ImplementVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(ApplyStaticNatVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(ShutDownVpcVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(DeallocateVmVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(ImplementNetworkVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(ReserveVmInterfaceVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(TrashNetworkVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(new SupportedApiVersionCommand("3.2"));
|
|
||||||
addCommandGsonEqualityGroup(SyncDomainCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(SyncNuageVspCmsIdCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(PingNuageVspCommand.class);
|
|
||||||
addCommandGsonEqualityGroup(new EntityExistsCommand(Command.class, "uuid"));
|
|
||||||
|
|
||||||
tester.testEquals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testApplyAclRuleVspCommandGsonEquals() throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
|
||||||
VspNetwork vspNetwork = new VspNetwork.Builder()
|
|
||||||
.id(1)
|
|
||||||
.uuid("uuid")
|
|
||||||
.name("name")
|
|
||||||
.cidr("192.168.1.0/24")
|
|
||||||
.gateway("192.168.1.1")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
VspAclRule aclRule = new VspAclRule.Builder()
|
|
||||||
.action(VspAclRule.ACLAction.Allow)
|
|
||||||
.uuid("uuid")
|
|
||||||
.trafficType(VspAclRule.ACLTrafficType.Egress)
|
|
||||||
.protocol(Protocol.TCP)
|
|
||||||
.startPort(80)
|
|
||||||
.endPort(80)
|
|
||||||
.priority(1)
|
|
||||||
.state(VspAclRule.ACLState.Active)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
ApplyAclRuleVspCommand before = new ApplyAclRuleVspCommand(VspAclRule.ACLType.NetworkACL, vspNetwork, Arrays.asList(aclRule), false);
|
|
||||||
ApplyAclRuleVspCommand after = serializeAndDeserialize(before);
|
|
||||||
|
|
||||||
Assert.assertThat(after.getAclRules().get(0).getProtocol().hasPort(), is(Protocol.TCP.hasPort()));
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Command> T serializeAndDeserialize(T command) {
|
|
||||||
Command[] forwardedCommands = s_gson.fromJson(s_gson.toJson(new Command[] { command }), Command[].class);
|
|
||||||
return (T) forwardedCommands[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Command> void addCommandGsonEqualityGroup(Class<T> clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException{
|
|
||||||
addCommandGsonEqualityGroup(fillObject(clazz));
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Command> void addCommandGsonEqualityGroup(Command command) throws IllegalAccessException, InvocationTargetException, InstantiationException{
|
|
||||||
Command[] forwardedCommands = s_gson.fromJson(s_gson.toJson(new Command[] { command }), Command[].class);
|
|
||||||
Assert.assertEquals(command, forwardedCommands[0]);
|
|
||||||
tester.addEqualityGroup(command, forwardedCommands[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T extends Command> void addCommandEqualityGroup(Class<T> clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
|
||||||
Command a = fillObject(clazz);
|
|
||||||
Command b = fillObject(clazz);
|
|
||||||
tester.addEqualityGroup(a, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
private <T> T fillObject(Class<T> clazz) throws IllegalAccessException, InvocationTargetException, InstantiationException {
|
|
||||||
Constructor constructor = clazz.getDeclaredConstructors()[0];
|
|
||||||
Object[] constructorArgs = new Object[constructor.getParameterTypes().length];
|
|
||||||
for (int i = 0; i < constructor.getParameterTypes().length; i++) {
|
|
||||||
Class constructorArgType = constructor.getParameterTypes()[i];
|
|
||||||
if (isNumericType(constructorArgType)) {
|
|
||||||
constructorArgs[i] = constructorArgType.getName().length();
|
|
||||||
} else if (String.class.isAssignableFrom(constructorArgType)) {
|
|
||||||
constructorArgs[i] = constructorArgType.getName();
|
|
||||||
} else if (Boolean.class.isAssignableFrom(constructorArgType) || boolean.class.isAssignableFrom(constructorArgType)) {
|
|
||||||
constructorArgs[i] = constructorArgType.getName().length() % 2 == 0;
|
|
||||||
} else if (Map.class.isAssignableFrom(constructorArgType)) {
|
|
||||||
constructorArgs[i] = Maps.newHashMap();
|
|
||||||
} else {
|
|
||||||
constructorArgs[i] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (T) constructor.newInstance(constructorArgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isNumericType(Class type) {
|
|
||||||
return Number.class.isAssignableFrom(type) || int.class.isAssignableFrom(type) || long.class.isAssignableFrom(type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,382 +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.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;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
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.cloud.NuageTest;
|
|
||||||
import com.cloud.agent.AgentManager;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.domain.DomainVO;
|
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
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;
|
|
||||||
import com.cloud.network.Network.GuestType;
|
|
||||||
import com.cloud.network.Network.Provider;
|
|
||||||
import com.cloud.network.Network.Service;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
|
||||||
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;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.network.rules.FirewallRule;
|
|
||||||
import com.cloud.network.rules.FirewallRuleVO;
|
|
||||||
import com.cloud.network.rules.StaticNat;
|
|
||||||
import com.cloud.network.vpc.NetworkACLItem;
|
|
||||||
import com.cloud.network.vpc.Vpc;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
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 com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
|
|
||||||
public class NuageVspElementTest extends NuageTest {
|
|
||||||
|
|
||||||
@InjectMocks
|
|
||||||
private NuageVspElement _nuageVspElement = new NuageVspElement();
|
|
||||||
|
|
||||||
@Mock private NetworkServiceMapDao _networkServiceMapDao;
|
|
||||||
@Mock private AgentManager _agentManager;
|
|
||||||
@Mock private HostDao _hostDao;
|
|
||||||
@Mock private NuageVspDao _nuageVspDao;
|
|
||||||
@Mock private DomainDao _domainDao;
|
|
||||||
@Mock private NetworkOfferingDao _networkOfferingDao;
|
|
||||||
@Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao;
|
|
||||||
@Mock private NuageVspManager _nuageVspManager;
|
|
||||||
@Mock private FirewallRulesDao _firewallRulesDao;
|
|
||||||
@Mock private IPAddressDao _ipAddressDao;
|
|
||||||
@Mock private PhysicalNetworkDao _physicalNetworkDao;
|
|
||||||
@Mock private NuageVspEntityBuilder _nuageVspEntityBuilder;
|
|
||||||
@Mock private VpcDetailsDao _vpcDetailsDao;
|
|
||||||
@Mock private DomainRouterDao _domainRouterDao;
|
|
||||||
@Mock private ResourceManager _resourceManager;
|
|
||||||
@Mock private ResourceTagDao _resourceTagDao;
|
|
||||||
@Mock private NetworkDao _networkDao;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
_nuageVspElement._nuageVspEntityBuilder = _nuageVspEntityBuilder;
|
|
||||||
_nuageVspElement._vpcDetailsDao = _vpcDetailsDao;
|
|
||||||
_nuageVspElement._routerDao = _domainRouterDao;
|
|
||||||
_nuageVspElement._networkDao = _networkDao;
|
|
||||||
|
|
||||||
when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true);
|
|
||||||
when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.SourceNat, Provider.NuageVsp)).thenReturn(true);
|
|
||||||
|
|
||||||
_nuageVspElement.configure("NuageVspTestElement", Collections.<String, Object>emptyMap());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCanHandle() {
|
|
||||||
final Network net = mock(Network.class);
|
|
||||||
when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
|
|
||||||
when(net.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(net.getNetworkOfferingId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
|
|
||||||
when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(ntwkoffer.isPersistent()).thenReturn(true);
|
|
||||||
when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
|
|
||||||
|
|
||||||
// Golden path
|
|
||||||
assertTrue(_nuageVspElement.canHandle(net, Service.Connectivity));
|
|
||||||
|
|
||||||
when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vlan);
|
|
||||||
// Only broadcastdomaintype Vsp is supported
|
|
||||||
assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity));
|
|
||||||
|
|
||||||
when(net.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
|
|
||||||
when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(false);
|
|
||||||
// No NuageVsp provider in the network
|
|
||||||
assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity));
|
|
||||||
|
|
||||||
when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(false);
|
|
||||||
when(_networkServiceMapDao.canProviderSupportServiceInNetwork(NETWORK_ID, Service.Connectivity, Provider.NuageVsp)).thenReturn(true);
|
|
||||||
// NusageVsp provider does not provide Connectivity for this network
|
|
||||||
assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity));
|
|
||||||
|
|
||||||
when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
|
|
||||||
// Only service Connectivity is supported
|
|
||||||
assertFalse(_nuageVspElement.canHandle(net, Service.Dhcp));
|
|
||||||
|
|
||||||
// Can't handle network offerings with specify vlan = true
|
|
||||||
when(ntwkoffer.isSpecifyVlan()).thenReturn(true);
|
|
||||||
assertFalse(_nuageVspElement.canHandle(net, Service.Connectivity));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testImplement() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException, URISyntaxException {
|
|
||||||
final Network network = mock(NetworkVO.class, withSettings().extraInterfaces(Network.class));
|
|
||||||
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
|
|
||||||
when(network.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(network.getBroadcastUri()).thenReturn(new URI(""));
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDomainId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDataCenterId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_networkModel.isProviderForNetwork(Provider.NuageVsp, NETWORK_ID)).thenReturn(true);
|
|
||||||
|
|
||||||
final NetworkVO networkVO = mock(NetworkVO.class);
|
|
||||||
when(network.getUuid()).thenReturn("aaaaaa");
|
|
||||||
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(networkVO);
|
|
||||||
|
|
||||||
final NetworkOffering offering = mock(NetworkOffering.class);
|
|
||||||
when(offering.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
|
|
||||||
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
|
|
||||||
|
|
||||||
DeployDestination deployDest = mock(DeployDestination.class);
|
|
||||||
|
|
||||||
final DomainVO dom = mock(DomainVO.class);
|
|
||||||
when(dom.getName()).thenReturn("domain");
|
|
||||||
when(_domainDao.findById(NETWORK_ID)).thenReturn(dom);
|
|
||||||
final Account acc = mock(Account.class);
|
|
||||||
when(acc.getAccountName()).thenReturn("accountname");
|
|
||||||
final ReservationContext context = mock(ReservationContext.class);
|
|
||||||
when(context.getDomain()).thenReturn(dom);
|
|
||||||
when(context.getAccount()).thenReturn(acc);
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(NETWORK_ID);
|
|
||||||
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
|
|
||||||
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
|
|
||||||
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
when(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Ingress)).thenReturn(new ArrayList<FirewallRuleVO>());
|
|
||||||
when(_firewallRulesDao.listByNetworkPurposeTrafficType(NETWORK_ID, FirewallRule.Purpose.Firewall, FirewallRule.TrafficType.Egress)).thenReturn(new ArrayList<FirewallRuleVO>());
|
|
||||||
when(_ipAddressDao.listStaticNatPublicIps(NETWORK_ID)).thenReturn(new ArrayList<IPAddressVO>());
|
|
||||||
when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList<String>());
|
|
||||||
when(_networkDao.findById(network.getId())).thenReturn((NetworkVO)network);
|
|
||||||
|
|
||||||
assertTrue(_nuageVspElement.implement(network, offering, deployDest, context));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testVerifyServiceCombination() {
|
|
||||||
|
|
||||||
Set<Service> services = Sets.newHashSet(
|
|
||||||
Service.Dhcp,
|
|
||||||
Service.StaticNat,
|
|
||||||
Service.SourceNat,
|
|
||||||
Service.Connectivity,
|
|
||||||
Service.Firewall);
|
|
||||||
assertTrue(_nuageVspElement.verifyServicesCombination(services));
|
|
||||||
|
|
||||||
services = Sets.newHashSet(
|
|
||||||
Service.Dhcp,
|
|
||||||
Service.StaticNat,
|
|
||||||
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
|
|
||||||
public void testApplyStaticNats() throws CloudException {
|
|
||||||
final Network network = mock(Network.class);
|
|
||||||
when(network.getUuid()).thenReturn("aaaaaa");
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDomainId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final DomainVO domVo = mock(DomainVO.class);
|
|
||||||
when(_domainDao.findById(41l)).thenReturn(domVo);
|
|
||||||
|
|
||||||
final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
|
|
||||||
when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(NETWORK_ID);
|
|
||||||
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
|
|
||||||
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
|
|
||||||
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
|
|
||||||
final Answer answer = mock(Answer.class);
|
|
||||||
when(answer.getResult()).thenReturn(true);
|
|
||||||
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
|
|
||||||
assertTrue(_nuageVspElement.applyStaticNats(network, new ArrayList<StaticNat>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testApplyFWRules() throws Exception {
|
|
||||||
final Network network = mock(Network.class);
|
|
||||||
when(network.getUuid()).thenReturn("aaaaaa");
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDomainId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
|
|
||||||
when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(ntwkoffer.isEgressDefaultPolicy()).thenReturn(true);
|
|
||||||
when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(NETWORK_ID);
|
|
||||||
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
|
|
||||||
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
|
|
||||||
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
|
|
||||||
|
|
||||||
final Answer answer = mock(Answer.class);
|
|
||||||
when(answer.getResult()).thenReturn(true);
|
|
||||||
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
|
|
||||||
assertTrue(_nuageVspElement.applyFWRules(network, new ArrayList<FirewallRule>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testApplyNetworkACL() throws Exception {
|
|
||||||
final Network network = mock(Network.class);
|
|
||||||
when(network.getUuid()).thenReturn("aaaaaa");
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(network.getNetworkOfferingId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDomainId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final NetworkOfferingVO ntwkoffer = mock(NetworkOfferingVO.class);
|
|
||||||
when(ntwkoffer.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(ntwkoffer.isEgressDefaultPolicy()).thenReturn(true);
|
|
||||||
when(_networkOfferingDao.findById(NETWORK_ID)).thenReturn(ntwkoffer);
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(NETWORK_ID);
|
|
||||||
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
|
|
||||||
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NuageVspDeviceVO[]{nuageVspDevice}));
|
|
||||||
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
when(_domainDao.findById(NETWORK_ID)).thenReturn(mock(DomainVO.class));
|
|
||||||
final Answer answer = mock(Answer.class);
|
|
||||||
when(answer.getResult()).thenReturn(true);
|
|
||||||
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
|
|
||||||
assertTrue(_nuageVspElement.applyNetworkACLs(network, new ArrayList<NetworkACLItem>()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testShutdownVpc() throws Exception {
|
|
||||||
final Vpc vpc = mock(Vpc.class);
|
|
||||||
when(vpc.getUuid()).thenReturn("aaaaaa");
|
|
||||||
when(vpc.getState()).thenReturn(Vpc.State.Inactive);
|
|
||||||
when(vpc.getDomainId()).thenReturn(NETWORK_ID);
|
|
||||||
when(vpc.getZoneId()).thenReturn(NETWORK_ID);
|
|
||||||
when(vpc.getId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final DomainVO dom = mock(DomainVO.class);
|
|
||||||
when(dom.getName()).thenReturn("domain");
|
|
||||||
when(_domainDao.findById(NETWORK_ID)).thenReturn(dom);
|
|
||||||
final Account acc = mock(Account.class);
|
|
||||||
when(acc.getAccountName()).thenReturn("accountname");
|
|
||||||
final ReservationContext context = mock(ReservationContext.class);
|
|
||||||
when(context.getDomain()).thenReturn(dom);
|
|
||||||
when(context.getAccount()).thenReturn(acc);
|
|
||||||
|
|
||||||
PhysicalNetworkVO physNet = mock(PhysicalNetworkVO.class);
|
|
||||||
when(physNet.getIsolationMethods()).thenReturn(Lists.newArrayList("VSP"));
|
|
||||||
when(physNet.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_physicalNetworkDao.listByZone(NETWORK_ID)).thenReturn(Lists.newArrayList(physNet));
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(NETWORK_ID);
|
|
||||||
final NuageVspDeviceVO nuageVspDevice = mock(NuageVspDeviceVO.class);
|
|
||||||
when(nuageVspDevice.getHostId()).thenReturn(NETWORK_ID);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Lists.newArrayList(nuageVspDevice));
|
|
||||||
when(_hostDao.findById(NETWORK_ID)).thenReturn(host);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
DomainRouterVO domainRouter = mock(DomainRouterVO.class);
|
|
||||||
when(domainRouter.getUuid()).thenReturn("aaaaaa");
|
|
||||||
when(_domainRouterDao.listByVpcId(NETWORK_ID)).thenReturn(Lists.newArrayList(domainRouter));
|
|
||||||
|
|
||||||
final Answer answer = mock(Answer.class);
|
|
||||||
when(answer.getResult()).thenReturn(true);
|
|
||||||
when(_agentManager.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
|
|
||||||
assertTrue(_nuageVspElement.shutdownVpc(vpc, context));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,511 +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 static org.hamcrest.Matchers.is;
|
|
||||||
import static org.hamcrest.Matchers.notNullValue;
|
|
||||||
import static org.hamcrest.Matchers.nullValue;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Matchers.any;
|
|
||||||
import static org.mockito.Matchers.anyLong;
|
|
||||||
import static org.mockito.Matchers.eq;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
|
||||||
import static org.mockito.Mockito.verifyZeroInteractions;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import net.nuage.vsp.acs.client.api.model.NetworkRelatedVsdIds;
|
|
||||||
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.mockito.ArgumentCaptor;
|
|
||||||
import org.mockito.InjectMocks;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import org.mockito.internal.util.collections.Sets;
|
|
||||||
import org.mockito.invocation.InvocationOnMock;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
|
|
||||||
import com.cloud.NuageTest;
|
|
||||||
import com.cloud.agent.AgentManager;
|
|
||||||
import com.cloud.agent.api.Answer;
|
|
||||||
import com.cloud.agent.api.Command;
|
|
||||||
import com.cloud.agent.api.guru.DeallocateVmVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ImplementNetworkVspCommand;
|
|
||||||
import com.cloud.agent.api.guru.ReserveVmInterfaceVspCommand;
|
|
||||||
import com.cloud.agent.api.manager.ImplementNetworkVspAnswer;
|
|
||||||
import com.cloud.configuration.ConfigurationManager;
|
|
||||||
import com.cloud.dc.DataCenter.NetworkType;
|
|
||||||
import com.cloud.dc.DataCenterVO;
|
|
||||||
import com.cloud.dc.dao.DataCenterDao;
|
|
||||||
import com.cloud.dc.dao.DataCenterDetailsDao;
|
|
||||||
import com.cloud.deploy.DeployDestination;
|
|
||||||
import com.cloud.deploy.DeploymentPlan;
|
|
||||||
import com.cloud.domain.Domain;
|
|
||||||
import com.cloud.domain.DomainVO;
|
|
||||||
import com.cloud.domain.dao.DomainDao;
|
|
||||||
import com.cloud.exception.InsufficientAddressCapacityException;
|
|
||||||
import com.cloud.exception.InsufficientVirtualNetworkCapacityException;
|
|
||||||
import com.cloud.host.HostVO;
|
|
||||||
import com.cloud.host.dao.HostDao;
|
|
||||||
import com.cloud.network.Network;
|
|
||||||
import com.cloud.network.Network.GuestType;
|
|
||||||
import com.cloud.network.Network.Service;
|
|
||||||
import com.cloud.network.Networks.BroadcastDomainType;
|
|
||||||
import com.cloud.network.Networks.Mode;
|
|
||||||
import com.cloud.network.Networks.TrafficType;
|
|
||||||
import com.cloud.network.NuageVspDeviceVO;
|
|
||||||
import com.cloud.network.dao.IPAddressDao;
|
|
||||||
import com.cloud.network.dao.NetworkDao;
|
|
||||||
import com.cloud.network.dao.NetworkDetailsDao;
|
|
||||||
import com.cloud.network.dao.NetworkVO;
|
|
||||||
import com.cloud.network.dao.NuageVspDao;
|
|
||||||
import com.cloud.network.dao.PhysicalNetworkDao;
|
|
||||||
import com.cloud.network.dao.PhysicalNetworkVO;
|
|
||||||
import com.cloud.network.manager.NuageVspManager;
|
|
||||||
import com.cloud.network.router.VirtualRouter;
|
|
||||||
import com.cloud.offering.NetworkOffering;
|
|
||||||
import com.cloud.offerings.NetworkOfferingVO;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
|
||||||
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
|
|
||||||
import com.cloud.user.Account;
|
|
||||||
import com.cloud.user.AccountVO;
|
|
||||||
import com.cloud.user.dao.AccountDao;
|
|
||||||
import com.cloud.vm.DomainRouterVO;
|
|
||||||
import com.cloud.vm.NicProfile;
|
|
||||||
import com.cloud.vm.NicVO;
|
|
||||||
import com.cloud.vm.ReservationContext;
|
|
||||||
import com.cloud.vm.VirtualMachine;
|
|
||||||
import com.cloud.vm.VirtualMachineProfile;
|
|
||||||
import com.cloud.vm.dao.DomainRouterDao;
|
|
||||||
import com.cloud.vm.dao.NicDao;
|
|
||||||
|
|
||||||
public class NuageVspGuestNetworkGuruTest extends NuageTest {
|
|
||||||
private static final long DATACENTER_ID = 100L;
|
|
||||||
private static final long HOST_ID = 101L;
|
|
||||||
private static final long DOMAIN_ID = 1L;
|
|
||||||
private static final long ACCOUNT_ID = 2L;
|
|
||||||
private static final long OFFERING_ID = 40L;
|
|
||||||
private static final long NETWORK_ID = 42L;
|
|
||||||
private static final long VM_ID = 242L;
|
|
||||||
private static final long NIC_ID = 342L;
|
|
||||||
|
|
||||||
private static final String DATACENTER_UUID = "uuid-datacenter-100";
|
|
||||||
private static final String HOST_UUID = "uuid-host-101";
|
|
||||||
private static final String DOMAIN_UUID = "uuid-domain-001";
|
|
||||||
private static final String ACCOUNT_UUID = "uuid-account-002";
|
|
||||||
private static final String OFFERING_UUID = "uuid-offering-040";
|
|
||||||
private static final String NETWORK_UUID = "uuid-network-000-42";
|
|
||||||
private static final String VM_UUID = "uuid-vm-002-42";
|
|
||||||
private static final String NIC_UUID = "uuid-nic-003-42";
|
|
||||||
|
|
||||||
@Mock private PhysicalNetworkDao _physicalNetworkDao;
|
|
||||||
@Mock private DataCenterDao _dataCenterDao;
|
|
||||||
@Mock private NetworkOfferingServiceMapDao _networkOfferingServiceMapDao;
|
|
||||||
@Mock private AgentManager _agentManager;
|
|
||||||
@Mock private AccountDao _accountDao;
|
|
||||||
@Mock private DomainDao _domainDao;
|
|
||||||
@Mock private NicDao _nicDao;
|
|
||||||
@Mock private NetworkOfferingDao _networkOfferingDao;
|
|
||||||
@Mock private NuageVspDao _nuageVspDao;
|
|
||||||
@Mock private HostDao _hostDao;
|
|
||||||
@Mock private NetworkDao _networkDao;
|
|
||||||
@Mock private IPAddressDao _ipAddressDao;
|
|
||||||
@Mock private NuageVspManager _nuageVspManager;
|
|
||||||
@Mock private ConfigurationManager _configurationManager;
|
|
||||||
@Mock private DataCenterDetailsDao _dcDetailsDao;
|
|
||||||
@Mock private NetworkDetailsDao _networkDetailsDao;
|
|
||||||
@Mock private PhysicalNetworkVO physnet;
|
|
||||||
@Mock private DomainRouterDao _routerDao;
|
|
||||||
|
|
||||||
private Account _account;
|
|
||||||
private Domain _domain;
|
|
||||||
private DataCenterVO _dc;
|
|
||||||
private ReservationContext _reservationContext;
|
|
||||||
|
|
||||||
@InjectMocks
|
|
||||||
private NuageVspGuestNetworkGuru _nuageVspGuestNetworkGuru = new NuageVspGuestNetworkGuru();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
|
|
||||||
_account = getMockAccount();
|
|
||||||
_domain = getMockDomain();
|
|
||||||
_dc = mockDataCenter();
|
|
||||||
_reservationContext = getMockReservationContext(_account, _domain);
|
|
||||||
|
|
||||||
when(_physicalNetworkDao.findById(any(Long.class))).thenReturn(physnet);
|
|
||||||
when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VSP"));
|
|
||||||
when(physnet.getId()).thenReturn(NETWORK_ID);
|
|
||||||
|
|
||||||
final HostVO host = mock(HostVO.class);
|
|
||||||
when(host.getId()).thenReturn(HOST_ID);
|
|
||||||
when(host.getUuid()).thenReturn(HOST_UUID);
|
|
||||||
when(_hostDao.findById(HOST_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
when(_agentManager.easySend(eq(HOST_ID), any(Command.class))).thenReturn(new Answer(null));
|
|
||||||
when(_agentManager.easySend(eq(HOST_ID), any(ImplementNetworkVspCommand.class))).thenAnswer(this::mockImplement);
|
|
||||||
when(_nuageVspManager.getNuageVspHost(NETWORK_ID)).thenReturn(host);
|
|
||||||
|
|
||||||
final NuageVspDeviceVO device = mock(NuageVspDeviceVO.class);
|
|
||||||
when(_nuageVspDao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.singletonList(device));
|
|
||||||
when(device.getId()).thenReturn(1L);
|
|
||||||
when(device.getHostId()).thenReturn(HOST_ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
Answer mockImplement(InvocationOnMock invocation) {
|
|
||||||
if (invocation.getArguments()[1] instanceof ImplementNetworkVspCommand) {
|
|
||||||
ImplementNetworkVspCommand command = (ImplementNetworkVspCommand)(invocation.getArguments()[1]);
|
|
||||||
return new ImplementNetworkVspAnswer(command, command.getNetwork(), new NetworkRelatedVsdIds.Builder().build());
|
|
||||||
} else {
|
|
||||||
return new Answer(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCanHandle() {
|
|
||||||
final NetworkOffering offering = mockNetworkOffering(false);
|
|
||||||
|
|
||||||
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
|
|
||||||
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true));
|
|
||||||
|
|
||||||
// Not supported TrafficType != Guest
|
|
||||||
when(offering.getTrafficType()).thenReturn(TrafficType.Management);
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(false));
|
|
||||||
|
|
||||||
// Supported: GuestType Shared
|
|
||||||
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
|
|
||||||
when(offering.getGuestType()).thenReturn(GuestType.Shared);
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet), is(true));
|
|
||||||
|
|
||||||
// Not supported: Basic networking
|
|
||||||
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false));
|
|
||||||
|
|
||||||
// Not supported: IsolationMethod != VSP
|
|
||||||
when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VLAN"));
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Basic, physnet), is(false));
|
|
||||||
|
|
||||||
// Not supported: Non-persistent VPC tier
|
|
||||||
when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
|
|
||||||
assertFalse(_nuageVspGuestNetworkGuru.canHandle(offering, NetworkType.Advanced, physnet));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDesign() {
|
|
||||||
final NetworkOffering offering = mockNetworkOffering(false);
|
|
||||||
when(offering.isPersistent()).thenReturn(false);
|
|
||||||
|
|
||||||
final DeploymentPlan plan = mockDeploymentPlan();
|
|
||||||
final Network network = mock(Network.class);
|
|
||||||
|
|
||||||
final Network designednetwork = _nuageVspGuestNetworkGuru.design(offering, plan, network, _account);
|
|
||||||
assertThat(designednetwork, notNullValue(Network.class));
|
|
||||||
assertThat(designednetwork.getBroadcastDomainType(), is(BroadcastDomainType.Vsp));
|
|
||||||
|
|
||||||
// Can't design non-persistent VPC tier
|
|
||||||
when(_configurationManager.isOfferingForVpc(any(NetworkOffering.class))).thenReturn(true);
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, _account), nullValue(Network.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDesignNoIsolationMethodVSP() {
|
|
||||||
when(physnet.getIsolationMethods()).thenReturn(Collections.singletonList("VLAN"));
|
|
||||||
|
|
||||||
final NetworkOffering offering = mockNetworkOffering(false);
|
|
||||||
|
|
||||||
final DeploymentPlan plan = mockDeploymentPlan();
|
|
||||||
final Network network = mock(Network.class);
|
|
||||||
|
|
||||||
assertThat(_nuageVspGuestNetworkGuru.design(offering, plan, network, _account), nullValue(Network.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReserve() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
final NicProfile nicProfile = mockNicProfile();
|
|
||||||
final VirtualMachineProfile vmProfile = mockVirtualMachineProfile(VirtualMachine.State.Starting);
|
|
||||||
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(network);
|
|
||||||
|
|
||||||
_nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), _reservationContext);
|
|
||||||
|
|
||||||
verify(_agentManager).easySend(anyLong(), any(Command.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testReserveVRRollingRestart() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
final NicProfile nicProfile = mockNicProfile();
|
|
||||||
final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Starting);
|
|
||||||
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(network);
|
|
||||||
|
|
||||||
_nuageVspGuestNetworkGuru.reserve(nicProfile, network, vmProfile, mock(DeployDestination.class), _reservationContext);
|
|
||||||
|
|
||||||
verifyZeroInteractions(_agentManager);
|
|
||||||
verify(network).setRollingRestart(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testImplementNetwork() throws URISyntaxException, InsufficientVirtualNetworkCapacityException {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
|
|
||||||
when(network.getState()).thenReturn(com.cloud.network.Network.State.Implementing);
|
|
||||||
|
|
||||||
final NetworkOffering offering = mockNetworkOffering(false);
|
|
||||||
|
|
||||||
final DeployDestination deployDest = mock(DeployDestination.class);
|
|
||||||
when(deployDest.getDataCenter()).thenReturn(_dc);
|
|
||||||
_nuageVspGuestNetworkGuru.implement(network, offering, deployDest, _reservationContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeallocate() throws Exception {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
final NicProfile nicProfile = mockNicProfile();
|
|
||||||
final VirtualMachineProfile vmProfile = mockVirtualMachineProfile(VirtualMachine.State.Expunging);
|
|
||||||
|
|
||||||
_nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeallocateVR() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
final NicProfile nicProfile = mockNicProfile();
|
|
||||||
final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Expunging);
|
|
||||||
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(network);
|
|
||||||
|
|
||||||
_nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testDeallocateVRRollingRestart() throws InsufficientVirtualNetworkCapacityException, InsufficientAddressCapacityException, URISyntaxException {
|
|
||||||
final NetworkVO network = mockNetwork();
|
|
||||||
final NicProfile nicProfile = mockNicProfile();
|
|
||||||
final VirtualMachineProfile vmProfile = mockVRProfile(VirtualMachine.State.Expunging);
|
|
||||||
|
|
||||||
DomainRouterVO newVR = mock(DomainRouterVO.class);
|
|
||||||
|
|
||||||
when(_routerDao.listByNetworkAndRole(NETWORK_ID, VirtualRouter.Role.VIRTUAL_ROUTER)).thenReturn(Collections.singletonList(newVR));
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(network);
|
|
||||||
|
|
||||||
_nuageVspGuestNetworkGuru.deallocate(network, nicProfile, vmProfile);
|
|
||||||
|
|
||||||
ArgumentCaptor<Command> argumentCaptor = ArgumentCaptor.forClass(Command.class);
|
|
||||||
verify(_agentManager, times(2)).easySend(eq(HOST_ID), argumentCaptor.capture());
|
|
||||||
final List<Command> commands = argumentCaptor.getAllValues();
|
|
||||||
assertThat(commands.get(0) instanceof DeallocateVmVspCommand, is(true));
|
|
||||||
assertThat(commands.get(1) instanceof ReserveVmInterfaceVspCommand, is(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testTrash() throws Exception {
|
|
||||||
final NetworkVO network = mock(NetworkVO.class);
|
|
||||||
when(network.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getUuid()).thenReturn(NETWORK_UUID);
|
|
||||||
when(network.getName()).thenReturn("trash");
|
|
||||||
when(network.getDomainId()).thenReturn(DOMAIN_ID);
|
|
||||||
when(network.getNetworkOfferingId()).thenReturn(OFFERING_ID);
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDataCenterId()).thenReturn(DATACENTER_ID);
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
|
|
||||||
|
|
||||||
final NetworkOffering offering = mockNetworkOffering(false);
|
|
||||||
|
|
||||||
when(_nuageVspManager.getDnsDetails(network.getDataCenterId())).thenReturn(new ArrayList<>());
|
|
||||||
when(_nuageVspManager.getGatewaySystemIds()).thenReturn(new ArrayList<>());
|
|
||||||
|
|
||||||
assertTrue(_nuageVspGuestNetworkGuru.trash(network, offering));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private NetworkVO mockNetwork() throws URISyntaxException {
|
|
||||||
final NetworkVO network = mock(NetworkVO.class);
|
|
||||||
when(network.getId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getUuid()).thenReturn(NETWORK_UUID);
|
|
||||||
when(network.getDataCenterId()).thenReturn(DATACENTER_ID);
|
|
||||||
when(network.getNetworkOfferingId()).thenReturn(OFFERING_ID);
|
|
||||||
when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(network.getDomainId()).thenReturn(DOMAIN_ID);
|
|
||||||
when(network.getAccountId()).thenReturn(ACCOUNT_ID);
|
|
||||||
when(network.getVpcId()).thenReturn(null);
|
|
||||||
when(network.getTrafficType()).thenReturn(TrafficType.Guest);
|
|
||||||
when(network.getMode()).thenReturn(Mode.Dhcp);
|
|
||||||
when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Vsp);
|
|
||||||
when(network.getBroadcastUri()).thenReturn(new URI("vsp://" + NETWORK_UUID + "/10.1.1.1"));
|
|
||||||
when(network.getGateway()).thenReturn("10.1.1.1");
|
|
||||||
when(network.getCidr()).thenReturn("10.1.1.0/24");
|
|
||||||
when(network.getName()).thenReturn("iso");
|
|
||||||
|
|
||||||
when(_networkDao.acquireInLockTable(NETWORK_ID, 1200)).thenReturn(network);
|
|
||||||
when(_networkDao.findById(NETWORK_ID)).thenReturn(network);
|
|
||||||
|
|
||||||
return network;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private NetworkOffering mockNetworkOffering(boolean forVpc) {
|
|
||||||
final NetworkOfferingVO offering = mock(NetworkOfferingVO.class);
|
|
||||||
when(offering.getId()).thenReturn(OFFERING_ID);
|
|
||||||
when(offering.getUuid()).thenReturn(OFFERING_UUID);
|
|
||||||
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
|
|
||||||
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
|
|
||||||
when(offering.isForVpc()).thenReturn(forVpc);
|
|
||||||
when(offering.isPersistent()).thenReturn(false);
|
|
||||||
when(offering.getTags()).thenReturn("aaaa");
|
|
||||||
when(offering.isEgressDefaultPolicy()).thenReturn(true);
|
|
||||||
|
|
||||||
when(_networkOfferingDao.findById(OFFERING_ID)).thenReturn(offering);
|
|
||||||
|
|
||||||
when(_configurationManager.isOfferingForVpc(offering)).thenReturn(forVpc);
|
|
||||||
|
|
||||||
when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(OFFERING_ID, Service.Connectivity, Network.Provider.NuageVsp)).thenReturn(true);
|
|
||||||
when(_networkOfferingServiceMapDao.canProviderSupportServiceInNetworkOffering(OFFERING_ID, Service.SourceNat, Network.Provider.NuageVsp)).thenReturn(true);
|
|
||||||
|
|
||||||
when(_networkModel.getNetworkOfferingServiceProvidersMap(OFFERING_ID)).thenReturn(ImmutableMap.of(
|
|
||||||
Service.Connectivity, Sets.newSet(Network.Provider.NuageVsp),
|
|
||||||
Service.SourceNat, Sets.newSet(Network.Provider.NuageVsp)
|
|
||||||
));
|
|
||||||
|
|
||||||
return offering;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DeploymentPlan mockDeploymentPlan() {
|
|
||||||
final DeploymentPlan deploymentPlan = mock(DeploymentPlan.class);
|
|
||||||
when(deploymentPlan.getDataCenterId()).thenReturn(DATACENTER_ID);
|
|
||||||
return deploymentPlan;
|
|
||||||
}
|
|
||||||
|
|
||||||
private DataCenterVO mockDataCenter() {
|
|
||||||
DataCenterVO dc = mock(DataCenterVO.class);
|
|
||||||
when(dc.getId()).thenReturn(DATACENTER_ID);
|
|
||||||
when(dc.getUuid()).thenReturn(DATACENTER_UUID);
|
|
||||||
when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
|
|
||||||
when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
|
|
||||||
when(_dataCenterDao.findById(DATACENTER_ID)).thenReturn(dc);
|
|
||||||
|
|
||||||
return dc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private Account getMockAccount() {
|
|
||||||
final AccountVO account = mock(AccountVO.class);
|
|
||||||
when(account.getId()).thenReturn(ACCOUNT_ID);
|
|
||||||
when(account.getAccountId()).thenReturn(ACCOUNT_ID);
|
|
||||||
when(account.getUuid()).thenReturn(ACCOUNT_UUID);
|
|
||||||
when(account.getDomainId()).thenReturn(DOMAIN_ID);
|
|
||||||
when(account.getType()).thenReturn(Account.ACCOUNT_TYPE_NORMAL);
|
|
||||||
|
|
||||||
when(_accountDao.findById(ACCOUNT_ID)).thenReturn(account);
|
|
||||||
|
|
||||||
return account;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private Domain getMockDomain() {
|
|
||||||
final DomainVO domain = mock(DomainVO.class);
|
|
||||||
when(domain.getId()).thenReturn(DOMAIN_ID);
|
|
||||||
when(domain.getUuid()).thenReturn(DOMAIN_UUID);
|
|
||||||
when(domain.getName()).thenReturn("aaaaa");
|
|
||||||
|
|
||||||
when(_domainDao.findById(DOMAIN_ID)).thenReturn(domain);
|
|
||||||
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private VirtualMachineProfile mockVirtualMachineProfile(VirtualMachine.State state) {
|
|
||||||
final VirtualMachine vm = mock(VirtualMachine.class);
|
|
||||||
when(vm.getId()).thenReturn(VM_ID);
|
|
||||||
when(vm.getType()).thenReturn(VirtualMachine.Type.User);
|
|
||||||
when(vm.getState()).thenReturn(state);
|
|
||||||
|
|
||||||
final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
|
|
||||||
when(vmProfile.getType()).thenReturn(VirtualMachine.Type.User);
|
|
||||||
when(vmProfile.getInstanceName()).thenReturn("Test-VM");
|
|
||||||
when(vmProfile.getUuid()).thenReturn(VM_UUID);
|
|
||||||
when(vmProfile.getVirtualMachine()).thenReturn(vm);
|
|
||||||
return vmProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private VirtualMachineProfile mockVRProfile(VirtualMachine.State state) {
|
|
||||||
final VirtualMachine vm = mock(VirtualMachine.class);
|
|
||||||
when(vm.getId()).thenReturn(VM_ID);
|
|
||||||
when(vm.getUuid()).thenReturn(VM_UUID);
|
|
||||||
when(vm.getType()).thenReturn(VirtualMachine.Type.DomainRouter);
|
|
||||||
when(vm.getState()).thenReturn(state);
|
|
||||||
|
|
||||||
|
|
||||||
final VirtualMachineProfile vmProfile = mock(VirtualMachineProfile.class);
|
|
||||||
when(vmProfile.getType()).thenReturn(VirtualMachine.Type.DomainRouter);
|
|
||||||
when(vmProfile.getInstanceName()).thenReturn("Test-VR");
|
|
||||||
when(vmProfile.getId()).thenReturn(VM_ID);
|
|
||||||
when(vmProfile.getUuid()).thenReturn(VM_UUID);
|
|
||||||
when(vmProfile.getVirtualMachine()).thenReturn(vm);
|
|
||||||
when(vmProfile.isRollingRestart()).thenReturn(true);
|
|
||||||
return vmProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private NicProfile mockNicProfile() {
|
|
||||||
final NicVO nicvo = mock(NicVO.class);
|
|
||||||
when(nicvo.getId()).thenReturn(NIC_ID);
|
|
||||||
when(nicvo.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
|
|
||||||
when(nicvo.getIPv4Address()).thenReturn("10.10.10.10");
|
|
||||||
when(nicvo.getUuid()).thenReturn("aaaa-fffff");
|
|
||||||
when(nicvo.getNetworkId()).thenReturn(NETWORK_ID);
|
|
||||||
when(nicvo.getInstanceId()).thenReturn(VM_ID);
|
|
||||||
when(_nicDao.findById(NIC_ID)).thenReturn(nicvo);
|
|
||||||
when(_nicDao.findDefaultNicForVM(VM_ID)).thenReturn(nicvo);
|
|
||||||
|
|
||||||
NicProfile nicProfile = mock(NicProfile.class);
|
|
||||||
when(nicProfile.getUuid()).thenReturn("aaa-bbbb");
|
|
||||||
when(nicProfile.getId()).thenReturn(NIC_ID);
|
|
||||||
when(nicProfile.getMacAddress()).thenReturn("c8:60:00:56:e5:58");
|
|
||||||
when(nicProfile.getIPv4Address()).thenReturn("10.10.10.10");
|
|
||||||
return nicProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static ReservationContext getMockReservationContext(Account networksAccount, Domain networksDomain) {
|
|
||||||
final ReservationContext reservationContext = mock(ReservationContext.class);
|
|
||||||
when(reservationContext.getAccount()).thenReturn(networksAccount);
|
|
||||||
when(reservationContext.getDomain()).thenReturn(networksDomain);
|
|
||||||
return reservationContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user