private void connectButton_Click(object sender, EventArgs e)
        {
            connectButton.Enabled = false;
            connectButton.Text = "Connecting. Please wait...";
            connectButton.Refresh();
            VCenterUserName = userIDTextbox.Text;
            VCenterUserPassword = passwordTextbox.Text;
            VCenterServer = vcenterServerName.Text;

            try
            {
                VCenterClient = new VimClient();
                VCenterClient.Connect(String.Format("https://{0}/sdk", vcenterServerName.Text));
                VCenterClient.Login(VCenterUserName, VCenterUserPassword);

                IList<EntityViewBase> dataCenterList = VCenterClient.FindEntityViews(typeof(Datacenter), null, null, null);
                foreach (Datacenter dc in dataCenterList)
                {
                    datacenterCombobox.Items.Add(new ComboboxItem(dc.Name, dc.MoRef.Value));
                }
                connectButton.Text = "Connected. Click OK or Select a datacenter and click Import.";
                button2.Enabled = true;
                datacenterCombobox.Enabled = true;
                datacenterCombobox.SelectedIndex = 0;
                powerStateCombobox.Enabled = true;
                powerStateCombobox.SelectedIndex = 0;
                DCMoRef = ((ComboboxItem)datacenterCombobox.SelectedItem).Value;
                PowerState = powerStateCombobox.SelectedText;
                button1.Enabled = true;
                Connected = true;
            }
            catch (Exception ex)
            {
                connectButton.Text = "Error occurred. Adjust settings and Connect.";
                connectButton.Enabled = true;
            }
            finally
            { }
        }
Exemplo n.º 2
1
        protected VimClient ConnectServer(string viServer, string viUser, string viPassword)
        {
            //
            // Establish a connetion to the provided sdk server
            //
            VimClient vimClient = new VimClient();
            ServiceContent vimServiceContent = new ServiceContent();
            UserSession vimSession = new UserSession();
            //
            // Connect over https to the /sdk page
            //
            try
            {
                vimClient.Connect(viServer);
                vimSession = vimClient.Login(viUser, viPassword);
                vimServiceContent = vimClient.ServiceContent;

                return vimClient;
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
            catch (Exception e)
            {
                //
                // Regular Exception occurred
                //
                txtErrors.Text = "A server fault of type " + e.GetType().Name + " with message '" + e.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                vimClient = null;
                return vimClient;
            }
        }
Exemplo n.º 3
0
        public async Task <Vm> Deploy(VmTemplate template, bool privileged = false)
        {
            var vm = await Load(template.Name + "#" + template.IsolationTag);

            if (vm != null)
            {
                return(vm);
            }

            VimClient host = FindHostByAffinity(template.IsolationTag);

            _logger.LogDebug("deploy: host " + host.Name);

            NormalizeTemplate(template, host.Options, privileged);
            _logger.LogDebug("deploy: normalized " + template.Name);

            if (!template.Disks.IsEmpty())
            {
                bool found = await host.FileExists(template.Disks[0].Path);

                if (!found)
                {
                    throw new Exception("Template disks have not been prepared.");
                }
            }

            if (!host.Options.IsNsxNetwork && !host.Options.Uplink.StartsWith("nsx."))
            {
                _logger.LogDebug("deploy: reserve vlans ");
                _vlanman.ReserveVlans(template, host.Options.IsVCenter);
            }

            _logger.LogDebug("deploy: " + template.Name + " " + host.Name);
            return(await host.Deploy(template));
        }
Exemplo n.º 4
0
        private async Task AddHost(string url)
        {
            string hostname = new Uri(url).Host;

            _logger.LogDebug($"Adding host {hostname}");

            if (_hostCache.ContainsKey(hostname))
            {
                await _hostCache[hostname].Disconnect();
                _hostCache.TryRemove(hostname, out VimClient discard);
                await Task.Delay(100);
            }

            HypervisorServiceConfiguration hostOptions = _options.Clone <HypervisorServiceConfiguration>();

            if (!url.EndsWith("/sdk"))
            {
                url += "/sdk";
            }

            hostOptions.Url  = url;
            hostOptions.Host = hostname;
            var vHost = new VimClient(
                hostOptions,
                _vmCache,
                _vlanman,
                _mill.CreateLogger <VimClient>()
                );

            _hostCache.AddOrUpdate(hostname, vHost, (k, v) => (v = vHost));
            _logger.LogDebug($"Added host {hostname}; cache: {_hostCache.Values.Count}");
        }
Exemplo n.º 5
0
        private VimClient FindHostByAffinity(string tag)
        {
            VimClient host = null;

            lock (_affinityMap)
            {
                if (_affinityMap.ContainsKey(tag))
                {
                    host = _affinityMap[tag];
                }
                else
                {
                    Vm vm = _vmCache.Values.Where(o => o.Name.EndsWith(tag)).FirstOrDefault();
                    if (vm != null)
                    {
                        host = _hostCache[vm.Host];
                    }
                    else
                    {
                        host = FindHostByFewestVms();
                    }
                    _affinityMap.Add(tag, host);
                }
            }
            return(host);
        }
Exemplo n.º 6
0
        public async Task <int> DeleteDisks(VmTemplate template)
        {
            if (template.Disks.Length == 0)
            {
                return(-1);
            }

            int progress = await VerifyDisks(template);

            if (progress < 0)
            {
                return(-1);
            }

            if (progress == 100)
            {
                VimClient host = FindHostByRandom();
                foreach (VmDisk disk in template.Disks)
                {
                    //protect stock disks; only delete a disk if it is local to the workspace
                    //i.e. the disk folder matches the workspaceId
                    if (template.IsolationTag.HasValue() && disk.Path.Contains(template.IsolationTag))
                    {
                        Task deleteTask = host.DeleteDisk(disk.Path);
                    }
                }
                return(-1);
            }
            throw new Exception("Cannot delete disk that isn't fully created.");
        }
Exemplo n.º 7
0
        public async Task <int> CreateDisks(VmTemplate template)
        {
            if (template.Disks.Length == 0)
            {
                return(-1);
            }

            int progress = await VerifyDisks(template);

            if (progress < 0)
            {
                VimClient host = FindHostByRandom();
                if (template.Disks[0].Source.HasValue())
                {
                    Task cloneTask = host.CloneDisk(template.Id, template.Disks[0].Source, template.Disks[0].Path);
                    progress = 0;
                }
                else
                {
                    await host.CreateDisk(template.Disks[0]);

                    progress = 100;
                }
            }
            return(progress);
        }
        public TestEnvironment( VmWareConfiguration vmWareConfiguration )
        {
            _vmWareConfiguration = vmWareConfiguration;

            _virtualHost = new VimClient();
            _virtualHost.Login(
                string.Format( "https://{0}/sdk", _vmWareConfiguration.FarmUrl ),
                _vmWareConfiguration.FarmLogin,
                _vmWareConfiguration.FarmPassword );

            _vm = ( VirtualMachine )_virtualHost.FindEntityView(
                typeof( VirtualMachine ),
                null,
                new NameValueCollection
                    {
                        {"name", _vmWareConfiguration.VirtualMachineName}
                    },
                null );

            _manager = new GuestOperationsManager( _virtualHost, _virtualHost.ServiceContent.GuestOperationsManager );

            _authentication = new NamePasswordAuthentication
                                  {
                                      Username = _vmWareConfiguration.User,
                                      Password = _vmWareConfiguration.Password,
                                      InteractiveSession = true
                                  };
        }
Exemplo n.º 9
0
 /// <summary>
 /// login to VMware server by specified credential
 /// </summary>
 /// <param name="userName">user name</param>
 /// <param name="pwd">password for specified user</param>
 protected internal void LogIn(string userName, string pwd)
 {
     if (vClient == null)
     {
         vClient = new VimClient();
     }
     vClient.Login(ServerUrl, userName, pwd);
 }
Exemplo n.º 10
0
        public async Task SetAffinity(string isolationTag, Vm[] vms, bool start)
        {
            _logger.LogDebug("setaffinity: find host ");
            VimClient host = FindHostByAffinity(isolationTag);

            _logger.LogDebug("setaffinity: setting affinity ");
            await host.SetAffinity(isolationTag, vms, start);
        }
Exemplo n.º 11
0
 /// <summary>
 /// disconnect for current server and set null value of VimClient instance
 /// </summary>
 protected internal void Disconnect()
 {
     if (vClient != null)
     {
         try
         {
             vClient.Disconnect();
             vClient = null;
         }
         catch { }
     }
 }
Exemplo n.º 12
0
 public VMware(string address, string username, string password)
 {
     //this.mService = new VimService();
     this.mVimClient = new VimClientImpl();
     this.Address = address;
     this.Username = username;
     this.Password = password;
     this.Login();
     EndpointAddress endPoint = new EndpointAddress(string.Format("net.tcp://127.0.0.1:1511"));
     using (ChannelFactory<IJobReport> channelFactory = new ChannelFactory<IJobReport>(new NetTcpBinding(), endPoint))
     {
         this.mJobReport = channelFactory.CreateChannel(endPoint);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// logout from current server and set null value of VimClient instance
 /// </summary>
 protected internal void Logout()
 {
     if (vClient != null)
     {
         try
         {
             vClient.Logout();
             if (vClient != null)
             {
                 vClient.Disconnect();
             }
             vClient = null;
         }
         catch { }
     }
 }
Exemplo n.º 14
0
        protected List<Datacenter> GetDataCenter(VimClient vimClient, string dcName = null)
        {
            //
            // Get a list of datacenters
            //
            List<Datacenter> lstDatacenters = new List<Datacenter>();
            List<EntityViewBase> appDatacenters = new List<EntityViewBase>();
            try
            {
                if (dcName == null)
                {
                    //
                    // Return all datacenters
                    //
                    appDatacenters = vimClient.FindEntityViews(typeof(Datacenter), null, null, null);
                }
                else
                {
                    //
                    // Return the named datacenter
                    //
                    NameValueCollection dcFilter = new NameValueCollection();
                    dcFilter.Add("name", dcName);
                    appDatacenters = vimClient.FindEntityViews(typeof(Datacenter), null, dcFilter, null);
                }
                foreach (EntityViewBase appDatacenter in appDatacenters)
                {
                    Datacenter thisDatacenter = (Datacenter)appDatacenter;
                    lstDatacenters.Add(thisDatacenter);
                }

                return lstDatacenters;
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
        }
Exemplo n.º 15
0
        public async Task <VmOptions> GetVmIsoOptions(string id)
        {
            VimClient host = FindHostByRandom();

            List <string> isos = new List <string>();

            string publicFolder = Guid.Empty.ToString();

            isos.AddRange(
                (await host.GetFiles(host.Options.IsoStore + id + "/*.iso", false))
                );
            isos.AddRange(
                (await host.GetFiles(host.Options.IsoStore + publicFolder + "/*.iso", false))
                );

            //translate actual path to display path
            isos = isos.Select(x => x.Replace(host.Options.IsoStore, "").Trim()).ToList();

            return(new VmOptions {
                Iso = isos.ToArray()
            });
        }
Exemplo n.º 16
0
        public async Task <int> VerifyDisks(VmTemplate template)
        {
            if (template.Disks.Length == 0)
            {
                return(100); //show good if no disks to verify
            }
            foreach (VimClient vhost in _hostCache.Values)
            {
                int progress = await vhost.TaskProgress(template.Id);

                if (progress >= 0)
                {
                    return(progress);
                }
            }

            // string pattern = @"blank-(\d+)([^\.]+)";
            // Match match = Regex.Match(template.Disks[0].Path, pattern);
            // if (match.Success)
            // {
            //     return 100; //show blank disk as created
            // }

            VimClient host = FindHostByRandom();

            NormalizeTemplate(template, host.Options);
            // if (template.Disks.Length > 0)
            // {
            _logger.LogDebug(template.Source + " " + template.Disks[0].Path);
            if (await host.FileExists(template.Disks[0].Path))
            {
                return(100);
            }
            // }
            return(-1);
        }
Exemplo n.º 17
0
 public HostDirectoryStore(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
 public HostAuthenticationStore(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
 public ClusterProfileManager(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
 public HostLocalAuthentication(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 21
0
        protected List<VirtualMachine> GetVirtualMachines(VimClient vimClient, Datacenter selectedDC = null, string vmName = null)
        {
            //
            // Get a list of virtual machines
            //
            List<VirtualMachine> lstVirtualMachines = new List<VirtualMachine>();
            NameValueCollection vmFilter = new NameValueCollection();
            ManagedObjectReference DcMoRef = new ManagedObjectReference();

            if (vmName != null)
            {
                //
                // A specific virtual machine
                //
                vmFilter.Add("name", vmName);
            }
            else
            {
                vmFilter = null;
            }

            if (selectedDC != null)
            {
                //
                // A specific datacenter
                //
                DcMoRef = selectedDC.MoRef;
            }
            else
            {
                DcMoRef = null;
            }
            try
            {
                //
                // If DcMoRef and vmFilter are null return all Vm's, otherwise return specific vm's
                //
                List<EntityViewBase> appVirtualMachines = vimClient.FindEntityViews(typeof(VirtualMachine), DcMoRef, vmFilter, null);
                if (appVirtualMachines != null)
                {
                    foreach (EntityViewBase appVirtualMachine in appVirtualMachines)
                    {
                        VirtualMachine thisVirtualMachine = (VirtualMachine)appVirtualMachine;
                        lstVirtualMachines.Add(thisVirtualMachine);
                    }
                    return lstVirtualMachines;
                }
                else
                {
                    return null;
                }
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
        }
Exemplo n.º 22
0
        protected List<Datastore> GetDataStore(VimClient vimClient, Datacenter selectedDC = null, string dsName = null)
        {
            //
            // Get a list of datastores from a specific datacenter
            //
            List<Datastore> lstDatastores = new List<Datastore>();
            NameValueCollection dsFilter = new NameValueCollection();
            ManagedObjectReference DcMoRef = new ManagedObjectReference();

            if (dsName != null)
            {
                //
                // The name of a specific datastore
                //
                dsFilter.Add("name", dsName);
            }
            else
            {
                dsFilter = null;
            }

            if (selectedDC != null)
            {
                //
                // A specific datacenter to get datastores from
                //
                DcMoRef = selectedDC.MoRef;
            }
            else
            {
                DcMoRef = null;
            }
            try
            {
                //
                // if DcMoref and dsFilter are empty return all datastores
                //
                List<EntityViewBase> appDatastores = vimClient.FindEntityViews(typeof(Datastore), DcMoRef, dsFilter, null);
                if (appDatastores != null)
                {
                    foreach (EntityViewBase appDatastore in appDatastores)
                    {
                        Datastore thisDatastore = (Datastore)appDatastore;
                        lstDatastores.Add(thisDatastore);
                    }
                    return lstDatastores;
                }
                else
                {
                    return null;
                }
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
        }
Exemplo n.º 23
0
 public VSphereClient(string serviceUrl, string userName, string password)
 {
     _client = new VimClient();
     _client.Connect(serviceUrl);
     _client.Login(userName, password);
 }
Exemplo n.º 24
0
 public ContainerView(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 25
0
 private VmWareClient()
 {
     _client = new VimClientImpl();
     // отключаем на время разработки
     ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
 }
Exemplo n.º 26
0
 protected VmwareDistributedVirtualSwitch GetDvSwitch(VimClient vimClient, ManagedObjectReference dvportGroupSwitch)
 {
     //
     // Get a specific distributed switch
     //
     try
     {
         //
         // Get the switch associated with the moref
         //
         ViewBase appSwitch = vimClient.GetView(dvportGroupSwitch, null);
         if (appSwitch != null)
         {
             VmwareDistributedVirtualSwitch thisDvSwitch = (VmwareDistributedVirtualSwitch)appSwitch;
             return thisDvSwitch;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }
Exemplo n.º 27
0
 protected List<ResourcePool> GetResPools(VimClient vimClient, string ClusterMoRefVal)
 {
     //
     // Get resource pools from a specific cluster
     //
     List<ResourcePool> lstResPools = new List<ResourcePool>();
     NameValueCollection clusterFilter = new NameValueCollection();
     clusterFilter.Add("parent", ClusterMoRefVal);
     try
     {
         List<EntityViewBase> arrResPools = vimClient.FindEntityViews(typeof(ResourcePool), null, clusterFilter, null);
         if (arrResPools != null)
         {
             foreach (EntityViewBase arrResPool in arrResPools)
             {
                 ResourcePool thisResPool = (ResourcePool)arrResPool;
                 lstResPools.Add(thisResPool);
             }
             return lstResPools;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }
Exemplo n.º 28
0
 protected List<CustomizationSpecInfo> GetCustomizationSpecs(VimClient vimClient)
 {
     //
     // Get a list of Customization Spec Info items
     //
     try
     {
         //
         // Get all Spec Info items
         //
         List<CustomizationSpecInfo> lstSpecInfo = new List<CustomizationSpecInfo>();
         CustomizationSpecManager specManager = (CustomizationSpecManager)vimClient.GetView(vimClient.ServiceContent.CustomizationSpecManager, null);
         if (specManager != null)
         {
             foreach (CustomizationSpecInfo specInfo in specManager.Info)
             {
                 lstSpecInfo.Add(specInfo);
             }
             return lstSpecInfo;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }
Exemplo n.º 29
0
        protected List<HostSystem> GetHosts(VimClient vimClient, string hostParent = null)
        {
            //
            // Get one or more virtual hosts
            //
            List<HostSystem> lstHosts = new List<HostSystem>();
            List<EntityViewBase> appHosts = new List<EntityViewBase>();
            try
            {
                if (hostParent == null)
                {
                    //
                    // Get all the hosts
                    //
                    appHosts = vimClient.FindEntityViews(typeof(HostSystem), null, null, null);
                }
                else
                {
                    //
                    // Get all the hosts in a cluster
                    //
                    NameValueCollection hostFilter = new NameValueCollection();
                    hostFilter.Add("parent", hostParent);

                    appHosts = vimClient.FindEntityViews(typeof(HostSystem), null, hostFilter, null);
                }
                if (appHosts != null)
                {
                    foreach (EntityViewBase appHost in appHosts)
                    {
                        HostSystem thisHost = (HostSystem)appHost;
                        lstHosts.Add(thisHost);
                    }
                    return lstHosts;
                }
                else
                {
                    return null;
                }
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
        }
Exemplo n.º 30
0
 protected List<ClusterComputeResource> GetClusters(VimClient vimClient, string clusterName = null)
 {
     //
     // Get one or more clusters
     //
     List<ClusterComputeResource> lstClusters = new List<ClusterComputeResource>();
     List<EntityViewBase> appClusters = new List<EntityViewBase>();
     try
     {
         if (clusterName == null)
         {
             //
             // Get all the clusters
             //
             appClusters = vimClient.FindEntityViews(typeof(ClusterComputeResource), null, null, null);
         }
         else
         {
             //
             // Get a specific cluster
             //
             NameValueCollection clusterFilter = new NameValueCollection();
             clusterFilter.Add("name", clusterName);
             appClusters = vimClient.FindEntityViews(typeof(ClusterComputeResource), null, clusterFilter, null);
         }
         if (appClusters != null)
         {
             foreach (EntityViewBase appCluster in appClusters)
             {
                 ClusterComputeResource thisCluster = (ClusterComputeResource)appCluster;
                 lstClusters.Add(thisCluster);
             }
             return lstClusters;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }
Exemplo n.º 31
0
 protected CustomizationSpecItem GetCustomizationSpecItem(VimClient vimClient, string specName = null)
 {
     //
     // Get one or more Customization Spec Items
     //
     try
     {
         //
         // Need a manager to collect the spec items
         //
         CustomizationSpecManager specManager = (CustomizationSpecManager)vimClient.GetView(vimClient.ServiceContent.CustomizationSpecManager, null);
         if (specManager != null)
         {
             CustomizationSpecItem itmCustomizationSpecItem = specManager.GetCustomizationSpec(specName);
             return itmCustomizationSpecItem;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }
 public ManagedObjectView(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
 public LocalizationManager(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 34
0
        protected List<Network> GetPortGroups(VimClient vimClient, Datacenter selectedDC = null, string pgName = null)
        {
            //
            // Get a list of Portgroups
            //
            List<Network> lstPortGroups = new List<Network>();
            NameValueCollection pgFilter = new NameValueCollection();
            ManagedObjectReference DcMoRef = new ManagedObjectReference();

            if (pgName != null)
            {
                //
                // Name of a specific portgroup
                //
                pgFilter.Add("name", pgName);
            }
            else
            {
                pgFilter = null;
            }

            if (selectedDC != null)
            {
                //
                // A specific datacenter
                //
                DcMoRef = selectedDC.MoRef;
            }
            else
            {
                DcMoRef = null;
            }
            try
            {
                //
                // If DcMoRef and pgFilter are null return all portgroups, otherwise return the selected portgroup
                //
                List<EntityViewBase> appPortGroups = vimClient.FindEntityViews(typeof(Network), DcMoRef, pgFilter, null);
                if (appPortGroups != null)
                {
                    foreach (EntityViewBase appPortGroup in appPortGroups)
                    {
                        Network thisPortGroup = (Network)appPortGroup;
                        lstPortGroups.Add(thisPortGroup);
                    }
                    return lstPortGroups;
                }
                else
                {
                    return null;
                }
            }
            catch (VimException ex)
            {
                //
                // VMware Exception occurred
                //
                txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
                Error_Panel.Visible = true;
                return null;
            }
        }
Exemplo n.º 35
0
 public GuestOperationsManager(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 36
0
 public VSphereClient(string serviceUrl, string userName, string password)
 {
     _client = new VimClient();
     _client.Connect(serviceUrl);
     _client.Login(userName, password);
 }
        public void ConnectToFarm()
        {
            VimClient virtualHost = new VimClient();
            virtualHost.Login(
                string.Format( "https://{0}/sdk", FarmUrl ),
                FarmLogin,
                FarmPassword );

            _vmWareVirtualMachine = ( VirtualMachine )virtualHost.FindEntityView(
                typeof( VirtualMachine ),
                null,
                new NameValueCollection
                    {
                        {"name", VirtualMachineName}
                    },
                null );
        }
 public MessageBusProxy(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 39
0
 public StoragePod(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
 public OpaqueNetwork(VimClient client, ManagedObjectReference moRef) : base(client, moRef)
 {
 }
Exemplo n.º 41
-1
 protected List<Datacenter> GetDcFromCluster(VimClient vimClient, string clusterParent)
 {
     //
     // Get a datacenter based on the cluster
     //
     List<Datacenter> lstDataCenters = new List<Datacenter>();
     NameValueCollection parentFilter = new NameValueCollection();
     parentFilter.Add("hostFolder", clusterParent);
     try
     {
         //
         // Get a specific datacenter based on parentFilter
         //
         List<EntityViewBase> arrDataCenters = vimClient.FindEntityViews(typeof(Datacenter), null, parentFilter, null);
         if (arrDataCenters != null)
         {
             foreach (EntityViewBase arrDatacenter in arrDataCenters)
             {
                 Datacenter thisDatacenter = (Datacenter)arrDatacenter;
                 lstDataCenters.Add(thisDatacenter);
             }
             return lstDataCenters;
         }
         else
         {
             return null;
         }
     }
     catch (VimException ex)
     {
         //
         // VMware Exception occurred
         //
         txtErrors.Text = "A server fault of type " + ex.MethodFault.GetType().Name + " with message '" + ex.Message + "' occured while performing requested operation.";
         Error_Panel.Visible = true;
         return null;
     }
 }