Пример #1
0
 def empty_approute_policy(self, policy_name, call_origin):
     policy_id = self.api_endpoint.get_approute_policy_id_by_name(
         policy_name)
     policy = self.api_endpoint.get_approute_policy_by_id(policy_id)
     payload = templates.create_empty_policy(policy)
     response = self.api_endpoint.put_approute_policy(
         policy_id, payload, call_origin)
Пример #2
0
    def delete_mapping(self, profile_name):
        self.check_config()
        self.test_connection()

        if profile_name in self.app_route_traffic_profiles.keys():

            #Delete endpoints from the policy
            policy_name = self.app_route_traffic_profiles[profile_name][
                'policyName']
            self.empty_approute_policy(policy_name, 'delete_mapping')

            # Regenerate merge policy
            self.create_approute_policy_with_all_endpoints()

            # Delete associated endpoints from internal variable
            self.delete_service_endpoint_by_profile(profile_name)

            # Delete traffic profile from internal variable
            del self.app_route_traffic_profiles[profile_name]

        elif profile_name in self.data_traffic_profiles.keys():

            #Delete endpoints from the policy
            policy_name = self.data_traffic_profiles[profile_name][
                'policyName']
            policy_id = self.api_endpoint.get_data_policy_id_by_name(
                policy_name)
            policy = self.api_endpoint.get_data_policy_by_id(policy_id)
            payload = templates.create_empty_policy(policy)
            response = self.api_endpoint.put_data_policy(
                policy_id, payload, 'delete_traffic_profile')
            #No active policies affected because these profiles are never active

            # Regenerate merge policy
            self.create_data_policy_with_all_endpoints()

            # Delete associated endpoints from internal variable
            self.delete_service_endpoint_by_profile(profile_name)

            # Delete traffic profile from internal variable
            del self.data_traffic_profiles[profile_name]

        else:
            logger.warning(err.CannotFindElement("delete_traffic_profile",\
                "This traffic profile does not exist, ignoring request."))