Commit be27d0cb authored by Mohammad Ismaeel's avatar Mohammad Ismaeel
Browse files

set service from serviceclient

parent 5c8fd581
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -44,15 +44,17 @@ def set_service () :
    service_json = request.json 
    service = ParseDict(service_json, Service())
    try : 
        context_client.connect()
        context_client.SetService(service)
        service_client.connect()
        service_id = service_client.CreateService(service)
        if service_id : 
            service_client.UpdateService(service)
        return make_response('Service Was Created Successfully !!' ,200)
    except Exception as e : 
        logging.info(f"error in creating service {e}") 
        return make_response(f'error !! {e}' ,400)  
    finally: 
        if context_client: 
            context_client.close()
        if service_client: 
            service_client.close()
            
@service.route('/create_service',methods= ['POST'])
def create_service (): 
@@ -90,13 +92,14 @@ def create_service ():
        return resonse
    
    else : 
        headers = {"Content-Type": "application/json"}
        url = ('http://{}:8008/service/set_service').format(host) 
        required_fields['bandwidth']=service_bandwidth
        required_fields['bidirectionality']=service_bi
        required_fields['port']=port
        service_json = service_builder(required_fields)
        
        response = requests.post(url,service_json)
        response = requests.post(url,json=service_json,headers=headers)
        
        if response.status_code == 200 : 
            return make_response('Service Created Successfully !!' , 200)
+2 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@
        <div class="col-12 my-2">
          <div class="row">

            <div class="col-12">
            <!-- <div class="col-12">
  
              <h5 style="font-weight: bold;">TAPI : </h5>
            </div>
@@ -32,7 +32,7 @@
                  
                     Connect To Remote 
              </a>
          </div>
          </div> -->
          </div>
        <div class="col-12 my-2">
          <h5 style="font-weight: bold;">Optical Configuration : </h5>