/// <summary> /// Test WmiCalls to which incoming HTTP POST requests are dispatched. /// /// TODO: revise beyond first approximation /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. /// A second approximation would use the AgentShell settings files directly. /// A third approximation would look to invoke ServerResource methods via an HTTP request /// </summary> public HypervResourceController1Test() { wmiCallsV2 = Substitute.For<IWmiCallsV2>(); //AgentService.ConfigServerResource(); HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; // Used to create existing StoragePool in preparation for the ModifyStoragePool testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); // Make sure secondary store is available. string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); s_logger.Info("Test secondary storage in " + fullPath); DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); if (!testSecondarStoreDir.Exists) { try { testSecondarStoreDir.Create(); } catch (System.IO.IOException ex) { throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); } } // Convert to secondary storage string to canonical path testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; // Make sure local primary storage is available DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); // Convert to local primary storage string to canonical path testLocalStorePath = testPoolDir.FullName; AgentSettings.Default.local_storage_path = testLocalStorePath; // Clean up old test files in local storage folder FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); // Capture other JSON encoded paths testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); // TODO: may need to initialise the server resource in future. // s_hypervresource.initialize(); // Verify sample template is in place storage pool s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON + " sample template at " + testSampleTemplateURLJSON); }
public static void Configure(HypervResourceControllerConfig config) { HypervResourceController.config = config; wmiCallsV2 = new WmiCallsV2(); }
/// <summary> /// Test WmiCalls to which incoming HTTP POST requests are dispatched. /// /// TODO: revise beyond first approximation /// First approximation is a quick port of the existing Java tests for Hyper-V server resource. /// A second approximation would use the AgentShell settings files directly. /// A third approximation would look to invoke ServerResource methods via an HTTP request /// </summary> public HypervResourceController1Test() { wmiCallsV2 = Substitute.For <IWmiCallsV2>(); //AgentService.ConfigServerResource(); HypervResourceController.config.PrivateMacAddress = AgentSettings.Default.private_mac_address; HypervResourceController.config.PrivateNetmask = AgentSettings.Default.private_ip_netmask; HypervResourceController.config.StorageIpAddress = HypervResourceController.config.PrivateIpAddress; HypervResourceController.config.StorageMacAddress = HypervResourceController.config.PrivateMacAddress; HypervResourceController.config.StorageNetmask = HypervResourceController.config.PrivateNetmask; // Used to create existing StoragePool in preparation for the ModifyStoragePool testLocalStoreUUID = AgentSettings.Default.local_storage_uuid.ToString(); // Make sure secondary store is available. string fullPath = Path.GetFullPath(testSecondaryStoreLocalPath); s_logger.Info("Test secondary storage in " + fullPath); DirectoryInfo testSecondarStoreDir = new DirectoryInfo(fullPath); if (!testSecondarStoreDir.Exists) { try { testSecondarStoreDir.Create(); } catch (System.IO.IOException ex) { throw new NotImplementedException("Need to be able to create the folder " + testSecondarStoreDir.FullName + " failed due to " + ex.Message); } } // Convert to secondary storage string to canonical path testSecondaryStoreLocalPath = testSecondarStoreDir.FullName; AgentSettings.Default.local_secondary_storage_path = testSecondaryStoreLocalPath; // Make sure local primary storage is available DirectoryInfo testPoolDir = new DirectoryInfo(testLocalStorePath); //Assert.True(testPoolDir.Exists, "To simulate local file system Storage Pool, you need folder at " + testPoolDir.FullName); // Convert to local primary storage string to canonical path testLocalStorePath = testPoolDir.FullName; AgentSettings.Default.local_storage_path = testLocalStorePath; // Clean up old test files in local storage folder FileInfo testVolWorks = new FileInfo(Path.Combine(testLocalStorePath, testSampleVolumeWorkingUUID)); // Assert.True(testVolWorks.Exists, "Create a working virtual disk at " + testVolWorks.FullName); testSampleTemplateURLJSON = JsonConvert.SerializeObject(testSampleTemplateUUID); s_logger.Info("Created " + testSampleTemplateURLJSON + " in local storage."); // Capture other JSON encoded paths testSampleVolumeWorkingURIJSON = Newtonsoft.Json.JsonConvert.SerializeObject(testVolWorks.FullName); testLocalStorePathJSON = JsonConvert.SerializeObject(testLocalStorePath); // TODO: may need to initialise the server resource in future. // s_hypervresource.initialize(); // Verify sample template is in place storage pool s_logger.Info("setUp complete, sample StoragePool at " + testLocalStorePathJSON + " sample template at " + testSampleTemplateURLJSON); }