Esempio n. 1
0
 def priv_CreateSliver(self, slice_urn, credentials, rspec, users, force_approval=False, options=None):	
   #user_info = {}
   user_info = users
   try:
     #if CredVerifier.checkValid(credentials, "createsliver"):
     if True:
       self.recordAction("createsliver", credentials, slice_urn)
       try:
         #cert = Certificate(request.environ['CLIENT_RAW_CERT'])
         #user_info["urn"] = cert.getURN()
         #user_info["email"] = cert.getEmailAddress()
         self._log.debug("Parsed user cert with URN (%(urn)s) and email (%(email)s)" % users)
       except Exception, e:
         self._log.exception("UNFILTERED EXCEPTION")
         user_info["urn"] = None
         user_info["email"] = None
       from foam.app import admin_apih
       if not admin_apih.vlan_automation_on:
         sliver = foam.geni.lib.createSliver(slice_urn, credentials, rspec, user_info)
         style = ConfigDB.getConfigItemByKey("geni.approval.approve-on-creation").getValue()
         if style == foam.geni.approval.NEVER:
           approve = False
         elif style == foam.geni.approval.ALWAYS:
           approve = True
         else:
           approve = foam.geni.ofeliaapproval.of_analyzeForApproval(sliver)
         if approve or force_approval:
           pid = foam.task.approveSliver(sliver.getURN(), AUTO_SLIVER_PRIORITY)
           self._log.debug("task.py launched for approve-sliver (PID: %d)" % pid)	
       else:
         free_vlan_list = self.pub_get_offered_vlans(1)
         free_vlan = free_vlan_list[0]
         slice_id = slice_urn.split("+slice+")[1].split(":")[0].split("id_")[1].split("name_")[0]
         #filedir = './opt/ofelia/ofam/local/db'
         #filename = os.path.join(filedir, 'expedient_slices_info.json')
         #f = open(filename, 'r')
         #self.slice_info_dict = json.load(f)
         #f.close()
         if (slice_id == "") or (slice_id not in self.slice_info_dict): 
           self._log.exception("The slice id you specified is non-existent")
           raise Exception
         updated_slice_info_dict = self.slice_info_dict.copy()
         for sliv_pos, sliver in enumerate(self.slice_info_dict[slice_id]['switch_slivers']):
           for sfs_pos, sfs in enumerate(sliver['flowspace']):   
             updated_slice_info_dict[slice_id]['switch_slivers'][sliv_pos]['flowspace'][sfs_pos]['vlan_id_start'] = free_vlan
             updated_slice_info_dict[slice_id]['switch_slivers'][sliv_pos]['flowspace'][sfs_pos]['vlan_id_end'] = free_vlan
         all_efs = self.create_slice_fs(updated_slice_info_dict[slice_id]['switch_slivers'])
         new_slice_of_rspec = create_ofv3_rspec(slice_id, updated_slice_info_dict[slice_id]['project_name'], updated_slice_info_dict[slice_id]['project_desc'], \
                                     updated_slice_info_dict[slice_id]['slice_name'], updated_slice_info_dict[slice_id]['slice_desc'], \
                                     updated_slice_info_dict[slice_id]['controller_url'], updated_slice_info_dict[slice_id]['owner_email'], \
                                     updated_slice_info_dict[slice_id]['owner_password'], \
                                     updated_slice_info_dict[slice_id]['switch_slivers'], all_efs)
         self.slice_info_dict = updated_slice_info_dict.copy()
         sliver = foam.geni.lib.createSliver(slice_urn, credentials, new_slice_of_rspec, user_info)
         pid = foam.task.approveSliver(sliver.getURN(), AUTO_SLIVER_PRIORITY)
         self._log.debug("task.py launched for approve-sliver (PID: %d)" % pid)
       data = GeniDB.getSliverData(sliver.getURN(), True)
       foam.task.emailCreateSliver(data)
       return self.successResult(GeniDB.getManifest(sliver.getURN()))
     return
 def pub_change_slice_controller(self, slice_id, controller_url, **kwargs):
     slice_id = slice_id.replace(":", "_")
     slice_id = slice_id.replace("name_", "nam__")
     '''
 Changes the slice controller url.
 '''
     if slice_id not in self.slice_info_dict:
         self._log.info(
             "Slice is probably not started yet, doing nothing...")
         return ""
         #raise Exception("Something went wrong with the fs recovery")
     #retrieve updated dict as a json file from foam db folder
     filedir = './opt/ofelia/ofam/local/db'
     filename = os.path.join(filedir, 'expedient_slices_info.json')
     if os.path.isfile(filename):
         f = open(filename, 'r')
         self.slice_info_dict = json.load(f)
         f.close()
     else:
         self._log.info(
             "Slice is probably not started yet, doing nothing...")
         return ""
     slice_of_rspec = create_ofv3_rspec(
         slice_id, self.slice_info_dict[slice_id]['project_name'],
         self.slice_info_dict[slice_id]['project_desc'],
         self.slice_info_dict[slice_id]['slice_name'],
         self.slice_info_dict[slice_id]['slice_desc'], controller_url,
         self.slice_info_dict[slice_id]['owner_email'],
         self.slice_info_dict[slice_id]['owner_password'],
         self.slice_info_dict[slice_id]['switch_slivers'],
         self.create_slice_fs(
             self.slice_info_dict[slice_id]['switch_slivers']))
     self.slice_info_dict[slice_id]['controller_url'] = controller_url
     slice_urn = "urn:publicid:IDN+openflow:foam:" + str(
         THIS_SITE_TAG) + "+slice+" + "id_" + str(slice_id) + "name_" + str(
             self.slice_info_dict[slice_id]['slice_name'])
     creds = []  #creds are not needed at least for now: to be fixed
     user_info = {}
     user_info["urn"] = "urn:publicid:IDN+openflow:foam" + str(
         THIS_SITE_TAG) + "+ch+" + "user+" + str(
             self.slice_info_dict[slice_id]['owner_email'])  #temp hack
     user_info["email"] = str(self.slice_info_dict[slice_id]['owner_email'])
     if GeniDB.sliceExists(slice_urn):
         sliv_urn = GeniDB.getSliverURN(slice_urn)
     else:
         raise Exception(
             "Something went wrong with the fs recovery, slice does not exist!"
         )
     sliver = GeniDB.getSliverObj(sliv_urn)
     is_allocated_by_FV = GeniDB.getEnabled(sliv_urn)
     was_allocated_by_FV = is_allocated_by_FV
     try:
         #old_exp_shutdown_success = legexpgapi2_apih.pub_Shutdown(slice_urn, creds, [])
         old_exp_shutdown_success = self.priv_DeleteSliver(
             slice_urn, creds, [])
     except Exception, e:
         import traceback
         traceback.print_exc()
         raise Exception("Exception while trying to shutdown old slice!")
Esempio n. 3
0
 def pub_change_slice_controller(self, slice_id, controller_url, **kwargs):
   slice_id   = slice_id.replace(":","_")
   slice_id   = slice_id.replace("name_","nam__")
   '''
   Changes the slice controller url.
   '''
   if slice_id not in self.slice_info_dict:
     self._log.info("Slice is probably not started yet, doing nothing...")
     return ""
     #raise Exception("Something went wrong with the fs recovery")
   #retrieve updated dict as a json file from foam db folder
   filedir = './opt/ofelia/ofam/local/db'
   filename = os.path.join(filedir, 'expedient_slices_info.json')
   if os.path.isfile(filename):
     f = open(filename, 'r')
     self.slice_info_dict = json.load(f)
     f.close()
   else:
     self._log.info("Slice is probably not started yet, doing nothing...")
     return ""
   slice_of_rspec = create_ofv3_rspec(slice_id, self.slice_info_dict[slice_id]['project_name'], 
                                      self.slice_info_dict[slice_id]['project_desc'],
                                      self.slice_info_dict[slice_id]['slice_name'],
                                      self.slice_info_dict[slice_id]['slice_desc'], controller_url,
                                      self.slice_info_dict[slice_id]['owner_email'],
                                      self.slice_info_dict[slice_id]['owner_password'],
                                      self.slice_info_dict[slice_id]['switch_slivers'],
                                      self.create_slice_fs(self.slice_info_dict[slice_id]['switch_slivers']))
   self.slice_info_dict[slice_id]['controller_url'] = controller_url
   slice_urn = "urn:publicid:IDN+openflow:foam:"+ str(THIS_SITE_TAG) +"+slice+" + "id_" + str(slice_id) + "name_" + str(self.slice_info_dict[slice_id]['slice_name'])
   creds = [] #creds are not needed at least for now: to be fixed
   user_info = {}
   user_info["urn"] = "urn:publicid:IDN+openflow:foam"+ str(THIS_SITE_TAG) +"+ch+" + "user+" + str(self.slice_info_dict[slice_id]['owner_email']) #temp hack
   user_info["email"] = str(self.slice_info_dict[slice_id]['owner_email'])
   if GeniDB.sliceExists(slice_urn):
     sliv_urn = GeniDB.getSliverURN(slice_urn)
   else:
     raise Exception("Something went wrong with the fs recovery, slice does not exist!")
   sliver = GeniDB.getSliverObj(sliv_urn) 
   is_allocated_by_FV = GeniDB.getEnabled(sliv_urn)
   was_allocated_by_FV = is_allocated_by_FV
   try:
     #old_exp_shutdown_success = legexpgapi2_apih.pub_Shutdown(slice_urn, creds, [])
     old_exp_shutdown_success = self.priv_DeleteSliver(slice_urn, creds, [])
   except Exception, e:
     import traceback
     traceback.print_exc()
     raise Exception("Exception while trying to shutdown old slice!")
Esempio n. 4
0
  def pub_create_slice(self, slice_id, project_name, project_description,
                    slice_name, slice_description, controller_url,
                    owner_email, owner_password,
                    switch_slivers, **kwargs):               
    '''
    Create an OpenFlow slice. 
    
    The C{switch_sliver} list contains a dict for each switch to be added to the
    slice's topology. Each such dict has the following items:
    
    - C{datapath_id}: the switch's datapath id
    - C{flowspace}: an array of dicts describing the switch's flowspace
    Each such dict has the following keys:
        - C{id}: integer. Per clearinghouse unique identifier for the rule.
        - C{port_num_start}, C{port_num_end}: string. the port range for this 
        flowspace
        - C{dl_src_start}, C{dl_src_end}: string. link layer address range in
        "xx:xx:xx:xx:xx:xx" format or '*' for wildcard
        - C{dl_dst_start}, C{dl_dst_end}: string. link layer address range in
        "xx:xx:xx:xx:xx:xx" format or '*' for wildcard
        - C{vlan_id_start}, C{vlan_id_end}: string. vlan id range or
        "*" for wildcard
        - C{nw_src_start}, C{nw_src_end}: string. network address range in 
        "x.x.x.x" format or '*' for wildcard
        - C{nw_dst_start}, C{nw_dst_end}: string. network address range in
        "x.x.x.x" format or '*' for wildcard
        - C{nw_proto_start}, C{nw_proto_end}: string. network protocol range or
        "*" for wildcard
        - C{tp_src_start}, C{tp_src_end}: string. transport port range or "*"
        for wildcard
        - C{tp_dst_start}, C{tp_dst_end}: string. transport port range or "*"
        for wildcard

    The call returns a dict with the following items:
    - C{error_msg}: a summary error message or "" if no errors occurred.
    - C{switches}: a list of dicts with the following items:
        - C{datapath_id}: id of the switch that caused the error
        - C{error}: optional error msg for the switch
        - all other fields of the C{switch_sliver} dicts mentioned above
        (port_num, direction, ...). The values for these items are the error
        messages associated with each field.

    @param slice_id: a string that uniquely identifies the slice at the 
        clearinghouse.
    @type slice_id: int
    
    @param project_name: a name for the project under which this slice 
        is created
    @type project_name: string
    
    @param project_description: text describing the project
    @type project_description: string
    
    @param slice_name: Name for the slice
    @type slice_name: string
    
    @param slice_description: text describing the slice/experiment
    @type slice_description: string
    
    @param controller_url: The URL for the slice's OpenFlow controller specified
        as <transport>:<hostname>[:<port>], where:
            - tranport is 'tcp' ('ssl' will be added later)
            - hostname is the controller's hostname
            - port is the port on which the controller listens to openflow
            messages (defaults to 6633).
    @type controller_url: string
    
    @param owner_email: email of the person responsible for the slice
    @type owner_email: string
    
    @param owner_password: initial password the user can use to login to the
        FlowVisor Web interface. Will need to be changed on initial login.
    @type owner_password: string
    
    @param switch_slivers: description of the topology and flowspace for slice
    @type switch_slivers: list of dicts
    
    @param kwargs: will contain additional useful information about the request.
        Of most use are the items in the C{kwargs['request'].META} dict. These
        include 'REMOTE_USER' which is the username of the user connecting or
        if using x509 certs then the domain name. Additionally, kwargs has the
        user using the 'user' key.
    
    @return: switches and links that have caused errors
    @rtype: dict
    '''
    slice_id   = slice_id.replace(":","_")
    slice_id   = slice_id.replace("name_","nam__")
    slice_name = slice_name.replace(":","_") 
    
#    self._actionLog.info("Legacy Expedient API: create_slice got the following:")
#    self._actionLog.info("    slice_id: %s" % slice_id)
#    self._actionLog.info("    project_name: %s" % project_name)
#    self._actionLog.info("    project_desc: %s" % project_description)
#    self._actionLog.info("    slice_name: %s" % slice_name)
#    self._actionLog.info("    slice_desc: %s" % slice_description)
#    self._actionLog.info("    controller: %s" % controller_url)
#    self._actionLog.info("    owner_email: %s" % owner_email)
#    self._actionLog.info("    owner_pass: %s" % owner_password)
    #self._actionLog.info("    switch_slivers"
    #pprint(switch_slivers, indent=8)
    
    #legacy experiment creation (old database access)
    '''    
    e = Experiment.objects.filter(slice_id=slice_id)
    if (e.count()>0):
      old_e = e[0]
      old_fv_name = old_e.get_fv_slice_name()
      update_exp = True
      old_exp_fs = ExperimentFLowSpace.objects.filtswier(exp=old_e)
    else:
      update_exp = False  
    '''  
  
#    e = Experiment()
#    e.slice_id = slice_id
#    e.project_name = project_name
#    e.project_desc = project_description
#    e.slice_name = slice_name
#    e.slice_desc = slice_description
#    e.controller_url = controller_url
#    e.owner_email = owner_email
#    e.owner_password = owner_password
#    e.save()
    #update dict info
    purged_switch_slivers = self.purge_switch_slivers_from_null_fs(switch_slivers)
    self.slice_info_dict[slice_id] = {}
    self.slice_info_dict[slice_id]['project_name'] = project_name
    self.slice_info_dict[slice_id]['project_desc'] = project_description
    self.slice_info_dict[slice_id]['slice_name'] = slice_name
    self.slice_info_dict[slice_id]['slice_desc'] = slice_description
    self.slice_info_dict[slice_id]['controller_url'] = controller_url
    self.slice_info_dict[slice_id]['owner_email'] = owner_email
    self.slice_info_dict[slice_id]['owner_password'] = owner_password
    self.slice_info_dict[slice_id]['switch_slivers'] = purged_switch_slivers
   
    all_efs = self.create_slice_fs(purged_switch_slivers)
    
    #set the necessary parameters so that we can use FOAM internal functions for sliver creation
    #Vasileios: now that the requested flowspaces are identified, create the rspec (to be used in FOAM)
    slice_of_rspec = create_ofv3_rspec(slice_id, project_name, project_description, \
                                      slice_name, slice_description, controller_url, \
                                      owner_email, owner_password, \
                                      purged_switch_slivers, all_efs)
    self._log.info(slice_of_rspec) #print the rspec in the log for debugging

    #form the slice URN according to http://groups.geni.net/geni/wiki/GeniApiIdentifiers
    slice_urn = "urn:publicid:IDN+openflow:foam:"+ str(THIS_SITE_TAG) +"+slice+" + "id_" + str(slice_id) + "name_" + str(slice_name) 
    creds = [] #creds are not needed at least for now: to be fixed
    user_info = {}
    user_info["urn"] = "urn:publicid:IDN+openflow:foam"+ str(THIS_SITE_TAG) +"+ch+" + "user+" + str(owner_email) #temp hack
    user_info["email"] = str(owner_email)
    
    #now we have: slice_urn, creds, rspec and user_info : great!
    update_exp = True    
    #if GeniDB.getSliverURN(slice_urn) is None:
    if not GeniDB.sliceExists(slice_urn):
      update_exp = False    

    #moving on (now use gapi2 calls)
    if (update_exp):
      try:
        #old_exp_fs.delete()
        #old_e.delete()
        old_exp_shutdown_success = self.priv_DeleteSliver(slice_urn, creds, [])
      except Exception, e:
        import traceback
        traceback.print_exc()
        raise Exception("Exception while trying to shutdown old slice!")
      if old_exp_shutdown_success == False:
        raise Exception("Old slice could not be shutdown")
    def pub_create_slice(self, slice_id, project_name, project_description,
                         slice_name, slice_description, controller_url,
                         owner_email, owner_password, switch_slivers,
                         **kwargs):
        '''
    Create an OpenFlow slice. 
    
    The C{switch_sliver} list contains a dict for each switch to be added to the
    slice's topology. Each such dict has the following items:
    
    - C{datapath_id}: the switch's datapath id
    - C{flowspace}: an array of dicts describing the switch's flowspace
    Each such dict has the following keys:
        - C{id}: integer. Per clearinghouse unique identifier for the rule.
        - C{port_num_start}, C{port_num_end}: string. the port range for this 
        flowspace
        - C{dl_src_start}, C{dl_src_end}: string. link layer address range in
        "xx:xx:xx:xx:xx:xx" format or '*' for wildcard
        - C{dl_dst_start}, C{dl_dst_end}: string. link layer address range in
        "xx:xx:xx:xx:xx:xx" format or '*' for wildcard
        - C{vlan_id_start}, C{vlan_id_end}: string. vlan id range or
        "*" for wildcard
        - C{nw_src_start}, C{nw_src_end}: string. network address range in 
        "x.x.x.x" format or '*' for wildcard
        - C{nw_dst_start}, C{nw_dst_end}: string. network address range in
        "x.x.x.x" format or '*' for wildcard
        - C{nw_proto_start}, C{nw_proto_end}: string. network protocol range or
        "*" for wildcard
        - C{tp_src_start}, C{tp_src_end}: string. transport port range or "*"
        for wildcard
        - C{tp_dst_start}, C{tp_dst_end}: string. transport port range or "*"
        for wildcard

    The call returns a dict with the following items:
    - C{error_msg}: a summary error message or "" if no errors occurred.
    - C{switches}: a list of dicts with the following items:
        - C{datapath_id}: id of the switch that caused the error
        - C{error}: optional error msg for the switch
        - all other fields of the C{switch_sliver} dicts mentioned above
        (port_num, direction, ...). The values for these items are the error
        messages associated with each field.

    @param slice_id: a string that uniquely identifies the slice at the 
        clearinghouse.
    @type slice_id: int
    
    @param project_name: a name for the project under which this slice 
        is created
    @type project_name: string
    
    @param project_description: text describing the project
    @type project_description: string
    
    @param slice_name: Name for the slice
    @type slice_name: string
    
    @param slice_description: text describing the slice/experiment
    @type slice_description: string
    
    @param controller_url: The URL for the slice's OpenFlow controller specified
        as <transport>:<hostname>[:<port>], where:
            - tranport is 'tcp' ('ssl' will be added later)
            - hostname is the controller's hostname
            - port is the port on which the controller listens to openflow
            messages (defaults to 6633).
    @type controller_url: string
    
    @param owner_email: email of the person responsible for the slice
    @type owner_email: string
    
    @param owner_password: initial password the user can use to login to the
        FlowVisor Web interface. Will need to be changed on initial login.
    @type owner_password: string
    
    @param switch_slivers: description of the topology and flowspace for slice
    @type switch_slivers: list of dicts
    
    @param kwargs: will contain additional useful information about the request.
        Of most use are the items in the C{kwargs['request'].META} dict. These
        include 'REMOTE_USER' which is the username of the user connecting or
        if using x509 certs then the domain name. Additionally, kwargs has the
        user using the 'user' key.
    
    @return: switches and links that have caused errors
    @rtype: dict
    '''
        slice_id = slice_id.replace(":", "_")
        slice_id = slice_id.replace("name_", "nam__")
        slice_name = slice_name.replace(":", "_")

        #    self._actionLog.info("Legacy Expedient API: create_slice got the following:")
        #    self._actionLog.info("    slice_id: %s" % slice_id)
        #    self._actionLog.info("    project_name: %s" % project_name)
        #    self._actionLog.info("    project_desc: %s" % project_description)
        #    self._actionLog.info("    slice_name: %s" % slice_name)
        #    self._actionLog.info("    slice_desc: %s" % slice_description)
        #    self._actionLog.info("    controller: %s" % controller_url)
        #    self._actionLog.info("    owner_email: %s" % owner_email)
        #    self._actionLog.info("    owner_pass: %s" % owner_password)
        #self._actionLog.info("    switch_slivers"
        #pprint(switch_slivers, indent=8)

        #legacy experiment creation (old database access)
        '''    
    e = Experiment.objects.filter(slice_id=slice_id)
    if (e.count()>0):
      old_e = e[0]
      old_fv_name = old_e.get_fv_slice_name()
      update_exp = True
      old_exp_fs = ExperimentFLowSpace.objects.filtswier(exp=old_e)
    else:
      update_exp = False  
    '''

        #    e = Experiment()
        #    e.slice_id = slice_id
        #    e.project_name = project_name
        #    e.project_desc = project_description
        #    e.slice_name = slice_name
        #    e.slice_desc = slice_description
        #    e.controller_url = controller_url
        #    e.owner_email = owner_email
        #    e.owner_password = owner_password
        #    e.save()
        #update dict info
        purged_switch_slivers = self.purge_switch_slivers_from_null_fs(
            switch_slivers)
        self.slice_info_dict[slice_id] = {}
        self.slice_info_dict[slice_id]['project_name'] = project_name
        self.slice_info_dict[slice_id]['project_desc'] = project_description
        self.slice_info_dict[slice_id]['slice_name'] = slice_name
        self.slice_info_dict[slice_id]['slice_desc'] = slice_description
        self.slice_info_dict[slice_id]['controller_url'] = controller_url
        self.slice_info_dict[slice_id]['owner_email'] = owner_email
        self.slice_info_dict[slice_id]['owner_password'] = owner_password
        self.slice_info_dict[slice_id][
            'switch_slivers'] = purged_switch_slivers

        all_efs = self.create_slice_fs(purged_switch_slivers)

        #set the necessary parameters so that we can use FOAM internal functions for sliver creation
        #Vasileios: now that the requested flowspaces are identified, create the rspec (to be used in FOAM)
        slice_of_rspec = create_ofv3_rspec(slice_id, project_name, project_description, \
                                          slice_name, slice_description, controller_url, \
                                          owner_email, owner_password, \
                                          purged_switch_slivers, all_efs)
        self._log.info(
            slice_of_rspec)  #print the rspec in the log for debugging

        #form the slice URN according to http://groups.geni.net/geni/wiki/GeniApiIdentifiers
        slice_urn = "urn:publicid:IDN+openflow:foam:" + str(
            THIS_SITE_TAG) + "+slice+" + "id_" + str(slice_id) + "name_" + str(
                slice_name)
        creds = []  #creds are not needed at least for now: to be fixed
        user_info = {}
        user_info["urn"] = "urn:publicid:IDN+openflow:foam" + str(
            THIS_SITE_TAG) + "+ch+" + "user+" + str(owner_email)  #temp hack
        user_info["email"] = str(owner_email)

        #now we have: slice_urn, creds, rspec and user_info : great!
        update_exp = True
        #if GeniDB.getSliverURN(slice_urn) is None:
        if not GeniDB.sliceExists(slice_urn):
            update_exp = False

        #moving on (now use gapi2 calls)
        if (update_exp):
            try:
                #old_exp_fs.delete()
                #old_e.delete()
                old_exp_shutdown_success = self.priv_DeleteSliver(
                    slice_urn, creds, [])
            except Exception, e:
                import traceback
                traceback.print_exc()
                raise Exception(
                    "Exception while trying to shutdown old slice!")
            if old_exp_shutdown_success == False:
                raise Exception("Old slice could not be shutdown")
 def priv_CreateSliver(self,
                       slice_urn,
                       credentials,
                       rspec,
                       users,
                       force_approval=False,
                       options=None):
     #user_info = {}
     user_info = users
     try:
         #if CredVerifier.checkValid(credentials, "createsliver"):
         if True:
             self.recordAction("createsliver", credentials, slice_urn)
             try:
                 #cert = Certificate(request.environ['CLIENT_RAW_CERT'])
                 #user_info["urn"] = cert.getURN()
                 #user_info["email"] = cert.getEmailAddress()
                 self._log.debug(
                     "Parsed user cert with URN (%(urn)s) and email (%(email)s)"
                     % users)
             except Exception, e:
                 self._log.exception("UNFILTERED EXCEPTION")
                 user_info["urn"] = None
                 user_info["email"] = None
             from foam.app import admin_apih
             if not admin_apih.vlan_automation_on:
                 sliver = foam.geni.lib.createSliver(
                     slice_urn, credentials, rspec, user_info)
                 style = ConfigDB.getConfigItemByKey(
                     "geni.approval.approve-on-creation").getValue()
                 if style == foam.geni.approval.NEVER:
                     approve = False
                 elif style == foam.geni.approval.ALWAYS:
                     approve = True
                 else:
                     approve = foam.geni.ofeliaapproval.of_analyzeForApproval(
                         sliver)
                 if approve or force_approval:
                     pid = foam.task.approveSliver(sliver.getURN(),
                                                   AUTO_SLIVER_PRIORITY)
                     self._log.debug(
                         "task.py launched for approve-sliver (PID: %d)" %
                         pid)
             else:
                 free_vlan_list = self.pub_get_offered_vlans(1)
                 free_vlan = free_vlan_list[0]
                 slice_id = slice_urn.split("+slice+")[1].split(
                     ":")[0].split("id_")[1].split("name_")[0]
                 #filedir = './opt/ofelia/ofam/local/db'
                 #filename = os.path.join(filedir, 'expedient_slices_info.json')
                 #f = open(filename, 'r')
                 #self.slice_info_dict = json.load(f)
                 #f.close()
                 if (slice_id == "") or (slice_id
                                         not in self.slice_info_dict):
                     self._log.exception(
                         "The slice id you specified is non-existent")
                     raise Exception
                 updated_slice_info_dict = self.slice_info_dict.copy()
                 for sliv_pos, sliver in enumerate(
                         self.slice_info_dict[slice_id]['switch_slivers']):
                     for sfs_pos, sfs in enumerate(sliver['flowspace']):
                         updated_slice_info_dict[slice_id][
                             'switch_slivers'][sliv_pos]['flowspace'][
                                 sfs_pos]['vlan_id_start'] = free_vlan
                         updated_slice_info_dict[slice_id][
                             'switch_slivers'][sliv_pos]['flowspace'][
                                 sfs_pos]['vlan_id_end'] = free_vlan
                 all_efs = self.create_slice_fs(
                     updated_slice_info_dict[slice_id]['switch_slivers'])
                 new_slice_of_rspec = create_ofv3_rspec(slice_id, updated_slice_info_dict[slice_id]['project_name'], updated_slice_info_dict[slice_id]['project_desc'], \
                                             updated_slice_info_dict[slice_id]['slice_name'], updated_slice_info_dict[slice_id]['slice_desc'], \
                                             updated_slice_info_dict[slice_id]['controller_url'], updated_slice_info_dict[slice_id]['owner_email'], \
                                             updated_slice_info_dict[slice_id]['owner_password'], \
                                             updated_slice_info_dict[slice_id]['switch_slivers'], all_efs)
                 self.slice_info_dict = updated_slice_info_dict.copy()
                 sliver = foam.geni.lib.createSliver(
                     slice_urn, credentials, new_slice_of_rspec, user_info)
                 pid = foam.task.approveSliver(sliver.getURN(),
                                               AUTO_SLIVER_PRIORITY)
                 self._log.debug(
                     "task.py launched for approve-sliver (PID: %d)" % pid)
             data = GeniDB.getSliverData(sliver.getURN(), True)
             foam.task.emailCreateSliver(data)
             return self.successResult(GeniDB.getManifest(sliver.getURN()))
         return