Cisco Active Network Abstraction Network Service Activation 1.0 Customization Guide, 3.7
Activation Scripts to Configure E-Line Service
ErrorMessage : Didn't tag either concept or doctype for selected page

null
Downloads: This chapterpdf (PDF - 181.0KB) The complete bookPDF (PDF - 3.55MB) | Feedback

Activation Scripts to Configure E-Line Service

Table Of Contents

Activation Scripts to Configure E-Line Service

Configure E-Line

Add Service Instance to Interface

Add xConnect to Service Instance

Activate Interface

Remove Service Instance from Interface

Remove xConnect from Service Instance


Activation Scripts to Configure E-Line Service


This appendix contains the complete text of the activation scripts called to configure an E-Line service:

Configure E-Line

Add Service Instance to Interface

Add xConnect to Service Instance

Activate Interface

Remove Service Instance from Interface

Remove xConnect from Service Instance

Configure E-Line

/******* Script to configure e-line *******/


// sourcing the utility files
String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"add_service_instance_to_interface.bsh");
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"add_xconnect_to_serviceInstance.bsh");
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"remove_service_instance_from_interface.bsh");
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"activate_interface.bsh");
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"remove_xconnect_from_serviceInstance.bsh");

/*
 * This function is called by the configure_eline function when it encounters
 * error condifiton and rollback is needed. It passes this function information
 * about where it failed through 'failureLevel' parameter and the rollback
 * function would handle rollback accordingly by calling the appropriate utility
 * scripts
 */
void rollback(String  interfaceName,Integer intServiceInstanceId, String failureLevel)
{
            // Function entry message
		telnetInterface.println ("Inside rollback_configure_eline...");
		
             // convert type to string
		 String strServiceInstanceId = "";
             if (intServiceInstanceId!= null) 
                     strServiceInstanceId = String.valueOf(intServiceInstanceId);

		if (failureLevel =="xconnect") 
		{
		      // invoking utility script to remove service instance from
				// interface
       	     remove_service_instance_from_interface(interfaceName,strServiceInstanceId);
		} 		
		else if(failureLevel == "activate-interface")
		{
			// invoking utility scripts to remove xconnect and service instance
			// from interface
                  
remove_xconnect_from_serviceInstance(interfaceName,strServiceInstanceId);
			remove_service_instance_from_interface(interfaceName,strServiceInstanceId);
		}

            // Set the appropriate status for this function
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
            // Function exit message
 		telnetInterface.println ("rollback_configure_eline done");
		sendResult(false, "The script --configure_eline --failed");

     
}

/*
 * This function configures flex uni eline command set on the box. If it
 * encounters error condition, it would invoke rollback such that any cli pushed
 * to the router by this function is removed. The various actions taken by this
 * function include, 
 * a) Convert the input parametrs to data types as needed 
 * b) Check that all the manadatory parameters are entered, if not return error. 
 * c) Check for range and syntax on parameter values 
 * d) Check for existence ofobjects against the router if needed 
 * e) Invoke utility scripts and handle errors 
 * f) Invoke rollback if needed
 */
boolean configure_eline(String interfaceName,Integer intServiceInstanceId,String 
outerVlanTag,String  innerVlanTag,String rewritePopAction,Integer 
intPushOuterVlanTag,Integer intPushInnerVlanTag,Integer intTranslateVlanTag,String 
peerDeviceIp,Integer intTunnelId,String activateInterface)
{


	telnetInterface.println("Inside Configure E-Line...");

	// typecasting the necessary inputs to string
	String strPushOuterVlanTag = "";
             if (intPushOuterVlanTag != null) 
                     strPushOuterVlanTag  = String.valueOf(intPushOuterVlanTag);

            String strPushInnerVlanTag = "";
             if (intPushInnerVlanTag!= null) 
                     strPushInnerVlanTag = String.valueOf(intPushInnerVlanTag);

            String strTranslateVlanTag = "";
             if (intTranslateVlanTag!= null) 
                     strTranslateVlanTag = String.valueOf(intTranslateVlanTag);

            String strServiceInstanceId = "";
             if (intServiceInstanceId!= null) 
                     strServiceInstanceId = String.valueOf(intServiceInstanceId);

            String strTunnelId = "";
             if (intTunnelId!= null) 
                     strTunnelId = String.valueOf(intTunnelId);

	
	// handling 'rewritePopAction' combo input
	String strRewritePopAction="";
	if(rewritePopAction.equals("none"))
	 {
		strRewritePopAction=empty;
	 }
	else if(rewritePopAction.equals("1"))
	 {
  	      strRewritePopAction="1";
       }
	else if(rewritePopAction.equals("2"))
	 {
		strRewritePopAction="2";
	 }

	// handling 'activateInterface' combo input
	String strActivateInterface="";
	if(activateInterface.equals("true"))
	 {
		strActivateInterface="true";
	 }
	else if(activateInterface.equals("false"))
	 {
		strActivateInterface="false";
	 }

      // Check for manadatory parameters
		
	// checking if mandatory input interface name is left blank
	if(!checkBlank(interfaceName,"Interface Name"))
	  {
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		sendResult(false, "The script --configure_eline -- failed");
		return false;
	  }
		
	// checking if mandatory input service instance is left blank
	if(!checkBlank(strServiceInstanceId,"Service Instance ID"))
        {
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		sendResult(false, "The script --configure_eline-- failed");
		return false;
        }

	// checking if mandatory input peer device ip is left blank
	if(!checkBlank(peerDeviceIp,"Peer Device IP"))
        {
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		sendResult(false, "The script --configure_eline-- failed");
		return false;
         }

	// checking if mandatory input tunnel id is left blank
	if(!checkBlank(strTunnelId,"Tunnel ID"))
  	   {
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		sendResult(false, "The script --configure_eline-- failed");
		return false;
	   }

	// invoke the utility script to add serivice instance. This script verifies the input 
parameters locally as well
      // as against the router before configuring service instance. If there is an error, 
returns false.
	if(!add_service_instance_to_interface(interfaceName,strServiceInstanceId 
,outerVlanTag,innerVlanTag,strRewritePopAction,strPushOuterVlanTag,strPushInnerVlanTag,str
TranslateVlanTag))
	{
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		sendResult(false, "The script --configure_eline-- failed");
		return false;
	}

	// invoke the utility script to add xconnect on the serivice instance. This script 
verifies the input parameters locally as well
      // as against the router before configuring xconnect on service instance. If there 
is an error, returns false.
      // If there is an error configuring xconnect, rollback is called to remove the 
configured service instance.
	
if(!add_xconnect_to_serviceInstance(interfaceName,strServiceInstanceId,outerVlanTag,innerV
lanTag,peerDeviceIp,strTunnelId))
	{
		rollback(interfaceName,intServiceInstanceId,"xconnect");
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
       	return false;
	}


	// Activate the interface if needed.
	if(strActivateInterface.equals("true"))
	{
		if(!activate_interface(interfaceName))
		{
		  telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		  rollback(interfaceName,intServiceInstanceId,"activate-interface");
		  return false;
		}
	}
	
	// Success!! Print success message and exit.
	sendResult(true, "The script configure_eline was executed successfully");
	telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
   	return true;


}

// Get the input parameters from ANA
Integer intServiceInstanceId =  (Integer)scriptEnvInterface.getParam("serviceInstanceId");
Integer intPushOuterVlanTag=  (Integer)scriptEnvInterface.getParam("pushOuterVlanTag");
Integer intPushInnerVlanTag =  (Integer)scriptEnvInterface.getParam("pushInnerVlanTag");
Integer intTranslateVlanTag =  (Integer)scriptEnvInterface.getParam("translateVlanTag");
Integer intTunnelId =  (Integer)scriptEnvInterface.getParam("tunnelId");
String rewritePopAction =  (String)scriptEnvInterface.getParam("rewritePopAction");
String activateInterface =  (String)scriptEnvInterface.getParam("activateInterface");

// Invoke the configure_eline function
boolean result = configure_eline(interfaceName,intServiceInstanceId 
,outerVlanTag,innerVlanTag,rewritePopAction,intPushOuterVlanTag,intPushInnerVlanTag,intTra
nslateVlanTag,peerDeviceIp,intTunnelId,activateInterface);

Add Service Instance to Interface

import java.io.File;

/* The script adds a service instance on a particular interface.
 * In case of error conditions rollback is called and any configuration
 * sent is removed from the device
 */

// Utilities load
String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");

/* This function does the rollback based on where the configuration failed.
*/
void rollback_addServiceInstance_interface(String interfaceName,String 
serviceInstanceId,String failureLevel){

	telnetInterface.println ("In rollback_add_service_instance_to_interface...");

      if (failureLevel =="vlan") {
       // already at (config-if-srv)
       config("no service instance " + serviceInstanceId);
       config("exit");
       config("exit");
     
      } 
      else if ((failureLevel =="rewrite")) {
       config("no service instance " + serviceInstanceId);
       config("exit");
       config("exit");
    }

    telnetInterface.println ("rollback_addServiceInstance done");
}

/* This function adds a service instance on an interface. Rollback is called if there are 
errors.
*/
boolean add_service_instance_to_interface(String interfaceName,String 
serviceInstanceId,String outerVlanTag,String innerVlanTag,String rewritePopAction,String 
pushOuterVlanTag,String pushInnerVlanTag,String translateVlanTag){
    
	   telnetInterface.println("Inside Add Service Instance to Interface!!");

      // check that the interface exists in the device
      if (!checkInterface(interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	    return false;
      }

      // checks whether serviceInstanceId is a number
	  if(!checkNumber(serviceInstanceId,"ServiceInstanceId"))
	    {
		 telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	       return false;
        }

      //Check that the serviceInstanceId is in the valid range
	  if 
(!checkRange(serviceInstanceId,SERVICE_INSTANCE_ID_MIN,SERVICE_INSTANCE_ID_MAX,"service 
Instance Id")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
      }

	// check that this service instance is not already configured on this interface in the 
device.
      if (checkIfServiceInstanceExists(serviceInstanceId , interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    sendResult(false, "The Service Instance " + serviceInstanceId + " already exists 
on interface " + interfaceName );
	    return false;
      }


       //check for outerVlanTag 
  	if(!outerVlanTag.equals(empty) && innerVlanTag.equals(empty)){
		if(firstCharCheck(outerVlanTag)){
		    if (!validateVLAN(outerVlanTag)){  
	    			telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	     			sendResult(false, "outerVlanTag is not in the right range");
	    			return false;
                 }
	          if(!checkIfEncapsulationExists(outerVlanTag,interfaceName)){
				telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
				sendResult(false,"outerVlanTag "+outerVlanTag+" already configured under 
other service instance");
				return false;
		   }

	  }
	else{
		if (!checkInput(outerVlanTag,"any,default,untagged")){  
	    		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	     		sendResult(false, "outerVlanTag has invalid input");
	    		return false;
		   }
	    }

	}
    
	 
	  //check for optional parameter innerVlanTag
	if(!innerVlanTag.equals(empty)){
	     if (!validateVLAN(innerVlanTag)){  
	       telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	       sendResult(false, "innerVlanTag is not in the right range");
	       return false;
        }  
      }

	  //check for optional parameter rewritePopAction
	  if(!rewritePopAction.equals(empty)){
		  //to check whether only the allowed value is inputted
              // (1,2) is the comma separated reference string 
		  //against which rewritePopAction value needs to be checked
		  if(!checkInput(rewritePopAction,"1,2")){
			  telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
			  sendResult(false, "Rewrite Pop Action has invalid input value");
	              return false;
               }
	  }

	  //check for optional parameter pushOuterVlanTag
	  if(!pushOuterVlanTag.equals(empty)){
	    if (!checkRange(pushOuterVlanTag,VLAN_MIN,VLAN_MAX,"pushOuterVlanTag")){ 
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
	  }
      }
      
       //check for optional parameter pushInnerVlanTag
	 if(!pushInnerVlanTag.equals(empty)){
	   if (!checkRange(pushInnerVlanTag,VLAN_MIN,VLAN_MAX,"pushInnerVlanTag")){ 
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
	  }
      }

      //check for optional parameter translateVlanTag
      if(!translateVlanTag.equals(empty)){
	  if (!checkRange(translateVlanTag,VLAN_MIN,VLAN_MAX,"translateVlanTag")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
	  }
	}

      // now send configurations down
	  if(!config("conf t")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      if(!config("int " + interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      if(!config("service instance " + serviceInstanceId + " e")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    telnetInterface.config("#","end");
	    return false;
       }
  
  // If outerVlanTag and innerVlanTag are empty
      if(outerVlanTag.equals(empty) && innerVlanTag.equals(empty)){
		if(!config("encapsulation dot1q any")){
         	 // call rollback_addServiceInstance here
	   	 telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
        	 rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, "vlan");
	  	 return false;
      	 }
	  }

  // If outerVlanTag is not empty and innerVlanTag is empty
       if(!outerVlanTag.equals(empty) && innerVlanTag.equals(empty)){

		  //If outerVlanTag is either default or untagged and innerVlanTag is empty
        if(outerVlanTag.equals("default")){
		  if(!config("encapsulation default")){
   		       // call rollback_addServiceInstance here
		      telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	            rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, 
"vlan" );
	            return false;
		  }
       }
    else if(outerVlanTag.equals("untagged")){
		  if(!config("encapsulation untagged")){
          // call rollback_addServiceInstance here
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, "vlan" 
);
	    return false;
		  }
       }
    else{
      if(!config("encapsulation dot1q " + outerVlanTag)){
          // call rollback_addServiceInstance here
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, "vlan" 
);
	    return false;
          }
	  }
	}


  // If outerVlanTag and innerVlanTag both are not empty
  	  if(!outerVlanTag.equals(empty) && !innerVlanTag.equals(empty)){
	  	  if(!config("encapsulation dot1q " + outerVlanTag+ " second-dot1q 
"+innerVlanTag)){
          		// call rollback_addServiceInstance here
	    		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          		rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, "vlan" 
);
	    		return false;
		  }
       	}
  
   // rewritePopAction is not empty
        if(!rewritePopAction.equals(empty)&& pushOuterVlanTag.equals(empty) && 
pushInnerVlanTag.equals(empty) && translateVlanTag.equals(empty)){
	     if(!config("rewrite ingress tag pop "+rewritePopAction+" symmetric")){
			telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          		rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, 
"rewrite" );
	    		return false;
		}
    	   }
   // rewritePopAction is empty pushOuterVlanTag is not empty and pushInnerVlanTag is 
empty and translateVlanTag empty
      else if(rewritePopAction.equals(empty) && !pushOuterVlanTag.equals(empty) && 
pushInnerVlanTag.equals(empty) && translateVlanTag.equals(empty)){
         if(!config("rewrite ingress tag push dot1q "+pushOuterVlanTag+" symmetric")){
           telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
           rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, 
"rewrite" );
	     return false;
	}
    }

   // rewritePopAction is empty pushOuterVlanTag is not empty and pushInnerVlanTag is not 
empty and translateVlanTag empty
    else if(rewritePopAction.equals(empty) && !pushOuterVlanTag.equals(empty) && 
!pushInnerVlanTag.equals(empty) && translateVlanTag.equals(empty)){
	  if(!config("rewrite ingress tag push dot1q "+pushOuterVlanTag+" second-dot1q 
"+pushInnerVlanTag+" symmetric")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, 
"rewrite" );
	    return false;
	}
    }

   // rewritePopAction, pushOuterVlanTag and pushInnerVlanTag are empty and 
translateVlanTag not empty
    else if(rewritePopAction.equals(empty) && pushOuterVlanTag.equals(empty) && 
pushInnerVlanTag.equals(empty) && !translateVlanTag.equals(empty)){
    	if(!config("rewrite ingress tag translate 1-to-1 dot1q "+translateVlanTag+" 
symmetric")){
		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          	rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, 
"rewrite" );
	    	return false;
	}
    }

   // rewritePopAction, pushOuterVlanTag and pushInnerVlanTag and translateVlanTag are 
empty
   else if(rewritePopAction.equals(empty) && pushOuterVlanTag.equals(empty) && 
pushInnerVlanTag.equals(empty) && translateVlanTag.equals(empty)){
	sendResult(true, "The script ---add_service_instance_interface--- was executed 
successfully");
      telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
      telnetInterface.config("#","end");
      return true;
}

   // Invalid option
   else{
	sendResult(false,"Invalid set of input paramenters");
      telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
      rollback_addServiceInstance_interface(interfaceName, serviceInstanceId, "vlan" );
	return false;
    }
  
   if(!config("end")){
     	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          return false;
       }

    // Success
    sendResult(true, "The script ---add_service_instance_interface--- was executed 
successfully");
    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
    return true;
}

Add xConnect to Service Instance

import java.io.File;

/* The script adds xconnect on a service instance.
*/

String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");


/* The function handles adding of xconnect on service instance
*/
boolean add_xconnect_to_serviceInstance(String interfaceName,String 
serviceInstanceId,String outerVlanTag,String innerVlanTag,String peerDeviceIp,String 
tunnelId){

      telnetInterface.println("Inside add xconnect to service instance!!");
       
	// validate that the interface exists in the device
      if (!checkInterface(interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	    return false;
      }

      //checks whether serviceInstanceId is a number
	  if(!checkNumber(serviceInstanceId,"ServiceInstanceId"))
	    {
		 telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	         return false;
        }

       //Check range for serviceInstanceId (1 to 8000)
	  if 
(!checkRange(serviceInstanceId,SERVICE_INSTANCE_ID_MIN,SERVICE_INSTANCE_ID_MAX,"service 
Instance Id")){ 
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
      }

	  // check that the service instance id is configured on the interface
      if (!checkIfServiceInstanceExists(serviceInstanceId , interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    sendResult(false, "The Service Instance " + serviceInstanceId + " does not exist 
on interface " + interfaceName );
	    return false;
      }

    
       // check for loopback address
      if (!checkIP(peerDeviceIp,"peerDeviceIp")){ 
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
      }
      
      // now send configurations down
	  if(!config("conf t")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

      if(!config("int "+interfaceName )){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

     if(!config("service instance " +serviceInstanceId + " e")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

     //If outerVlanTag and innerVlanTag are empty
    if(outerVlanTag.equals(empty) && innerVlanTag.equals(empty)){
		if(!config("encapsulation dot1q any")){
          		telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          		return false;
       }
	}

    // If outerVlanTag is not empty and innerVlanTag is empty
    if(!outerVlanTag.equals(empty) && innerVlanTag.equals(empty)){
      //outerVlanTag is either default or untagged and innerVlanTag is empty
      if(outerVlanTag.equals("default")){
		  if(!config("encapsulation default")){
            	telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
            	return false;
		  }
       }

    else if(outerVlanTag.equals("untagged")){
	  if(!config("encapsulation untagged")){
            telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
            return false;
		  }
       }

    else{
      if(!config("encapsulation dot1q " + outerVlanTag)){
          telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
           return false;
       }
     }
  }


  //If outerVlanTag and innerVlanTag both are not empty
	  if(!outerVlanTag.equals(empty) && !innerVlanTag.equals(empty)){
	  	  if(!config("encapsulation dot1q " + outerVlanTag+ " second-dot1q 
"+innerVlanTag)){
	            telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
 	            return false;
		  }
       }
    
	if(!config("xconnect "+peerDeviceIp+" "+tunnelId+" encapsulation mpls")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    telnetInterface.config("#","end");
	    return false;
       }
  

    if(!config("end")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
		return false;
		}

    // Success
    sendResult(true, "The script ---add_xconnect_to_serviceInstance--- was executed 
successfully");
    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
    return true;
}

Activate Interface

import java.io.File;


/********* Script to activate a given interface************/

// Utilities load
String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");

boolean activate_interface(String interfaceName)
{
	telnetInterface.println("Inside Activate Interface!!");

      // validate that the interface exists in the device
      if (!checkInterface(interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	    return false;
      }

      // now send configurations down
      if(!config("conf t")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      if(!config("int " + interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

        if(!config("no shut")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          return false;
       }

      if(!config("exit")){
          // call rollback here
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
             return false;
       }

      if(!config("exit")){
             telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
             return false;
       }

   // Success
    sendResult(true, "The script for activate-interface was executed successfully");
    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
    return true;


}

Remove Service Instance from Interface

import java.io.File;

/* The script removes a service instance from a given interface 
*/

String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");


boolean remove_service_instance_from_interface(String interfaceName,String 
serviceInstanceId){

      telnetInterface.println("Inside Remove Service Instance from Interface!!");

      // check whether the interface exists on the device
      if (!checkInterface(interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	    return false;
      }

      // check whether serviceInstanceId is a number
	if(!checkNumber(serviceInstanceId,"ServiceInstanceId"))
	    {
		 telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	         return false;
        }

      //Check range for serviceInstance_ID
	if 
(!checkRange(serviceInstanceId,SERVICE_INSTANCE_ID_MIN,SERVICE_INSTANCE_ID_MAX,"service 
Instance Id")){ 
            telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
      }

	// check that the service instance exists on the interface in the device
      if (!checkIfServiceInstanceExists(serviceInstanceId , interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    sendResult(false, "The Service Instance " + serviceInstanceId + " does not exist 
on interface " + interfaceName );
	    return false;
      }


      // now send configurations down
      if(!config("conf t")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      if(!config("int " + interfaceName )){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      if(!config("no service instance " + serviceInstanceId + " e")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

      if(!config("exit")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          return false;
	}

      if(!config("exit")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
          return false;
	}

    // Success
    sendResult(true, "The script ---remove_service_instance_interface--- was executed 
successfully");
    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
    return true;
	}

Remove xConnect from Service Instance

import java.io.File;

/* The script removes xconnect from a service instance
 */

String sep = File.separator;
source("." + sep + "scripts" + sep + "configuration" + sep + "cisco" + sep + 
"CarrierEProvUtil.bsh");

boolean remove_xconnect_from_serviceInstance(String interfaceName,String 
serviceInstanceId){

      telnetInterface.println("Inside Remove xconnect from Service Instance!!");

	// validate that the interface exists in the device
      if (!checkInterface(interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	    return false;
      }

      //checks whether serviceInstanceId is a number
	if(!checkNumber(serviceInstanceId,"ServiceInstanceId"))
	    {
		 telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE);
	       return false;
        }

       //Check range for serviceInstanceId 
	  if 
(!checkRange(serviceInstanceId,SERVICE_INSTANCE_ID_MIN,SERVICE_INSTANCE_ID_MAX,"service 
Instance Id")){ 
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
      }

	     
	  // check that this service instance exists on the interface in the device
      if (!checkIfServiceInstanceExists(serviceInstanceId , interfaceName)){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    sendResult(false, "The Service Instance " + serviceInstanceId + " does not exist 
on interface " + interfaceName );
	    return false;
      }
            

      // now send configurations down
	  if(!config("conf t")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

      if(!config("int "+interfaceName )){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }

     if(!config("service instance " +serviceInstanceId + " e")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
    
	if(!config("no xconnect ")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    return false;
       }
      
    if(!config("end")){
	    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_FAILURE );
	    rollback_removexconnect_serviceInstance(interfaceName,loopbackAddress,"end");
		return false;
		}

    // Success
    sendResult(true, "The script ---remove_xconnect_serviceInstance--- was executed 
successfully");
    telnetInterface.setStatus(CARRIERETHERNET_PROVISIONING_STATUS_SUCCESS );
    return true;

 }