Inheritance: Microsoft.WindowsAzure.Management.ServiceManagement.IaaS.IaaSDeploymentManagementCmdletBase
Esempio n. 1
0
        private IEnumerable <string> ListVMRoles()
        {
            IEnumerable <string>      strs;
            Func <string, Deployment> func = null;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                GetAzureVMCommand getAzureVMCommand = this;
                if (func == null)
                {
                    func = (string s) => base.Channel.GetDeployment(s, this.ServiceName, base.CurrentDeployment.Name);
                }
                Deployment         deployment = ((CmdletBase <IServiceManagement>)getAzureVMCommand).RetryCall <Deployment>(func);
                RoleList           roleList   = deployment.RoleList;
                IEnumerable <Role> roles      = roleList.Where <Role>((Role r) => r.RoleType == "PersistentVMRole");
                strs = roles.Select <Role, string>((Role r) => r.RoleName);
            }
            return(strs);
        }
Esempio n. 2
0
        private void ListAllVMs()
        {
            Func <string, HostedServiceList> func = null;

            using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel))
            {
                GetAzureVMCommand getAzureVMCommand = this;
                if (func == null)
                {
                    func = (string s) => base.Channel.ListHostedServices(s);
                }
                HostedServiceList hostedServiceList = ((CmdletBase <IServiceManagement>)getAzureVMCommand).RetryCall <HostedServiceList>(func);
                if (hostedServiceList != null)
                {
                    List <HostedService> .Enumerator enumerator = hostedServiceList.GetEnumerator();
                    try
                    {
                        Func <string, Deployment> func1 = null;
                        while (enumerator.MoveNext())
                        {
                            HostedService current = enumerator.Current;
                            using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel))
                            {
                                try
                                {
                                    GetAzureVMCommand getAzureVMCommand1 = this;
                                    if (func1 == null)
                                    {
                                        func1 = (string s) => base.Channel.GetDeploymentBySlot(s, current.ServiceName, "Production");
                                    }
                                    Deployment deployment = ((CmdletBase <IServiceManagement>)getAzureVMCommand1).RetryCall <Deployment>(func1);
                                    List <Role> .Enumerator enumerator1 = deployment.RoleList.GetEnumerator();
                                    try
                                    {
                                        Func <RoleInstance, bool> func2 = null;
                                        while (enumerator1.MoveNext())
                                        {
                                            Role role = enumerator1.Current;
                                            if (role.RoleType != "PersistentVMRole")
                                            {
                                                continue;
                                            }
                                            RoleInstanceList roleInstanceList = deployment.RoleInstanceList;
                                            if (func2 == null)
                                            {
                                                func2 = (RoleInstance r) => r.RoleName == role.RoleName;
                                            }
                                            RoleInstance roleInstance = roleInstanceList.Where <RoleInstance>(func2).First <RoleInstance>();
                                            PersistentVMRoleListContext persistentVMRoleListContext = new PersistentVMRoleListContext();
                                            persistentVMRoleListContext.ServiceName = current.ServiceName;
                                            persistentVMRoleListContext.Status      = roleInstance.InstanceStatus;
                                            persistentVMRoleListContext.Name        = roleInstance.RoleName;
                                            PersistentVMRoleListContext persistentVMRoleListContext1 = persistentVMRoleListContext;
                                            base.WriteObject(persistentVMRoleListContext1, true);
                                        }
                                    }
                                    finally
                                    {
                                        enumerator1.Dispose();
                                    }
                                }
                                catch (CommunicationException communicationException1)
                                {
                                    CommunicationException communicationException = communicationException1;
                                    if (communicationException as EndpointNotFoundException == null)
                                    {
                                        throw;
                                    }
                                }
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                }
            }
        }