Beispiel #1
0
 /// <summary>
 /// Used to talk to and automate an ESXi environment
 /// </summary>
 /// <param name="hostName">The vCenter DNS hostname or IP-address it can be contacted by</param>
 /// <param name="userName">Username as part of needed credential for access</param>
 /// <param name="password">Password as part of needed credential for access</param>
 /// <param name="domain">Domain as part of needed credential for access</param>
 public vCenterCommunicator(String hostName, String userName, SecureString password, String domain)
 {
     lock (m_lock) {
         logWriter = new FileStream(Path.Combine(vCenterCommunicator.AssemblyDirectory, "VMWareChatter-CrashLogs.log"), FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
     }
     try {
         //Fetch information and collect them in a representative object:
         vConnection = vSphereClient.Connect("https://" + hostName + "/sdk");
         if (!String.IsNullOrEmpty(domain))
         {
             userName = domain + "\\" + userName;
         }
         thisSession  = vSphereClient.Login(userName, System.Runtime.InteropServices.Marshal.PtrToStringAuto(System.Runtime.InteropServices.Marshal.SecureStringToBSTR(password)));
         vimApiAccess = new VimApiAccess(vConnection);
         vimApiAccess.Connect("https://" + hostName + "/sdk", userName, System.Runtime.InteropServices.Marshal.PtrToStringAuto(System.Runtime.InteropServices.Marshal.SecureStringToBSTR(password)));
     }
     catch (Exception ex) {
         lock (m_lock) {
             WriteLogText(logWriter, "Error: " + ex.Message + ", after connecting with username: "******", host: " + hostName);
         }
         throw;
     }
     m_UserNameUsed = userName;
     m_PasswordUsed = password;
 }
Beispiel #2
0
        private LicenseManager GetLicenseManager()
        {
            LicenseManager licenseManager = null;

            try {
                VMware.Vim.ServiceContent _sic = GetServiceInctance().RetrieveServiceContent();
                licenseManager = (LicenseManager)vSphereClient.GetView(_sic.LicenseManager, null);
            } catch {
                throw;
            }
            return(licenseManager);
        }
Beispiel #3
0
        private AuthorizationManager GetAuthorizationManager()
        {
            AuthorizationManager authorizationManager = null;

            try {
                VMware.Vim.ServiceContent _sic = GetServiceInctance().RetrieveServiceContent();
                authorizationManager = (AuthorizationManager)vSphereClient.GetView(_sic.AuthorizationManager, null);
            }
            catch {
                throw;
            }
            return(authorizationManager);
        }
Beispiel #4
0
        private SessionManager GetSessionManager()
        {
            SessionManager sessionManager = null;

            try {
                VMware.Vim.ServiceContent _sic = GetServiceInctance().RetrieveServiceContent();
                sessionManager = (SessionManager)vSphereClient.GetView(_sic.SessionManager, null);
            }
            catch {
                throw;
            }
            return(sessionManager);
        }