def create_sliver (self, slice_urn, slice_hrn, creds, rspec_string, users, options): logger.debug("=======================slice_urn: %s" %(slice_urn, )) logger.debug("=======================slice_hrn: %s" %(slice_hrn, )) #logger.error("***creds %s" %(creds, )) logger.debug("=======================rspec_string: %s" %(rspec_string, )) #logger.error("***users %s" %(users, )) logger.debug("=======================options: %s" %(options, )) rp = RspecParser() infos = rp.parse_rspec(rspec_string) vct = self._get_sfa_vct(slice_hrn) for info in infos: rtype = info.rtype hostname = info.hostname parent = info.parent #config = parent.get_configuration() logger.info("=======================resource %s and parent %s" %(rtype,parent)) #create new instance of type rtype #now = datetime.datetime.now() now = strftime("%Y%m%dT%H%M%S") #also insert ptm in common name #ptm = Identifier(hostname).prefix commonName = ("%s-%s"%(rtype.commonName,now)) #add configuration to instance (for now default values for parent parameters) configLets = [] configParamAtList = rtype.configurationParameters.configParams logger.debug("=======================configParamAtList: %s " % configParamAtList) for configParamAtomic in configParamAtList: newCL = Configlet(configParamAtomic=configParamAtomic) newCL.commonName = configParamAtomic.commonName newCL.description = configParamAtomic.description newCL.paramValue = configParamAtomic.defaultParamValue logger.debug("=======================setting param %s with value %s " %(newCL.commonName, newCL.paramValue)) configLets.append(newCL) #state = self.repo.RESOURCE_INSTANCE_STATE_PROVISIONED state = self.repo.RESOURCE_INSTANCE_STATE_UNPROVISIONED instance = ResourceInstance(resourceSpec=rtype, configurationData=configLets, parentInstance=None, state=state, commonName = commonName) logger.debug("=======================Created a resource instance %s " % instance) vct.providesResources.append(instance) logger.debug("=======================Resource instance appended to vct %s " % vct) #fake IP value setting until values are not persisted in the repo from OE for configlet in instance.configurationData: logger.debug("***********************configlet: %s" % (configlet, )) if configlet.configParamAtomic.commonName == "ip": #logger.debug("***********************ip found") configlet.paramValue = "192.168.144.42" #logger.debug("***********************ip set") #test if parent instance is already in vct, if not: add it #if parent in vct.providesResources: # logger.debug("=======================Parent instance %s already in vct %s " % (parent,vct)) #else: # vct.providesResources.append(parent) # logger.debug("=======================Parent instance %s appended to vct %s " % (parent,vct)) self.repo.persist(vct) logger.debug("=======================Persisted vct %s " % vct) result = self.__rp.book(vct) #self.__rp.start(vct) logger.debug("=======================Booked vct %s " % vct) logger.debug("=======================result: %s " % result) options['geni_slice_urn'] = slice_urn logger.debug("=======================geni_slice_urn for RspecCreator: %s " % slice_urn) rc = RspecCreator() return rc.create_rspec(options)
def list_resources (self, creds, options): logger.debug("=======================driver.list_resources called") rc = RspecCreator() return rc.create_rspec(options)