コード例 #1
0
ファイル: sync_enodeb.py プロジェクト: opencord/progran
    def sync_record(self, o):
        log.info("sync'ing enodeb", object=str(o), **o.tologdict())

        onos = ProgranHelpers.get_progran_onos_info(self.model_accessor)

        enodeb_url = "http://%s:%s/onos/progran/enodeb/" % (onos['url'],
                                                            onos['port'])
        data = self.get_progran_enodeb_field(o)
        log.debug("Sync'ing enodeb with data", request_data=data)

        if o.previously_sync == False:
            log.debug("Sending POST", url=enodeb_url, data=json.dumps(data))
            r = requests.post(enodeb_url,
                              data=json.dumps(data),
                              auth=HTTPBasicAuth(onos['username'],
                                                 onos['password']))
        else:
            data = {"EnodeB": data}
            log.debug("Sending PUT", url=enodeb_url, data=json.dumps(data))
            r = requests.put(enodeb_url,
                             data=json.dumps(data),
                             auth=HTTPBasicAuth(onos['username'],
                                                onos['password']))

        ProgranHelpers.get_progran_rest_errors(r)
        log.info("Enodeb synchronized", response=r.json())

        o.previously_sync = True
        o.save()
コード例 #2
0
    def sync_record(self, o):
        log.info("sync'ing imsi", object=str(o), **o.tologdict())
        onos = ProgranHelpers.get_progran_onos_info()
        imsi_url = "http://%s:%s/onos/progran/imsi/" % (onos['url'], onos['port'])
        data = self.get_progran_imsi_field(o)
        r = requests.post(imsi_url, data=json.dumps(data), auth=HTTPBasicAuth(onos['username'], onos['password']))

        ProgranHelpers.get_progran_rest_errors(r)
        log.info("Profile synchronized", response=r.json())
コード例 #3
0
ファイル: sync_enodeb.py プロジェクト: opencord/progran
 def delete_record(self, o):
     log.info("deleting enodeb", object=str(o), **o.tologdict())
     onos = ProgranHelpers.get_progran_onos_info(self.model_accessor)
     enode_url = "http://%s:%s/onos/progran/enodeb/%s" % (
         onos['url'], onos['port'], o.enbId)
     r = requests.delete(enode_url,
                         auth=HTTPBasicAuth(onos['username'],
                                            onos['password']))
     ProgranHelpers.get_progran_rest_errors(r)
     log.info("enodeb deleted", response=r.json())
コード例 #4
0
ファイル: sync_imsi_link.py プロジェクト: opencord/progran
    def delete_record(self, o):

        if o.provider_service_instance.leaf_model_name == "ProgranServiceInstance" and o.subscriber_service_instance.leaf_model_name ==  "MCordSubscriberInstance":
            log.info("deleting link", object=str(o), **o.tologdict())

            onos = ProgranHelpers.get_progran_onos_info(self.model_accessor)

            profile_name = o.provider_service_instance.name
            imsi_number =  o.subscriber_service_instance.leaf_model.imsi_number

            url = "http://%s:%s/onos/progran/profile/%s/%s" % (onos['url'], onos['port'], profile_name, imsi_number)

            r = requests.delete(url, auth=HTTPBasicAuth(onos['username'], onos['password']))
            ProgranHelpers.get_progran_rest_errors(r)
コード例 #5
0
ファイル: sync_imsi_link.py プロジェクト: opencord/progran
    def sync_record(self, o):

        if o.provider_service_instance.leaf_model_name == "ProgranServiceInstance" and o.subscriber_service_instance.leaf_model_name ==  "MCordSubscriberInstance":
            log.info("sync'ing link", object=str(o), **o.tologdict())

            onos = ProgranHelpers.get_progran_onos_info(self.model_accessor)

            profile_name = o.provider_service_instance.name
            imsi_number =  o.subscriber_service_instance.leaf_model.imsi_number

            data = {
                "IMSIRuleArray": [
                    imsi_number
                ]
            }

            url = "http://%s:%s/onos/progran/profile/%s/imsi" % (onos['url'], onos['port'], profile_name)

            r = requests.post(url, data=json.dumps(data), auth=HTTPBasicAuth(onos['username'], onos['password']))
            ProgranHelpers.get_progran_rest_errors(r)
コード例 #6
0
    def sync_record(self, o):
        onos = ProgranHelpers.get_progran_onos_info()

        log.info("sync'ing profile", object=str(o), **o.tologdict())

        profile_url = "http://%s:%s/onos/progran/profile/" % (onos['url'],
                                                              onos['port'])
        data = self.get_progran_profile_field(o)
        log.debug("Sync'ing profile with data", request_data=data)

        if o.previously_sync == False:
            log.debug("Sending POST", url=profile_url, data=json.dumps(data))
            r = requests.post(profile_url,
                              data=json.dumps(data),
                              auth=HTTPBasicAuth(onos['username'],
                                                 onos['password']))
        else:
            log.debug("Sending PUT", url=profile_url, data=json.dumps(data))
            r = requests.put(profile_url,
                             data=json.dumps(data),
                             auth=HTTPBasicAuth(onos['username'],
                                                onos['password']))

        ProgranHelpers.get_progran_rest_errors(r)
        log.info("Profile synchronized", response=r.json())

        if o.enodeb_id:
            log.info("adding profile %s to enodeb %s" % (o.id, o.enodeb.enbId),
                     object=str(o),
                     **o.tologdict())
            enodeb_url = "http://%s:%s/onos/progran/enodeb/%s/profile" % (
                onos['url'], onos['port'], o.enodeb.enbId)
            data = {"ProfileArray": [o.name]}
            log.debug("Adding enodeb to profile with data", request_data=data)
            r = requests.post(enodeb_url,
                              data=json.dumps(data),
                              auth=HTTPBasicAuth(onos['username'],
                                                 onos['password']))
            ProgranHelpers.get_progran_rest_errors(r)
            o.active_enodeb_id = o.enodeb_id  # storing the value to know when it will be deleted
            log.info("EnodeB synchronized", response=r.json())
        elif o.active_enodeb_id:
            enb_id = ENodeB.objects.get(id=o.active_enodeb_id).enbId
            log.info("removing profile %s from enodeb %s" %
                     (o.name, o.active_enodeb_id),
                     object=str(o),
                     **o.tologdict())
            enodeb_url = "http://%s:%s/onos/progran/enodeb/%s/profile/%s" % (
                onos['url'], onos['port'], enb_id, o.name)
            r = requests.delete(enodeb_url,
                                auth=HTTPBasicAuth(onos['username'],
                                                   onos['password']))
            ProgranHelpers.get_progran_rest_errors(r)
            o.active_enodeb_id = 0  # removing the value because it has been deleted
            log.info("EnodeB synchronized", response=r.json())

        o.previously_sync = True
        o.no_sync = True
        o.save()