def _initCore(self, corename, settings = None, ddloc = None):
     """
     Initialises a core from the core manager with the given name.
     
     If not provided, it assembles a settings class and attempts to instantiate
     a core with the given name. If not successful, the entire program execution
     is aborted.
     
     @param corename: Name of the core to be initialised
     @type corename: C{String}
     @param settings: Settings to be used for this core
     @type settings: L{Runtime.Settings}
     @param ddloc: Location of the dd command. Is only used if the settings instance is not provided
     @type ddloc: C{String}
     
     @return: Reference to the created core instance.
     @rtype: L{GeneratorCoreAbstract.CoreInterface}
     """
     manager = CoreManager.getInstance()
     redirectBuffer = DEBUG_FILENAME
     if settings == None:
         if ddloc == None:
             settings = Runtime.Settings(redirectOutput = redirectBuffer)
         else:
             settings = Runtime.Settings(redirectOutput = redirectBuffer, path_dd = ddloc)
     try:
         coreClass = manager.getCoreClass(corename)
     except KeyError:
         print "\nRequested core not found. Program abortion.\n"
         sys.exit(-1)
     return coreClass(settings)
Example #2
0
 def _setup_docker_image(self):
   memory_limit_str = self.config.get('memory_limit', '')
   s = 'docker run --cpus=1 --cpuset-cpus="{core}" --ipc="host" ' \
       '-u {user_id}:{group_id} ' \
       '--cap-add=SYS_PTRACE --security-opt seccomp=unconfined {memory_limit_str} ' \
       '--name={docker_name} -td {docker_build}  > /dev/null 2>&1'.format(
                                       core=CoreManager().core[self.config["core"]],
                                       user_id=os.getuid(),
                                       group_id=os.getgid(), 
                                       docker_build=self.docker_build, 
                                       memory_limit_str=memory_limit_str, 
                                       docker_name=self.docker_name)
   print(s)
   os.system(s)
        with a slash are skipped. Afterwards, always the first column of a line is taken
        and a list of all them together is assembled.
        
        @return: List of names with some more information; List of names for devices extracted form the fstab file
        @rtype: C{List} of C{String}; C{List} of C{String}
        """
        fstab = open(FSTAB_LOCATION)
        ret = []
        
        line = " "
        while line != "":
            line = fstab.readline()
            if line == "":      # skip if EOF
                continue
            if line[0] != "/":      # skip lines with comments and other stuff
                continue
            vals = line.split()
            ret.append(vals[0])
        
        fstab.close()
        return ret, ret

    def getDefaultDDLocation(self):
        """
        Gives a location for the dd command which is very likely to be used with this
        implementation.
        """
        return DEFAULT_PATH_DD    
        
CoreManager.getInstance().registerCore(NAME_IMPL, GeneratorCore)
    def _fillPageOne(self, parameters):
        """
        Putting the controls for the first wizard page.
        
        Controls for the core choice and the specifying of the location for
        the dd command are placed on the content pane of the first
        wizard page.
        """
        import os.path
        panel_outer = wx.Panel(self._page1.getContentPane(), -1)
        
        lCore = wx.StaticText(panel_outer, -1, "Choose Core")
        choicesCore = CoreManager.getInstance().getListOfCoreNames()
        self._chCore = wx.Choice(panel_outer, _ID_CH_CORES, choices = choicesCore)
        self._chCore.SetSelection(0)
        if parameters.has_key('default_core'):
            for i in range(len(choicesCore)):
                if choicesCore[i] == parameters['default_core']:
                    self._chCore.SetSelection(i)
        
##        import wx
        lLocDD = wx.StaticText(panel_outer, -1, "Specify Location of the dd-command")
##        self._tcLocDD = wx.TextCtrl(panel_outer, -1)
##        bBrowse = wx.Button(panel_outer, _ID_BROWSE_DD, "Browse")
        panel_dir = wx.Panel(panel_outer, -1)
        self._tcLocDD = wx.TextCtrl(panel_dir , -1)        
        bmDir = wx.Bitmap(os.path.join(ImageSettings.PATH_ICONS, "browse.png"), wx.BITMAP_TYPE_PNG);
        panel_fill = wx.Panel(panel_dir, -1)
##        panel_fill.SetBackgroundColour(wx.RED)
        bBrowse = wx.BitmapButton(panel_dir, _ID_BROWSE_DD, bmDir, size=(25,25))        

        box = wx.BoxSizer(wx.HORIZONTAL)
        box.Add(self._tcLocDD, 16, wx.ALIGN_CENTER)
        box.Add(panel_fill, 1, wx.EXPAND)
        box.Add(bBrowse, 3, wx.ALIGN_CENTER)
        panel_dir.SetAutoLayout(True)
        panel_dir.SetSizer(box)
        panel_dir.Layout()

        
        panel_fill_hor2 = wx.Panel(panel_outer, -1)
        panel_fill_hor3 = wx.Panel(panel_outer, -1)
        box = wx.BoxSizer(wx.VERTICAL)
        box.Add(lCore, 1, wx.EXPAND)
        box.Add(self._chCore, 1, wx.EXPAND)
        box.Add(panel_fill_hor2, 1, wx.EXPAND)
        box.Add(lLocDD, 1, wx.EXPAND)
        box.Add(panel_dir, 2, wx.EXPAND)
##        box.Add(self._tcLocDD, 2, wx.EXPAND)
##        box.Add(bBrowse, 2, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL)
        box.Add(panel_fill_hor3, 2, wx.EXPAND)

        panel_outer.SetAutoLayout(True)
        panel_outer.SetSizer(box)
        panel_outer.Layout()

        boxo = wx.BoxSizer(wx.VERTICAL)
        boxo.Add(panel_outer, 20, wx.EXPAND)

        self._page1.getContentPane().SetAutoLayout(True)
        self._page1.getContentPane().SetSizer(boxo)
        self._page1.getContentPane().Layout()
Example #5
0
 def _update(self):
   os.system('docker update --cpuset-cpus="{core}" {docker_name} > /dev/null 2>&1'.format(core=CoreManager().core[self.config["core"]], docker_name=self.docker_name))
   os.system('docker update --cpus="{share}" {docker_name} > /dev/null 2>&1'.format(share="%.02f" % self.config["cpu_share"], docker_name=self.docker_name))