def __init__(self, options, cmdlineProps): # Basic setup self._log = logging.getLogger('NodeConfig') self.localfile_nodeprefix = '/mgr' self.options = options self.cmdlineProps = cmdlineProps self.hostname = socket.gethostname() # check domainname if options.domainname == None: raise ConfigurationError("A domainname is required") # Verify the base AD936X LIBIIO profile exists self.ad936x_libiio_templates = { "spd": os.path.join(self.options.sdrroot, "dev", self.options.ad936xpath[1:], "AD936X_LIBIIO.spd.xml"), "prf": os.path.join(self.options.sdrroot, "dev", self.options.ad936xpath[1:], "AD936X_LIBIIO.prf.xml"), "scd": os.path.join(self.options.sdrroot, "dev", self.options.ad936xpath[1:], "AD936X_LIBIIO.scd.xml") } for template in self.ad936x_libiio_templates.values(): if not os.path.exists(template): raise ConfigurationError("%s missing" % template) self.nodedir = os.path.join(self.options.sdrroot, "dev", "nodes", self.options.nodename.replace('.', '/')) self.path_to_dcd = os.path.join(self.nodedir, "DeviceManager.dcd.xml") # Figure out where we are going to write the AD936X_LIBIIO profile if self.options.inplace: self.ad936x_libiio_path = os.path.join(self.options.sdrroot, "dev", "devices", "AD936X_LIBIIO") else: self.ad936x_libiio_path = os.path.join(self.nodedir, "AD936X_LIBIIO") # prep uuids self.uuids = {} self.uuids["softpkg"] = 'DCE:' + uuidgen() self.uuids["implementation"] = 'DCE:' + uuidgen() self.uuids["deviceconfiguration"] = 'DCE:' + uuidgen() self.uuids["componentfile"] = 'DCE:' + uuidgen() self.uuids["componentinstantiation"] = 'DCE:' + uuidgen() self.uuids["componentimplementation"] = 'DCE:' + uuidgen() self.uuids["componentsoftpkg"] = 'DCE:' + uuidgen() self.props = {}
def __init__(self, options, cmdlineProps): # Basic setup self._log = logging.getLogger("NodeConfig") self.localfile_nodeprefix = "/mgr" self.options = options self.cmdlineProps = cmdlineProps self.hostname = socket.gethostname() # check domainname if options.domainname == None: raise ConfigurationError("A domainname is required") # Verify the base RTL 2832U profile exists self.rtl2832U_templates = { "spd": os.path.join(self.options.sdrroot, "dev", self.options.rtlpath[1:], "RTL2832U.spd.xml"), "prf": os.path.join(self.options.sdrroot, "dev", self.options.rtlpath[1:], "RTL2832U.prf.xml"), "scd": os.path.join(self.options.sdrroot, "dev", self.options.rtlpath[1:], "RTL2832U.scd.xml"), } for template in self.rtl2832U_templates.values(): if not os.path.exists(template): raise ConfigurationError("%s missing" % template) self.nodedir = os.path.join(self.options.sdrroot, "dev", "nodes", self.options.nodename.replace(".", "/")) self.path_to_dcd = os.path.join(self.nodedir, "DeviceManager.dcd.xml") # Figure out where we are going to write the RTL2832U profile if self.options.inplace: self.rtl2832U_path = os.path.join(self.options.sdrroot, "dev", "devices", "rh", "RTL2832U") else: self.rtl2832U_path = os.path.join(self.nodedir, "RTL2832U") # prep uuids self.uuids = {} self.uuids["softpkg"] = "DCE:" + uuidgen() self.uuids["implementation"] = "DCE:" + uuidgen() self.uuids["deviceconfiguration"] = "DCE:" + uuidgen() self.uuids["componentfile"] = "DCE:" + uuidgen() self.uuids["componentinstantiation"] = "DCE:" + uuidgen() self.uuids["componentimplementation"] = "DCE:" + uuidgen() self.uuids["componentsoftpkg"] = "DCE:" + uuidgen() self.props = {}
def __init__(self, options, cmdlineProps): # Basic setup self._log = logging.getLogger('NodeMerge') self.localfile_nodeprefix = '/mgr' self.options = options self.cmdlineProps = cmdlineProps self.hostname = socket.gethostname() # check domainname if options.domainname == None: raise ConfigurationError("A domainname is required") # Common node path self.node_base_path = os.path.join(self.options.sdrroot, "dev", "nodes") # This node self.nodedir = os.path.join(self.node_base_path, self.options.nodename.replace('.', '/')) self.path_to_dcd = os.path.join(self.nodedir, "DeviceManager.dcd.xml") # Find all paths for dcd.xml's other than this node. def find_dcds(path): dcds = [] for root, dirs, files in os.walk(path): for name in files: if ".dcd.xml" in name: test_path = os.path.join(root, name) if test_path != self.path_to_dcd: dcds.append(parsers.DCDParser.parse(test_path)) return dcds self.other_dcds = find_dcds(self.node_base_path) if not self.other_dcds: raise ConfigurationError("No nodes found to merge.") # prep uuids self.uuids = {} self.uuids["deviceconfiguration"] = 'DCE:' + uuidgen()
def __init__(self, options, cmdlineProps): # Basic setup self._log = logging.getLogger('NodeMerge') self.localfile_nodeprefix = '/mgr' self.options = options self.cmdlineProps = cmdlineProps self.hostname = socket.gethostname() # check domainname if options.domainname == None: raise ConfigurationError("A domainname is required") # Common node path self.node_base_path = os.path.join(self.options.sdrroot, "dev", "nodes") # This node self.nodedir = os.path.join(self.node_base_path, self.options.nodename.replace('.','/')) self.path_to_dcd = os.path.join(self.nodedir , "DeviceManager.dcd.xml") # Find all paths for dcd.xml's other than this node. def find_dcds(path): dcds = [] for root, dirs, files in os.walk(path): for name in files: if ".dcd.xml" in name: test_path = os.path.join(root, name) if test_path != self.path_to_dcd: dcds.append(parsers.DCDParser.parse(test_path)) return dcds self.other_dcds = find_dcds(self.node_base_path) if not self.other_dcds: raise ConfigurationError("No nodes found to merge.") # prep uuids self.uuids = {} self.uuids["deviceconfiguration" ] = 'DCE:' + uuidgen()
def _createDeviceManagerProfile(self): ##################### # Setup environment ##################### # make sure node hasn't already been created if os.path.exists(self.path_to_dcd): self._log.error( "Cannot 'register' new dynamicnode. A previous configuration was found. Please 'unregister' dynamicnode first." ) sys.exit(1) try: if not os.path.isdir(self.nodedir): os.makedirs(self.nodedir) else: if not self.options.silent: self._log.debug( "Node directory already exists; skipping directory creation" ) pass except OSError: raise Exception, "Could not create device manager directory" AD936X_LIBIIO_componentfile = 'AD936X_LIBIIO_' + uuidgen() if self.options.inplace: compfiles = [{ 'id': AD936X_LIBIIO_componentfile, 'localfile': os.path.join('/devices', 'AD936X_LIBIIO', 'AD936X_LIBIIO.spd.xml') }] else: compfiles = [{ 'id': AD936X_LIBIIO_componentfile, 'localfile': os.path.join('/nodes', self.options.nodename.replace('.', '/'), 'AD936X_LIBIIO', 'AD936X_LIBIIO.spd.xml') }] compplacements = [{ 'refid': AD936X_LIBIIO_componentfile, 'instantiations': [{ 'id': self.uuids["componentinstantiation"], 'usagename': 'AD936X_LIBIIO_' + self.hostname.replace('.', '_') }] }] ##################### # DeviceManager files ##################### if not self.options.silent: self._log.debug("Creating DeviceManager profile <" + self.options.nodename + ">") # set deviceconfiguration info _dcd = parsers.DCDParser.deviceconfiguration() _dcd.set_id(self.uuids["deviceconfiguration"]) _dcd.set_name(self.options.nodename) _localfile = parsers.DCDParser.localfile(name=os.path.join( self.localfile_nodeprefix, 'DeviceManager.spd.xml')) _dcd.devicemanagersoftpkg = parsers.DCDParser.devicemanagersoftpkg( localfile=_localfile) # add componentfiles and componentfile(s) _dcd.componentfiles = parsers.DCDParser.componentfiles() for in_cf in compfiles: cf = parsers.DCDParser.componentfile( type_='SPD', id_=in_cf['id'], localfile=parsers.DCDParser.localfile(name=in_cf['localfile'])) _dcd.componentfiles.add_componentfile(cf) # add partitioning/componentplacements _dcd.partitioning = parsers.DCDParser.partitioning() for in_cp in compplacements: _comp_fileref = parsers.DCDParser.componentfileref( refid=in_cp['refid']) _comp_placement = parsers.DCDParser.componentplacement( componentfileref=_comp_fileref) for ci in in_cp['instantiations']: comp_inst = parsers.DCDParser.componentinstantiation( id_=ci['id'], usagename=ci['usagename']) _comp_placement.add_componentinstantiation(comp_inst) _dcd.partitioning.add_componentplacement(_comp_placement) # add domainmanager lookup if self.options.domainname: _tmpdomainname = self.options.domainname + '/' + self.options.domainname _dcd.domainmanager = parsers.DCDParser.domainmanager( namingservice=parsers.DCDParser.namingservice(name=_tmpdomainname)) dcd_out = open(self.path_to_dcd, 'w') dcd_out.write(parsers.parserconfig.getVersionXML()) _dcd.export(dcd_out, 0) dcd_out.close()
def _createDeviceManagerProfile(self): ##################### # Setup environment ##################### # make sure node hasn't already been created if os.path.exists(self.path_to_dcd): self._log.error("Cannot 'register' new dynamicnode. A previous configuration was found. Please 'unregister' dynamicnode first.") sys.exit(1) try: if not os.path.isdir(self.nodedir): os.makedirs(self.nodedir) else: if not self.options.silent: self._log.debug("Node directory already exists; skipping directory creation") pass except OSError: raise Exception, "Could not create device manager directory" USRP_UHD_componentfile = 'rh.USRP_UHD__' + uuidgen() if self.options.inplace: compfiles = [{'id':USRP_UHD_componentfile, 'localfile':os.path.join('/devices', 'rh', 'USRP_UHD', 'USRP_UHD.spd.xml')}] else: compfiles = [{'id':USRP_UHD_componentfile, 'localfile':os.path.join('/nodes', self.options.nodename.replace('.','/'), 'USRP_UHD', 'USRP_UHD.spd.xml')}] compplacements = [{'refid':USRP_UHD_componentfile, 'instantiations':[{'id':self.uuids["componentinstantiation"], 'usagename':'rh.USRP_UHD_' + self.hostname.replace('.', '_')}]}] ##################### # DeviceManager files ##################### if not self.options.silent: self._log.debug("Creating DeviceManager profile <" + self.options.nodename + ">") # set deviceconfiguration info _dcd = parsers.DCDParser.deviceconfiguration() _dcd.set_id(self.uuids["deviceconfiguration"]) _dcd.set_name(self.options.nodename) _localfile = parsers.DCDParser.localfile(name=os.path.join(self.localfile_nodeprefix, 'DeviceManager.spd.xml')) _dcd.devicemanagersoftpkg = parsers.DCDParser.devicemanagersoftpkg(localfile=_localfile) # add componentfiles and componentfile(s) _dcd.componentfiles = parsers.DCDParser.componentfiles() for in_cf in compfiles: cf = parsers.DCDParser.componentfile(type_='SPD', id_=in_cf['id'], localfile=parsers.DCDParser.localfile(name=in_cf['localfile'])) _dcd.componentfiles.add_componentfile(cf) # add partitioning/componentplacements _dcd.partitioning = parsers.DCDParser.partitioning() for in_cp in compplacements: _comp_fileref = parsers.DCDParser.componentfileref(refid=in_cp['refid']) _comp_placement = parsers.DCDParser.componentplacement(componentfileref=_comp_fileref) for ci in in_cp['instantiations']: comp_inst = parsers.DCDParser.componentinstantiation(id_=ci['id'], usagename=ci['usagename']) _comp_placement.add_componentinstantiation(comp_inst) _dcd.partitioning.add_componentplacement(_comp_placement) # add domainmanager lookup if self.options.domainname: _tmpdomainname = self.options.domainname + '/' + self.options.domainname _dcd.domainmanager = parsers.DCDParser.domainmanager(namingservice=parsers.DCDParser.namingservice(name=_tmpdomainname)) dcd_out = open(self.path_to_dcd, 'w') dcd_out.write(parsers.parserconfig.getVersionXML()) _dcd.export(dcd_out,0) dcd_out.close()
def _createDeviceManagerProfile(self): ##################### # Setup environment ##################### # make sure node hasn't already been created if os.path.exists(self.path_to_dcd): self._log.error( "Cannot 'register' new dynamicnode. A previous configuration was found. Please 'unregister' dynamicnode first." ) sys.exit(1) try: if not os.path.isdir(self.nodedir): os.makedirs(self.nodedir) else: if not self.options.silent: self._log.debug("Node directory already exists; skipping directory creation") pass except OSError: raise Exception, "Could not create device manager directory" RTL2832U_componentfile = "rh.RTL2832U_" + uuidgen() if self.options.inplace: compfiles = [ { "id": RTL2832U_componentfile, "localfile": os.path.join("/devices", "rh", "RTL2832U", "RTL2832U.spd.xml"), } ] else: compfiles = [ { "id": RTL2832U_componentfile, "localfile": os.path.join( "/nodes", self.options.nodename.replace(".", "/"), "RTL2832U", "RTL2832U.spd.xml" ), } ] compplacements = [ { "refid": RTL2832U_componentfile, "instantiations": [ { "id": self.uuids["componentinstantiation"], "usagename": "rh.RTL2832U_" + self.hostname.replace(".", "_"), } ], } ] ##################### # DeviceManager files ##################### if not self.options.silent: self._log.debug("Creating DeviceManager profile <" + self.options.nodename + ">") # set deviceconfiguration info _dcd = parsers.DCDParser.deviceconfiguration() _dcd.set_id(self.uuids["deviceconfiguration"]) _dcd.set_name(self.options.nodename) _localfile = parsers.DCDParser.localfile(name=os.path.join(self.localfile_nodeprefix, "DeviceManager.spd.xml")) _dcd.devicemanagersoftpkg = parsers.DCDParser.devicemanagersoftpkg(localfile=_localfile) # add componentfiles and componentfile(s) _dcd.componentfiles = parsers.DCDParser.componentfiles() for in_cf in compfiles: cf = parsers.DCDParser.componentfile( type_="SPD", id_=in_cf["id"], localfile=parsers.DCDParser.localfile(name=in_cf["localfile"]) ) _dcd.componentfiles.add_componentfile(cf) # add partitioning/componentplacements _dcd.partitioning = parsers.DCDParser.partitioning() for in_cp in compplacements: _comp_fileref = parsers.DCDParser.componentfileref(refid=in_cp["refid"]) _comp_placement = parsers.DCDParser.componentplacement(componentfileref=_comp_fileref) for ci in in_cp["instantiations"]: comp_inst = parsers.DCDParser.componentinstantiation(id_=ci["id"], usagename=ci["usagename"]) _comp_placement.add_componentinstantiation(comp_inst) _dcd.partitioning.add_componentplacement(_comp_placement) # add domainmanager lookup if self.options.domainname: _tmpdomainname = self.options.domainname + "/" + self.options.domainname _dcd.domainmanager = parsers.DCDParser.domainmanager( namingservice=parsers.DCDParser.namingservice(name=_tmpdomainname) ) dcd_out = open(self.path_to_dcd, "w") dcd_out.write(parsers.parserconfig.getVersionXML()) _dcd.export(dcd_out, 0) dcd_out.close()