def common_get_zones(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"zone": None, "node_zones": "test_node_zones"}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_zones(), "test_node_zones") agentpool_1 = self.create_initialized_agentpool_instance( availability_zones=["test_mc_zones1", "test_mc_zones2"] ) ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_zones(), ["test_mc_zones1", "test_mc_zones2"]) # custom value ctx_2 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"zones": "test_zones", "node_zones": "test_node_zones"}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_2.get_zones(), "test_zones")
def common_get_message_of_the_day(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"message_of_the_day": None}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_message_of_the_day(), None) agentpool_1 = self.create_initialized_agentpool_instance( message_of_the_day="test_message_of_the_day") ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_message_of_the_day(), "test_message_of_the_day") # custom ctx_2 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict( {"message_of_the_day": get_test_data_file_path("motd.txt")}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual( ctx_2.get_message_of_the_day(), "VU5BVVRIT1JJWkVEIEFDQ0VTUyBUTyBUSElTIERFVklDRSBJUyBQUk9ISUJJVEVECgpZb3UgbXVzdCBoYXZlIGV4cGxpY2l0LCBhdXRob3JpemVkIHBlcm1pc3Npb24gdG8gYWNjZXNzIG9yIGNvbmZpZ3VyZSB0aGlzIGRldmljZS4gVW5hdXRob3JpemVkIGF0dGVtcHRzIGFuZCBhY3Rpb25zIHRvIGFjY2VzcyBvciB1c2UgdGhpcyBzeXN0ZW0gbWF5IHJlc3VsdCBpbiBjaXZpbCBhbmQvb3IgY3JpbWluYWwgcGVuYWx0aWVzLiBBbGwgYWN0aXZpdGllcyBwZXJmb3JtZWQgb24gdGhpcyBkZXZpY2UgYXJlIGxvZ2dlZCBhbmQgbW9uaXRvcmVkLgo=", ) # custom ctx_3 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"message_of_the_day": "fake-path"}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) with self.assertRaises(InvalidArgumentValueError): ctx_3.get_message_of_the_day()
def init_context(self) -> None: """Initialize an AKSPreviewAgentPoolContext object to store the context in the process of assemble the AgentPool object. :return: None """ self.context = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict(self.__raw_parameters), self.models, DecoratorMode.UPDATE, self.agentpool_decorator_mode, )
def common_get_workload_runtime(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"workload_runtime": None}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_workload_runtime(), CONST_WORKLOAD_RUNTIME_OCI_CONTAINER) agentpool_1 = self.create_initialized_agentpool_instance(workload_runtime="test_workload_runtime") ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_workload_runtime(), "test_workload_runtime")
def common_get_gpu_instance_profile(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"gpu_instance_profile": None}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_gpu_instance_profile(), None) agentpool_1 = self.create_initialized_agentpool_instance(gpu_instance_profile="test_gpu_instance_profile") ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_gpu_instance_profile(), "test_gpu_instance_profile")
def common_get_enable_custom_ca_trust(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"enable_custom_ca_trust": True}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_enable_custom_ca_trust(), True) agentpool_1 = self.create_initialized_agentpool_instance(enable_custom_ca_trust=False) ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_enable_custom_ca_trust(), False) # custom ctx_2 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"enable_custom_ca_trust": True}), self.models, DecoratorMode.UPDATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_2.get_enable_custom_ca_trust(), True) agentpool_2 = self.create_initialized_agentpool_instance(enable_custom_ca_trust=False) ctx_2.attach_agentpool(agentpool_2) self.assertEqual(ctx_2.get_enable_custom_ca_trust(), True) # custom ctx_3 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"enable_custom_ca_trust": True, "disable_custom_ca_trust": True}), self.models, DecoratorMode.UPDATE, self.agentpool_decorator_mode, ) with self.assertRaises(MutuallyExclusiveArgumentError): ctx_3.get_enable_custom_ca_trust()
def common_get_crg_id(self): # default ctx_1 = AKSPreviewAgentPoolContext( self.cmd, AKSAgentPoolParamDict({"crg_id": None}), self.models, DecoratorMode.CREATE, self.agentpool_decorator_mode, ) self.assertEqual(ctx_1.get_crg_id(), None) agentpool_1 = self.create_initialized_agentpool_instance( capacity_reservation_group_id="test_capacity_reservation_group_id" ) ctx_1.attach_agentpool(agentpool_1) self.assertEqual(ctx_1.get_crg_id(), "test_capacity_reservation_group_id")