1616// under the License.
1717package com .cloud .kubernetes .cluster ;
1818
19- import java .math .BigInteger ;
20- import java .net .MalformedURLException ;
21- import java .net .URL ;
22- import java .security .SecureRandom ;
23- import java .util .ArrayList ;
24- import java .util .Arrays ;
25- import java .util .Date ;
26- import java .util .EnumSet ;
27- import java .util .HashMap ;
28- import java .util .List ;
29- import java .util .Map ;
30- import java .util .UUID ;
31- import java .util .concurrent .ConcurrentHashMap ;
32- import java .util .concurrent .Executors ;
33- import java .util .concurrent .ScheduledExecutorService ;
34- import java .util .concurrent .TimeUnit ;
35- import java .util .regex .Matcher ;
36- import java .util .regex .Pattern ;
37-
38- import javax .inject .Inject ;
39- import javax .naming .ConfigurationException ;
40-
41- import org .apache .cloudstack .acl .ControlledEntity ;
42- import org .apache .cloudstack .acl .SecurityChecker ;
43- import org .apache .cloudstack .annotation .AnnotationService ;
44- import org .apache .cloudstack .annotation .dao .AnnotationDao ;
45- import org .apache .cloudstack .api .ApiConstants ;
46- import org .apache .cloudstack .api .ApiConstants .VMDetails ;
47- import org .apache .cloudstack .api .ResponseObject .ResponseView ;
48- import org .apache .cloudstack .api .command .user .kubernetes .cluster .CreateKubernetesClusterCmd ;
49- import org .apache .cloudstack .api .command .user .kubernetes .cluster .DeleteKubernetesClusterCmd ;
50- import org .apache .cloudstack .api .command .user .kubernetes .cluster .GetKubernetesClusterConfigCmd ;
51- import org .apache .cloudstack .api .command .user .kubernetes .cluster .ListKubernetesClustersCmd ;
52- import org .apache .cloudstack .api .command .user .kubernetes .cluster .ScaleKubernetesClusterCmd ;
53- import org .apache .cloudstack .api .command .user .kubernetes .cluster .StartKubernetesClusterCmd ;
54- import org .apache .cloudstack .api .command .user .kubernetes .cluster .StopKubernetesClusterCmd ;
55- import org .apache .cloudstack .api .command .user .kubernetes .cluster .UpgradeKubernetesClusterCmd ;
56- import org .apache .cloudstack .api .response .KubernetesClusterConfigResponse ;
57- import org .apache .cloudstack .api .response .KubernetesClusterResponse ;
58- import org .apache .cloudstack .api .response .ListResponse ;
59- import org .apache .cloudstack .api .response .UserVmResponse ;
60- import org .apache .cloudstack .config .ApiServiceConfiguration ;
61- import org .apache .cloudstack .context .CallContext ;
62- import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
63- import org .apache .cloudstack .framework .config .ConfigKey ;
64- import org .apache .cloudstack .managed .context .ManagedContextRunnable ;
65- import org .apache .commons .codec .binary .Base64 ;
66- import org .apache .commons .collections .CollectionUtils ;
67- import org .apache .log4j .Level ;
68- import org .apache .log4j .Logger ;
69-
7019import com .cloud .api .ApiDBUtils ;
7120import com .cloud .api .query .dao .NetworkOfferingJoinDao ;
7221import com .cloud .api .query .dao .TemplateJoinDao ;
165114import com .cloud .vm .VirtualMachine ;
166115import com .cloud .vm .dao .VMInstanceDao ;
167116import com .google .common .base .Strings ;
117+ import org .apache .cloudstack .acl .ControlledEntity ;
118+ import org .apache .cloudstack .acl .SecurityChecker ;
119+ import org .apache .cloudstack .annotation .AnnotationService ;
120+ import org .apache .cloudstack .annotation .dao .AnnotationDao ;
121+ import org .apache .cloudstack .api .ApiConstants ;
122+ import org .apache .cloudstack .api .ApiConstants .VMDetails ;
123+ import org .apache .cloudstack .api .ResponseObject .ResponseView ;
124+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .CreateKubernetesClusterCmd ;
125+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .DeleteKubernetesClusterCmd ;
126+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .GetKubernetesClusterConfigCmd ;
127+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .ListKubernetesClustersCmd ;
128+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .ScaleKubernetesClusterCmd ;
129+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .StartKubernetesClusterCmd ;
130+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .StopKubernetesClusterCmd ;
131+ import org .apache .cloudstack .api .command .user .kubernetes .cluster .UpgradeKubernetesClusterCmd ;
132+ import org .apache .cloudstack .api .response .KubernetesClusterConfigResponse ;
133+ import org .apache .cloudstack .api .response .KubernetesClusterResponse ;
134+ import org .apache .cloudstack .api .response .ListResponse ;
135+ import org .apache .cloudstack .api .response .UserVmResponse ;
136+ import org .apache .cloudstack .config .ApiServiceConfiguration ;
137+ import org .apache .cloudstack .context .CallContext ;
138+ import org .apache .cloudstack .engine .orchestration .service .NetworkOrchestrationService ;
139+ import org .apache .cloudstack .framework .config .ConfigKey ;
140+ import org .apache .cloudstack .managed .context .ManagedContextRunnable ;
141+ import org .apache .commons .codec .binary .Base64 ;
142+ import org .apache .commons .collections .CollectionUtils ;
143+ import org .apache .log4j .Level ;
144+ import org .apache .log4j .Logger ;
145+
146+ import javax .inject .Inject ;
147+ import javax .naming .ConfigurationException ;
148+ import java .math .BigInteger ;
149+ import java .net .MalformedURLException ;
150+ import java .net .URL ;
151+ import java .security .SecureRandom ;
152+ import java .util .ArrayList ;
153+ import java .util .Arrays ;
154+ import java .util .Date ;
155+ import java .util .EnumSet ;
156+ import java .util .HashMap ;
157+ import java .util .List ;
158+ import java .util .Map ;
159+ import java .util .UUID ;
160+ import java .util .concurrent .ConcurrentHashMap ;
161+ import java .util .concurrent .Executors ;
162+ import java .util .concurrent .ScheduledExecutorService ;
163+ import java .util .concurrent .TimeUnit ;
168164
169165import static com .cloud .utils .NumbersUtil .toHumanReadableSize ;
170166
@@ -428,21 +424,18 @@ private boolean validateServiceOffering(final ServiceOffering serviceOffering, f
428424
429425 private void validateDockerRegistryParams (final String dockerRegistryUserName ,
430426 final String dockerRegistryPassword ,
431- final String dockerRegistryUrl ,
432- final String dockerRegistryEmail ) {
427+ final String dockerRegistryUrl ) {
433428 // if no params related to docker registry specified then nothing to validate so return true
434429 if ((dockerRegistryUserName == null || dockerRegistryUserName .isEmpty ()) &&
435430 (dockerRegistryPassword == null || dockerRegistryPassword .isEmpty ()) &&
436- (dockerRegistryUrl == null || dockerRegistryUrl .isEmpty ()) &&
437- (dockerRegistryEmail == null || dockerRegistryEmail .isEmpty ())) {
431+ (dockerRegistryUrl == null || dockerRegistryUrl .isEmpty ())) {
438432 return ;
439433 }
440434
441435 // all params related to docker registry must be specified or nothing
442436 if (!((dockerRegistryUserName != null && !dockerRegistryUserName .isEmpty ()) &&
443437 (dockerRegistryPassword != null && !dockerRegistryPassword .isEmpty ()) &&
444- (dockerRegistryUrl != null && !dockerRegistryUrl .isEmpty ()) &&
445- (dockerRegistryEmail != null && !dockerRegistryEmail .isEmpty ()))) {
438+ (dockerRegistryUrl != null && !dockerRegistryUrl .isEmpty ()))) {
446439 throw new InvalidParameterValueException ("All the docker private registry parameters (username, password, url, email) required are specified" );
447440 }
448441
@@ -451,12 +444,6 @@ private void validateDockerRegistryParams(final String dockerRegistryUserName,
451444 } catch (MalformedURLException e ) {
452445 throw new InvalidParameterValueException ("Invalid docker registry url specified" );
453446 }
454-
455- Pattern VALID_EMAIL_ADDRESS_REGEX = Pattern .compile ("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\ .[A-Z]{2,6}$" , Pattern .CASE_INSENSITIVE );
456- Matcher matcher = VALID_EMAIL_ADDRESS_REGEX .matcher (dockerRegistryEmail );
457- if (!matcher .find ()) {
458- throw new InvalidParameterValueException ("Invalid docker registry email specified" );
459- }
460447 }
461448
462449 private DeployDestination plan (final long nodesCount , final DataCenter zone , final ServiceOffering offering ) throws InsufficientServerCapacityException {
@@ -619,7 +606,6 @@ private void validateKubernetesClusterCreateParameters(final CreateKubernetesClu
619606 final String dockerRegistryUserName = cmd .getDockerRegistryUserName ();
620607 final String dockerRegistryPassword = cmd .getDockerRegistryPassword ();
621608 final String dockerRegistryUrl = cmd .getDockerRegistryUrl ();
622- final String dockerRegistryEmail = cmd .getDockerRegistryEmail ();
623609 final Long nodeRootDiskSize = cmd .getNodeRootDiskSize ();
624610 final String externalLoadBalancerIpAddress = cmd .getExternalLoadBalancerIpAddress ();
625611
@@ -706,7 +692,7 @@ private void validateKubernetesClusterCreateParameters(final CreateKubernetesClu
706692 throw new InvalidParameterValueException ("Given service offering ID: %s is not suitable for Kubernetes cluster" );
707693 }
708694
709- validateDockerRegistryParams (dockerRegistryUserName , dockerRegistryPassword , dockerRegistryUrl , dockerRegistryEmail );
695+ validateDockerRegistryParams (dockerRegistryUserName , dockerRegistryPassword , dockerRegistryUrl );
710696
711697 Network network = null ;
712698 if (networkId != null ) {
@@ -729,7 +715,7 @@ private void validateKubernetesClusterCreateParameters(final CreateKubernetesClu
729715 }
730716
731717 if (!KubernetesClusterExperimentalFeaturesEnabled .value () && (!Strings .isNullOrEmpty (dockerRegistryUrl ) ||
732- !Strings .isNullOrEmpty (dockerRegistryUserName ) || !Strings .isNullOrEmpty (dockerRegistryEmail ) || ! Strings . isNullOrEmpty ( dockerRegistryPassword ))) {
718+ !Strings .isNullOrEmpty (dockerRegistryUserName ) || !Strings .isNullOrEmpty (dockerRegistryPassword ))) {
733719 throw new CloudRuntimeException (String .format ("Private registry for the Kubernetes cluster is an experimental feature. Use %s configuration for enabling experimental features" , KubernetesClusterExperimentalFeaturesEnabled .key ()));
734720 }
735721 }
@@ -779,7 +765,6 @@ private void addKubernetesClusterDetails(final KubernetesCluster kubernetesClust
779765 final String dockerRegistryUserName = cmd .getDockerRegistryUserName ();
780766 final String dockerRegistryPassword = cmd .getDockerRegistryPassword ();
781767 final String dockerRegistryUrl = cmd .getDockerRegistryUrl ();
782- final String dockerRegistryEmail = cmd .getDockerRegistryEmail ();
783768 final boolean networkCleanup = cmd .getNetworkId () == null ;
784769 Transaction .execute (new TransactionCallbackNoReturn () {
785770 @ Override
@@ -797,9 +782,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
797782 if (!Strings .isNullOrEmpty (dockerRegistryUrl )) {
798783 details .add (new KubernetesClusterDetailsVO (kubernetesCluster .getId (), ApiConstants .DOCKER_REGISTRY_URL , dockerRegistryUrl , true ));
799784 }
800- if (!Strings .isNullOrEmpty (dockerRegistryEmail )) {
801- details .add (new KubernetesClusterDetailsVO (kubernetesCluster .getId (), ApiConstants .DOCKER_REGISTRY_EMAIL , dockerRegistryEmail , true ));
802- }
785+
803786 details .add (new KubernetesClusterDetailsVO (kubernetesCluster .getId (), ApiConstants .USERNAME , "admin" , true ));
804787 SecureRandom random = new SecureRandom ();
805788 String randomPassword = new BigInteger (130 , random ).toString (32 );
0 commit comments