public override void Run() { System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; Console.WriteLine("\n\n#### Example: Login to vCenter server with " + "external Platform Services Controller"); VapiAuthenticationHelper vapiAuthHelper = new VapiAuthenticationHelper(); SetupSslTrustForServer(); Console.WriteLine("\nStep 1: Connect to the lookup service on the " + "Platform Services Controller node."); LookupServiceHelper lookupServiceHelper = new LookupServiceHelper( LookupServiceUrl); Console.WriteLine("\nStep 2: Discover the Single Sign-On service " + "URL from lookup service."); String ssoUrl = lookupServiceHelper.FindSsoUrl(); Console.WriteLine("\nStep 3: Connect to the Single Sign-On URL and" + " retrieve the SAML bearer token."); SamlToken samlBearerToken = SsoHelper.GetSamlBearerToken(ssoUrl, UserName, Password); Console.WriteLine("\nStep 4. Login to vAPI services using the " + "SAML bearer token."); StubConfiguration sessionStubConfig = vapiAuthHelper.LoginBySamlBearerToken(Server, samlBearerToken); Console.WriteLine("\nStep 5: Perform certain tasks using the vAPI " + "services."); Console.WriteLine("\nListing all tags on the vCenter Server ..."); Tag taggingService = vapiAuthHelper.StubFactory.CreateStub <Tag>(sessionStubConfig); List <string> tagList = taggingService.List(); if (!tagList.Any()) { Console.WriteLine("\nNo tags found !"); } else { Console.WriteLine("\nTag Name\tTag Description"); foreach (string tagId in tagList) { Console.WriteLine( taggingService.Get(tagId).GetName() + "\t" + taggingService.Get(tagId).GetDescription()); } } vapiAuthHelper.Logout(); }
public override void Run() { System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; Console.WriteLine("\n\n#### Example: Login to vCenter server with " + "embedded Platform Services Controller"); VapiAuthenticationHelper vapiAuthHelper = new VapiAuthenticationHelper(); /* * Since the platform services controller is embedded, the sso * server is the same as the vcenter server. */ String ssoUrl = "https://" + Server + SSO_PATH; SetupSslTrustForServer(); Console.WriteLine("\nStep 1: Connect to the Single Sign-On URL " + "and retrieve the SAML bearer token."); SamlToken samlBearerToken = SsoHelper.GetSamlBearerToken(ssoUrl, UserName, Password); Console.WriteLine("\nStep 2. Login to vAPI services using the " + "SAML bearer token."); StubConfiguration sessionStubConfig = vapiAuthHelper.LoginBySamlBearerToken(Server, samlBearerToken); Console.WriteLine("\nStep 3: Perform certain tasks using the vAPI " + "services."); Console.WriteLine("\nListing all tags on the vCenter Server ..."); Tag taggingService = vapiAuthHelper.StubFactory.CreateStub <Tag>(sessionStubConfig); List <string> tagList = taggingService.List(); if (!tagList.Any()) { Console.WriteLine("\nNo tags found !"); } else { Console.WriteLine("\nTag Name\tTag Description"); foreach (string tagId in tagList) { Console.WriteLine( taggingService.Get(tagId).GetName() + "\t" + taggingService.Get(tagId).GetDescription()); } } vapiAuthHelper.Logout(); }
public override void Run() { System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; Console.WriteLine("\n\n#### Example: Login to vCenter server with " + "external Platform Services Controller"); VapiAuthenticationHelper vapiAuthHelper = new VapiAuthenticationHelper(); SetupSslTrustForServer(); Console.WriteLine("\nStep 1: Connect to the lookup service on the " + "Platform Services Controller node."); LookupServiceHelper lookupServiceHelper = new LookupServiceHelper( LookupServiceUrl); Console.WriteLine("\nStep 2: Discover the Single Sign-On service " + "URL from lookup service."); String ssoUrl = lookupServiceHelper.FindSsoUrl(); Console.WriteLine("\nStep 3: Connect to the Single Sign-On URL and" + " retrieve the SAML bearer token."); SamlToken samlBearerToken = SsoHelper.GetSamlBearerToken(ssoUrl, UserName, Password); Console.WriteLine("\nStep 4. Login to vAPI services using the " + "SAML bearer token."); StubConfiguration sessionStubConfig = vapiAuthHelper.LoginBySamlBearerToken(Server, samlBearerToken); Console.WriteLine("\nStep 5: Perform certain tasks using the vAPI " + "services."); Datacenter datacenterService = vapiAuthHelper.StubFactory.CreateStub <Datacenter>( sessionStubConfig); List <DatacenterTypes.Summary> dcList = datacenterService.List(new DatacenterTypes.FilterSpec()); Console.WriteLine("\nList of datacenters on the vcenter server:"); foreach (DatacenterTypes.Summary dcSummary in dcList) { Console.WriteLine(dcSummary); } vapiAuthHelper.Logout(); }
public override void Run() { System.Net.ServicePointManager.SecurityProtocol |= System.Net.SecurityProtocolType.Tls12; Console.WriteLine("\n\n#### Example: Login to vCenter server with " + "embedded Platform Services Controller"); VapiAuthenticationHelper vapiAuthHelper = new VapiAuthenticationHelper(); /* * Since the platform services controller is embedded, the sso * server is the same as the vcenter server. */ String ssoUrl = "https://" + Server + SSO_PATH; SetupSslTrustForServer(); Console.WriteLine("\nStep 1: Connect to the Single Sign-On URL " + "and retrieve the SAML bearer token."); SamlToken samlBearerToken = SsoHelper.GetSamlBearerToken(ssoUrl, UserName, Password); Console.WriteLine("\nStep 2. Login to vAPI services using the " + "SAML bearer token."); StubConfiguration sessionStubConfig = vapiAuthHelper.LoginBySamlBearerToken(Server, samlBearerToken); Console.WriteLine("\nStep 3: Perform certain tasks using the vAPI " + "services."); Datacenter datacenterService = vapiAuthHelper.StubFactory.CreateStub <Datacenter>( sessionStubConfig); List <DatacenterTypes.Summary> dcList = datacenterService.List(new DatacenterTypes.FilterSpec()); Console.WriteLine("\nList of datacenters on the vcenter server:"); foreach (DatacenterTypes.Summary dcSummary in dcList) { Console.WriteLine(dcSummary); } vapiAuthHelper.Logout(); }