<commit_before>'#################################################################'
import base64
import functools
import re
import string
import time
import urllib



from traffic.compute import rpcapi as compute_rpcapi
from traffic.compute import tqdisc
from traffic.compute import tfilter

from traffic.db import base
from traffic import exception
from traffic import flags
from traffic.openstack.common import excutils
from traffic.openstack.common import importutils
from traffic.openstack.common import jsonutils
from traffic.openstack.common import log as logging
from traffic.openstack.common import timeutils
from traffic.openstack.common.gettextutils import _
from traffic import tqdisc
from traffic import tfilter
from traffic.scheduler import rpcapi as scheduler_rpcapi 
from traffic import utils
from traffic.openstack.common import cfg


class API(base.Base):
    
    def __init__(self, image_service=None, tqdisc_api=None, tfilter_api=None,
                     **kwargs):
        self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
        self.compute_rpcapi = compute_rpcapi.ComputeAPI()
        self.tqdisc_api = tqdisc_api or tqdisc.API()
        self.tfilter_api = tfilter_api or tfilter.API()
            
        super(API, self).__init__(**kwargs)

         
    def create(self, context, instance_id, band, prio):
#         compute_rpcapi.create_traffic(context, ip, instance_id, band, prio)
        #self.compute_rpcapi.create_traffic(context, ip, instance_id, band, prio)
        ip = self.get_ip_by_instance(context, instance_id)
        host = self.get_host_by_instance(context, instance_id)
        self.scheduler_rpcapi.create_traffic(context, ip, instance_id, band, host, prio)
        
    def show(self, context, instance_id):
        result = self.tqdisc_api.get_by_instance_id(context, instance_id)
        return result["band"]
    
    def list(self, context):
        result = self.tqdisc_api.get_all(context)
        return result
        
    def get_by_ip(self, context, ip):
        tfilter = self.tfilter_api.get_by_ip(context, ip)
        result = self.tqdisc_api.get_by_classid(context, tfilter["flow_id"])
        return result["band"]
        
    def delete(self, context, instance_id):
        result = self.tqdisc_api.get_by_instance_id(context, instance_id)
        self.tqdisc_api.delete(context, result["classid"])<commit_msg>change host ip<commit_after>'#################################################################'
import base64
import functools
import re
import string
import time
import urllib



from traffic.compute import rpcapi as compute_rpcapi
from traffic.compute import tqdisc
from traffic.compute import tfilter

from traffic.db import base
from traffic import exception
from traffic import flags
from traffic.openstack.common import excutils
from traffic.openstack.common import importutils
from traffic.openstack.common import jsonutils
from traffic.openstack.common import log as logging
from traffic.openstack.common import timeutils
from traffic.openstack.common.gettextutils import _
from traffic import tqdisc
from traffic import tfilter
from traffic.scheduler import rpcapi as scheduler_rpcapi 
from traffic import utils
from traffic.openstack.common import cfg


class API(base.Base):
    
    def __init__(self, image_service=None, tqdisc_api=None, tfilter_api=None,
                     **kwargs):
        self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
        self.compute_rpcapi = compute_rpcapi.ComputeAPI()
        self.tqdisc_api = tqdisc_api or tqdisc.API()
        self.tfilter_api = tfilter_api or tfilter.API()
            
        super(API, self).__init__(**kwargs)

         
    def create(self, context, instance_id, band, prio):
#         compute_rpcapi.create_traffic(context, ip, instance_id, band, prio)
        #self.compute_rpcapi.create_traffic(context, ip, instance_id, band, prio)
        ip = self.get_ip_by_instance(context, instance_id)
        host = self.get_host_by_instance(context, instance_id)
        self.scheduler_rpcapi.create_traffic(context, ip[0], instance_id, band, host[0], prio)
        
    def show(self, context, instance_id):
        result = self.tqdisc_api.get_by_instance_id(context, instance_id)
        return result["band"]
    
    def list(self, context):
        result = self.tqdisc_api.get_all(context)
        return result
        
    def get_by_ip(self, context, ip):
        tfilter = self.tfilter_api.get_by_ip(context, ip)
        result = self.tqdisc_api.get_by_classid(context, tfilter["flow_id"])
        return result["band"]
        
    def delete(self, context, instance_id):
        result = self.tqdisc_api.get_by_instance_id(context, instance_id)
        self.tqdisc_api.delete(context, result["classid"])
{'fraction_non_alphanumeric': 0.10387434554973822, 'fraction_numerical': 0.001256544502617801, 'mean_word_length': 3.7712287712287713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6307734', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1426, 'n_words': 347}