def asgs_to_option(self, asgs): """ Returns the config option based on the names of the ASGs. """ asg_manager = AXUserASGManager(self._cluster_name_id, self._region) all_asg_names = asg_manager.get_all_asg_names() if asgs is None or len(asgs) == 0: return SpotInstanceOption.NO_SPOT elif set(asgs) == set(all_asg_names): return SpotInstanceOption.ALL_SPOT else: return SpotInstanceOption.PARTIAL_SPOT return
def option_to_asgs(self, option): """ Returns the names of the ASGs based on the provided config option. """ assert option in SpotInstanceOption.VALID_SPOT_INSTANCE_OPTIONS, \ "{} is not a valid spot instance option".format(option) asg_manager = AXUserASGManager(self._cluster_name_id, self._region) if option == SpotInstanceOption.ALL_SPOT: asg_names = asg_manager.get_all_asg_names() return asg_names elif option == SpotInstanceOption.NO_SPOT: return [] else: return [asg_manager.get_variable_asg()["AutoScalingGroupName"]] return