3939import javax .naming .directory .DirContext ;
4040import javax .naming .directory .InitialDirContext ;
4141
42- import com .cloud .dc .*;
43- import com .cloud .dc .dao .*;
44- import com .cloud .user .*;
45- import com .cloud .event .UsageEventUtils ;
46- import com .cloud .utils .db .*;
4742import org .apache .cloudstack .acl .SecurityChecker ;
4843import org .apache .cloudstack .api .ApiConstants .LDAPParams ;
4944import org .apache .cloudstack .api .command .admin .config .UpdateCfgCmd ;
7166import org .apache .cloudstack .api .command .admin .zone .DeleteZoneCmd ;
7267import org .apache .cloudstack .api .command .admin .zone .UpdateZoneCmd ;
7368import org .apache .cloudstack .api .command .user .network .ListNetworkOfferingsCmd ;
74- import org .apache .cloudstack .region .*;
69+ import org .apache .cloudstack .region .PortableIp ;
70+ import org .apache .cloudstack .region .PortableIpDao ;
71+ import org .apache .cloudstack .region .PortableIpRange ;
72+ import org .apache .cloudstack .region .PortableIpRangeDao ;
73+ import org .apache .cloudstack .region .PortableIpRangeVO ;
74+ import org .apache .cloudstack .region .PortableIpVO ;
75+ import org .apache .cloudstack .region .Region ;
7576import org .apache .cloudstack .region .dao .RegionDao ;
7677import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
7778import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailVO ;
149150import com .cloud .network .dao .PhysicalNetworkTrafficTypeDao ;
150151import com .cloud .network .dao .PhysicalNetworkTrafficTypeVO ;
151152import com .cloud .network .dao .PhysicalNetworkVO ;
152- import com .cloud .network .rules .LoadBalancerContainer .Scheme ;
153153import com .cloud .network .element .DhcpServiceProvider ;
154+ import com .cloud .network .rules .LoadBalancerContainer .Scheme ;
154155import com .cloud .network .vpc .VpcManager ;
155156import com .cloud .offering .DiskOffering ;
156157import com .cloud .offering .NetworkOffering ;
192193import com .cloud .utils .StringUtils ;
193194import com .cloud .utils .component .ManagerBase ;
194195import com .cloud .utils .crypt .DBEncryptionUtil ;
196+ import com .cloud .utils .db .DB ;
197+ import com .cloud .utils .db .Filter ;
198+ import com .cloud .utils .db .GlobalLock ;
199+ import com .cloud .utils .db .SearchCriteria ;
200+ import com .cloud .utils .db .Transaction ;
195201import com .cloud .utils .exception .CloudRuntimeException ;
196202import com .cloud .utils .net .NetUtils ;
197203import com .cloud .vm .NicIpAlias ;
200206import com .cloud .vm .dao .NicIpAliasDao ;
201207import com .cloud .vm .dao .NicIpAliasVO ;
202208import com .cloud .vm .dao .NicSecondaryIpDao ;
203- import edu .emory .mathcs .backport .java .util .Arrays ;
204- import org .apache .cloudstack .acl .SecurityChecker ;
205- import org .apache .cloudstack .api .ApiConstants .LDAPParams ;
206- import org .apache .cloudstack .api .command .admin .config .UpdateCfgCmd ;
207- import org .apache .cloudstack .api .command .admin .ldap .LDAPConfigCmd ;
208- import org .apache .cloudstack .api .command .admin .ldap .LDAPRemoveCmd ;
209- import org .apache .cloudstack .api .command .admin .network .CreateNetworkOfferingCmd ;
210- import org .apache .cloudstack .api .command .admin .network .DeleteNetworkOfferingCmd ;
211- import org .apache .cloudstack .api .command .admin .network .UpdateNetworkOfferingCmd ;
212- import org .apache .cloudstack .api .command .admin .offering .CreateDiskOfferingCmd ;
213- import org .apache .cloudstack .api .command .admin .offering .CreateServiceOfferingCmd ;
214- import org .apache .cloudstack .api .command .admin .offering .DeleteDiskOfferingCmd ;
215- import org .apache .cloudstack .api .command .admin .offering .DeleteServiceOfferingCmd ;
216- import org .apache .cloudstack .api .command .admin .offering .UpdateDiskOfferingCmd ;
217- import org .apache .cloudstack .api .command .admin .offering .UpdateServiceOfferingCmd ;
218- import org .apache .cloudstack .api .command .admin .pod .DeletePodCmd ;
219- import org .apache .cloudstack .api .command .admin .pod .UpdatePodCmd ;
220- import org .apache .cloudstack .api .command .admin .vlan .CreateVlanIpRangeCmd ;
221- import org .apache .cloudstack .api .command .admin .vlan .DedicatePublicIpRangeCmd ;
222- import org .apache .cloudstack .api .command .admin .vlan .DeleteVlanIpRangeCmd ;
223- import org .apache .cloudstack .api .command .admin .vlan .ReleasePublicIpRangeCmd ;
224- import org .apache .cloudstack .api .command .admin .zone .CreateZoneCmd ;
225- import org .apache .cloudstack .api .command .admin .zone .DeleteZoneCmd ;
226- import org .apache .cloudstack .api .command .admin .zone .UpdateZoneCmd ;
227- import org .apache .cloudstack .api .command .user .network .ListNetworkOfferingsCmd ;
228- import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
229- import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailVO ;
230- import org .apache .cloudstack .storage .datastore .db .StoragePoolDetailsDao ;
231- import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
232- import org .apache .log4j .Logger ;
233- import org .springframework .stereotype .Component ;
234209
235- import javax .ejb .Local ;
236- import javax .inject .Inject ;
237- import javax .naming .ConfigurationException ;
238- import javax .naming .Context ;
239- import javax .naming .NamingException ;
240- import javax .naming .directory .DirContext ;
241- import javax .naming .directory .InitialDirContext ;
242- import java .net .URI ;
243- import java .sql .PreparedStatement ;
244- import java .sql .ResultSet ;
245- import java .sql .SQLException ;
246- import java .util .ArrayList ;
247- import java .util .Collection ;
248- import java .util .HashMap ;
249- import java .util .HashSet ;
250- import java .util .Hashtable ;
251- import java .util .Iterator ;
252- import java .util .List ;
253- import java .util .Map ;
254- import java .util .Set ;
255- import java .util .UUID ;
210+ import edu .emory .mathcs .backport .java .util .Arrays ;
256211
257212@ Component
258213@ Local (value = { ConfigurationManager .class , ConfigurationService .class })
@@ -938,10 +893,9 @@ private void checkPodAttributes(long podId, String podName, long zoneId, String
938893 */
939894 }
940895
941- Grouping .AllocationState allocationState = null ;
942896 if (allocationStateStr != null && !allocationStateStr .isEmpty ()) {
943897 try {
944- allocationState = Grouping .AllocationState .valueOf (allocationStateStr );
898+ Grouping .AllocationState .valueOf (allocationStateStr );
945899 } catch (IllegalArgumentException ex ) {
946900 throw new InvalidParameterValueException ("Unable to resolve Allocation State '" + allocationStateStr + "' to a supported state" );
947901 }
@@ -1363,10 +1317,9 @@ private void checkZoneParameters(String zoneName, String dns1, String dns2, Stri
13631317 throw new InvalidParameterValueException ("Please enter a valid IPv6 address for IP6 DNS2" );
13641318 }
13651319
1366- Grouping .AllocationState allocationState = null ;
13671320 if (allocationStateStr != null && !allocationStateStr .isEmpty ()) {
13681321 try {
1369- allocationState = Grouping .AllocationState .valueOf (allocationStateStr );
1322+ Grouping .AllocationState .valueOf (allocationStateStr );
13701323 } catch (IllegalArgumentException ex ) {
13711324 throw new InvalidParameterValueException ("Unable to resolve Allocation State '" + allocationStateStr + "' to a supported state" );
13721325 }
@@ -2346,7 +2299,6 @@ public Vlan createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws Insuffic
23462299 String endIP = cmd .getEndIp ();
23472300 String newVlanGateway = cmd .getGateway ();
23482301 String newVlanNetmask = cmd .getNetmask ();
2349- Long userId = UserContext .current ().getCallerUserId ();
23502302 String vlanId = cmd .getVlan ();
23512303 Boolean forVirtualNetwork = cmd .isForVirtualNetwork ();
23522304 Long networkId = cmd .getNetworkID ();
@@ -3351,43 +3303,7 @@ private void checkPublicIpRangeErrors(long zoneId, String vlanId, String vlanGat
33513303 throw new InvalidParameterValueException ("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask." );
33523304 }
33533305 }
3354-
3355- private void checkPrivateIpRangeErrors (Long podId , String startIP , String endIP ) {
3356- HostPodVO pod = _podDao .findById (podId );
3357- if (pod == null ) {
3358- throw new InvalidParameterValueException ("Please specify a valid pod." );
3359- }
3360-
3361- // Check that the start and end IPs are valid
3362- if (!NetUtils .isValidIp (startIP )) {
3363- throw new InvalidParameterValueException ("Please specify a valid start IP" );
3364- }
3365-
3366- if (endIP != null && !NetUtils .isValidIp (endIP )) {
3367- throw new InvalidParameterValueException ("Please specify a valid end IP" );
3368- }
3369-
3370- if (endIP != null && !NetUtils .validIpRange (startIP , endIP )) {
3371- throw new InvalidParameterValueException ("Please specify a valid IP range." );
3372- }
3373-
3374- // Check that the IPs that are being added are compatible with the pod's
3375- // CIDR
3376- String cidrAddress = getCidrAddress (podId );
3377- long cidrSize = getCidrSize (podId );
3378-
3379- if (endIP != null && !NetUtils .sameSubnetCIDR (startIP , endIP , cidrSize )) {
3380- throw new InvalidParameterValueException ("Please ensure that your start IP and end IP are in the same subnet, as per the pod's CIDR size." );
3381- }
3382-
3383- if (!NetUtils .sameSubnetCIDR (startIP , cidrAddress , cidrSize )) {
3384- throw new InvalidParameterValueException ("Please ensure that your start IP is in the same subnet as the pod's CIDR address." );
3385- }
3386-
3387- if (endIP != null && !NetUtils .sameSubnetCIDR (endIP , cidrAddress , cidrSize )) {
3388- throw new InvalidParameterValueException ("Please ensure that your end IP is in the same subnet as the pod's CIDR address." );
3389- }
3390- }
3306+
33913307
33923308 private String getCidrAddress (String cidr ) {
33933309 String [] cidrPair = cidr .split ("\\ /" );
@@ -3399,15 +3315,6 @@ private int getCidrSize(String cidr) {
33993315 return Integer .parseInt (cidrPair [1 ]);
34003316 }
34013317
3402- private String getCidrAddress (long podId ) {
3403- HostPodVO pod = _podDao .findById (podId );
3404- return pod .getCidrAddress ();
3405- }
3406-
3407- private long getCidrSize (long podId ) {
3408- HostPodVO pod = _podDao .findById (podId );
3409- return pod .getCidrSize ();
3410- }
34113318
34123319 @ Override
34133320 public void checkPodCidrSubnets (long dcId , Long podIdToBeSkipped , String cidr ) {
@@ -4359,7 +4266,6 @@ public List<? extends NetworkOffering> searchForNetworkOfferings(ListNetworkOffe
43594266 public boolean isOfferingForVpc (NetworkOffering offering ) {
43604267 boolean vpcProvider = _ntwkOffServiceMapDao .isProviderForNetworkOffering (offering .getId (),
43614268 Provider .VPCVirtualRouter );
4362- boolean internalLb = offering .getInternalLb ();
43634269 return vpcProvider ;
43644270 }
43654271
@@ -4516,6 +4422,7 @@ public AccountVO markDefaultZone(String accountName, long domainId, long default
45164422
45174423 // Note: This method will be used for entity name validations in the coming
45184424 // releases (place holder for now)
4425+ @ SuppressWarnings ("unused" )
45194426 private void validateEntityName (String str ) {
45204427 String forbidden = "~!@#$%^&*()+=" ;
45214428 char [] searchChars = forbidden .toCharArray ();
@@ -4741,7 +4648,6 @@ public PortableIpRange createPortableIpRange(CreatePortableIpRangeCmd cmd) throw
47414648 String endIP = cmd .getEndIp ();
47424649 String gateway = cmd .getGateway ();
47434650 String netmask = cmd .getNetmask ();
4744- Long userId = UserContext .current ().getCallerUserId ();
47454651 String vlanId = cmd .getVlan ();
47464652
47474653 Region region = _regionDao .findById (regionId );
0 commit comments