Esempio n. 1
0
 def create_port_pair(self, port_pair_info):
     # url = const.port_pair_url
     port_pair_info.update({
         "sdnControllerId":
         self.sdncontrollerid,
         "url":
         extsys.get_sdn_controller_by_id(self.sdncontrollerid)["url"]
     })
     return sdncdriver.create_port_pair(port_pair_info)
Esempio n. 2
0
 def init_data(self, flow_classifiers_model):
     fp_database_info = FPInstModel.objects.filter(fpinstid=self.fp_inst_id).get()
     self.sdnControllerId = fp_database_info.sdncontrollerid
     self.url = extsys.get_sdn_controller_by_id(self.sdnControllerId)["url"]
     self.dscp = flow_classifiers_model["criteria"]["dscp"]
     self.ip_proto = flow_classifiers_model["criteria"]["ip_protocol"]
     self.source_port_range = flow_classifiers_model["criteria"]["source_port_range"]
     self.dest_port_range = flow_classifiers_model["criteria"]["dest_port_range"]
     self.dest_ip_range = flow_classifiers_model["criteria"]["dest_ip_range"]
     self.source_ip_range = flow_classifiers_model["criteria"]["source_ip_range"]
Esempio n. 3
0
    def create_port_pair_and_group(self, port_pair_ids):
        # url = const.port_pair_group_url
        port_pair_group = {
            "sdnControllerId": self.sdncontrollerid,
            "url": extsys.get_sdn_controller_by_id(self.sdncontrollerid)["url"],
            "portPairs": port_pair_ids
        }
        port_pair_group_id = sdncdriver.create_port_pair_group(port_pair_group)
        port_pair_group_info = {
            "groupid": port_pair_group_id,
            "portpair": port_pair_ids}

        self.port_pair_group_db_infos.append(port_pair_group_info)
Esempio n. 4
0
    def create_sfc(self):
        data = {
            "sdnControllerId": self.sdnControllerId,
            "url": extsys.get_sdn_controller_by_id(self.sdnControllerId)["url"],
            "flowClassifiers": self.flow_classifier_ids,
            "portPairGroups": self.port_pair_groups_ids,
            "symmetric": self.symmetric
        }

        # url = "/api/sdncdriver/v1.0/createchain"
        # req_param = json.JSONEncoder.encoding(data)
        # ret = req_by_msb(url, "POST", req_param)
        # ret = req_by_msb("OPENAPI_CREATE_SERVICE_PORT_CHAIN",data)
        # if ret[0] > 0:
        #     logger.error('Send SFC Create request to Driver failed.')
        #     sfc_inst_failed_handle( "Send SFC Create request to Driver failed.")
        #     raise NSLCMException('Send SFC Create request to Driver failed.')
        # resp_body = json.loads(ret[1])
        # sfc_id = resp_body["id"]
        sfc_id = sdncdriver.create_port_chain(data)
        FPInstModel.objects.filter(fpinstid=self.fp_inst_id).update(sfcid=sfc_id)
Esempio n. 5
0
 def delete_sfc_from_driver(self, sfc_inst_info):
     sdn_controller_id = sfc_inst_info.sdncontrollerid
     sdn_controller_url = extsys.get_sdn_controller_by_id(
         sdn_controller_id)["url"]
     sfc_id = sfc_inst_info.sfcid
     flow_classifiers = sfc_inst_info.flowclassifiers
     port_pair_groups = sfc_inst_info.portpairgroups
     if sfc_id:
         req_param = {
             "sdnControllerId": sdn_controller_id,
             "url": sdn_controller_url,
             "id": sfc_id
         }
         sdncdriver.delete_port_chain(req_param)
     if flow_classifiers:
         for flow_id in flow_classifiers.split(","):
             req_param = {
                 "sdnControllerId": sdn_controller_id,
                 "url": sdn_controller_url,
                 "id": flow_id
             }
             sdncdriver.delete_flow_classifier(req_param)
     if port_pair_groups:
         for group in json.JSONDecoder().decode(port_pair_groups):
             group_id = group["groupid"]
             req_param = {
                 "sdnControllerId": sdn_controller_id,
                 "url": sdn_controller_url,
                 "id": group_id
             }
             sdncdriver.delete_port_pair_group(req_param)
             port_pair = group["portpair"]
             for port_pair_id in port_pair:
                 req_param = {
                     "sdnControllerId": sdn_controller_id,
                     "url": sdn_controller_url,
                     "id": port_pair_id
                 }
                 sdncdriver.delete_port_pair(req_param)