private PassthroughResponse ResizeCluster(ClusterRoleCollection roleCollection, string subscriptionId,
                                                  string cloudServiceName, string dnsName)
        {
            var workerNode = roleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));

            if (workerNode == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }

            int instanceCount = workerNode.InstanceCount;
            var cluster       = this.GetCluster(dnsName, cloudServiceName, subscriptionId);

            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }

            var clusterWorkerRole = cluster.ClusterRoleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));

            if (clusterWorkerRole == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }
            clusterWorkerRole.InstanceCount = instanceCount;

            return(new PassthroughResponse {
                Data = new Contracts.May2014.Operation {
                    OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress,
                }
            });
        }
        public async Task <PassthroughResponse> UpdateRole(string subscriptionId, string cloudServiceName, string resourceNamespace, string dnsName)
        {
            var requestMessage = this.Request;

            if (requestMessage.Headers.GetValues("SchemaVersion").Any(v => v.Equals("1.0")))
            {
                throw new NotSupportedException(ClustersTestConstants.NotSupportedBySubscriptionException);
            }
            ClusterRoleCollection roleCollection = await requestMessage.Content.ReadAsAsync <ClusterRoleCollection>();

            var actionValue = requestMessage.RequestUri.ParseQueryString()["action"];
            PassthroughResponse response;

            //If no action is specified then RP defaults to Enable Rdp action.
            if (string.IsNullOrEmpty(actionValue))
            {
                this.EnableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName);
            }

            switch (actionValue.ToLowerInvariant())
            {
            case "resize":
                response = this.ResizeCluster(roleCollection, subscriptionId, cloudServiceName, dnsName);
                break;

            case "enablerdp":
                response = this.EnableDisableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName);
                break;

            default:
                throw new NotSupportedException(string.Format(ClustersTestConstants.NotSupportedAction,
                                                              actionValue));
            }
            return(response);
        }
        private PassthroughResponse EnableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
                                              string cloudServiceName, string dnsName)
        {
            Assert.IsNotNull(roleCollection, "Role collection is null");
            Assert.IsTrue(roleCollection.Count > 0, "There are no roles in the role collection");
            var cluster = this.GetCluster(dnsName, cloudServiceName, subscriptionId);

            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }
            ClusterRole previousRole = null;

            foreach (var role in roleCollection)
            {
                Assert.IsNotNull(role, "The role is null");
                Assert.IsTrue(role.RemoteDesktopSettings.IsEnabled);
                if (previousRole != null)
                {
                    Assert.IsTrue(
                        previousRole.RemoteDesktopSettings.AuthenticationCredential.Username ==
                        role.RemoteDesktopSettings.AuthenticationCredential.Username,
                        "rdpUsername between roles doesn't match");
                    Assert.IsTrue(
                        previousRole.RemoteDesktopSettings.AuthenticationCredential.Password ==
                        role.RemoteDesktopSettings.AuthenticationCredential.Password,
                        "rdpPassword between roles doesn't match");
                    Assert.IsTrue(previousRole.RemoteDesktopSettings.RemoteAccessExpiry ==
                                  role.RemoteDesktopSettings.RemoteAccessExpiry,
                                  "RemoteAccessExpory between roles doesn't match");
                }
                else
                {
                    Assert.IsNotNull(role.RemoteDesktopSettings.AuthenticationCredential.Username,
                                     "rdpUsername is null");
                    Assert.IsNotNull(role.RemoteDesktopSettings.AuthenticationCredential.Password,
                                     "rdpPassword is null");
                    Assert.IsNotNull(role.RemoteDesktopSettings.RemoteAccessExpiry,
                                     "RemoteAccessExpory is numm");
                }
                previousRole = role;
            }

            cluster.ClusterRoleCollection = roleCollection;
            return(new PassthroughResponse {
                Data = new Contracts.May2014.Operation {
                    OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress,
                }
            });
        }
        private PassthroughResponse DisableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
                                               string cloudServiceName, string dnsName)
        {
            var cluster = this.GetCluster(dnsName, cloudServiceName, subscriptionId);

            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }
            cluster.ClusterRoleCollection = roleCollection;
            return(new PassthroughResponse {
                Data = new Contracts.May2014.Operation {
                    OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress,
                }
            });
        }
        private PassthroughResponse EnableDisableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
                                                     string cloudServiceName, string dnsName)
        {
            Assert.IsNotNull(roleCollection);
            Assert.IsTrue(roleCollection.Count > 0);
            var firstRole = roleCollection.FirstOrDefault();

            Assert.IsNotNull(firstRole);
            Assert.IsNotNull(firstRole.RemoteDesktopSettings);
            if (firstRole.RemoteDesktopSettings.IsEnabled)
            {
                return(this.EnableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName));
            }
            else
            {
                return(this.DisableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName));
            }
        }
Beispiel #6
0
        public async Task <PassthroughResponse> ChangeClusterSize(string subscriptionId, string cloudServiceName, string resourceNamespace, string dnsName)
        {
            var requestMessage = this.Request;
            var actionValue    = requestMessage.RequestUri.ParseQueryString()["action"];

            if (!requestMessage.Headers.GetValues("SchemaVersion").Any(v => v.Equals("2.0")))
            {
                throw new NotSupportedException(ClustersTestConstants.NotSupportedBySubscriptionException);
            }
            ClusterRoleCollection roleCollection = await requestMessage.Content.ReadAsAsync <ClusterRoleCollection>();

            var workerNode = roleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));

            if (workerNode == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }

            int instanceCount = workerNode.InstanceCount;
            var cluster       = this.GetCluster(dnsName, cloudServiceName, subscriptionId);

            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }

            var clusterWorkerRole = cluster.ClusterRoleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));

            if (clusterWorkerRole == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }
            clusterWorkerRole.InstanceCount = instanceCount;

            return(new PassthroughResponse {
                Data = new Operation {
                    OperationId = Guid.NewGuid().ToString(), Status = OperationStatus.InProgress,
                }
            });
        }
Beispiel #7
0
 public ClusterBase()
 {
     this.Components       = new ComponentSet();
     ClusterRoleCollection = new ClusterRoleCollection();
 }
Beispiel #8
0
 public Task <PassthroughResponse> EnableDisableRdp(string subscriptionId, string cloudServiceName, string resourceNamespace, string clusterDnsName,
                                                    string actionType, ClusterRoleCollection roleCollection, CancellationToken cancellationToken)
 {
     return((Task <PassthroughResponse>)(base.CreateAndInvokeRestRequestForParentMethodAsync <PassthroughResponse>(subscriptionId, cloudServiceName, resourceNamespace, clusterDnsName, actionType, roleCollection)));
 }
Beispiel #9
0
 public Task <PassthroughResponse> ChangeClusterSize(string subscriptionId, string cloudServiceName, string resourceNamespace, string dnsName, string roleAction, ClusterRoleCollection clusterRoleCollection, CancellationToken cancellationToken)
 {
     return
         ((Task <PassthroughResponse>)
              (base.CreateAndInvokeRestRequestForParentMethodAsync <PassthroughResponse>(subscriptionId, cloudServiceName, resourceNamespace, dnsName, roleAction, clusterRoleCollection, cancellationToken)));
 }
 public ClusterBase()
 {
     this.Components = new ComponentSet();
     ClusterRoleCollection = new ClusterRoleCollection();
 }
 private PassthroughResponse DisableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
     string cloudServiceName, string dnsName)
 {
     var cluster = this.GetCluster(dnsName, cloudServiceName, subscriptionId);
     if (cluster == null)
     {
         throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
     }
     cluster.ClusterRoleCollection = roleCollection;
     return new PassthroughResponse { Data = new Contracts.May2014.Operation { OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress, } };
 }
        private PassthroughResponse EnableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
            string cloudServiceName, string dnsName)
        {
            Assert.IsNotNull(roleCollection, "Role collection is null");
            Assert.IsTrue(roleCollection.Count > 0, "There are no roles in the role collection");
            var cluster = this.GetCluster(dnsName, cloudServiceName, subscriptionId);
            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }
            ClusterRole previousRole = null;
            foreach (var role in roleCollection)
            {
                Assert.IsNotNull(role,"The role is null");
                Assert.IsTrue(role.RemoteDesktopSettings.IsEnabled);
                if (previousRole != null)
                {
                    Assert.IsTrue(
                        previousRole.RemoteDesktopSettings.AuthenticationCredential.Username ==
                        role.RemoteDesktopSettings.AuthenticationCredential.Username,
                        "rdpUsername between roles doesn't match");
                    Assert.IsTrue(
                        previousRole.RemoteDesktopSettings.AuthenticationCredential.Password ==
                        role.RemoteDesktopSettings.AuthenticationCredential.Password,
                        "rdpPassword between roles doesn't match");
                    Assert.IsTrue(previousRole.RemoteDesktopSettings.RemoteAccessExpiry ==
                                  role.RemoteDesktopSettings.RemoteAccessExpiry,
                        "RemoteAccessExpory between roles doesn't match");
                }
                else
                {
                    Assert.IsNotNull(role.RemoteDesktopSettings.AuthenticationCredential.Username,
                        "rdpUsername is null");
                    Assert.IsNotNull(role.RemoteDesktopSettings.AuthenticationCredential.Password,
                        "rdpPassword is null");
                    Assert.IsNotNull(role.RemoteDesktopSettings.RemoteAccessExpiry,
                        "RemoteAccessExpory is numm");
                }
                previousRole = role;
            }

            cluster.ClusterRoleCollection = roleCollection;
            return new PassthroughResponse { Data = new Contracts.May2014.Operation { OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress, } };
        }
        private PassthroughResponse ResizeCluster(ClusterRoleCollection roleCollection, string subscriptionId,
            string cloudServiceName, string dnsName)
        {
            var workerNode = roleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));
            if (workerNode == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }

            int instanceCount = workerNode.InstanceCount;
            var cluster = this.GetCluster(dnsName, cloudServiceName, subscriptionId);
            if (cluster == null)
            {
                throw new ArgumentNullException(string.Format(ClustersTestConstants.ClusterDoesNotExistException, dnsName, subscriptionId));
            }

            var clusterWorkerRole = cluster.ClusterRoleCollection.SingleOrDefault(role => role.FriendlyName.Equals("WorkerNodeRole"));
            if (clusterWorkerRole == null)
            {
                throw new NullReferenceException(ClustersTestConstants.NoDataNodeException);
            }
            clusterWorkerRole.InstanceCount = instanceCount;

            return new PassthroughResponse { Data = new Contracts.May2014.Operation { OperationId = Guid.NewGuid().ToString(), Status = Contracts.May2014.OperationStatus.InProgress, } };
        }
 private PassthroughResponse EnableDisableRdp(ClusterRoleCollection roleCollection, string subscriptionId,
     string cloudServiceName, string dnsName)
 {
     Assert.IsNotNull(roleCollection);
     Assert.IsTrue(roleCollection.Count > 0);
     var firstRole = roleCollection.FirstOrDefault();
     Assert.IsNotNull(firstRole);
     Assert.IsNotNull(firstRole.RemoteDesktopSettings);
     if (firstRole.RemoteDesktopSettings.IsEnabled)
     {
         return this.EnableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName);
     }
     else
     {
         return this.DisableRdp(roleCollection, subscriptionId, cloudServiceName, dnsName);
     }
 }