ia64/xen-unstable

changeset 10887:947e09f90b3b

[ACM] A wxPython GUI tool for sHype/ACM in Xen. It is used
and described in the user guide to demonstrate how to quickly create,
enforce, and test workload protection policies in Xen. The tool is aimed
to improve usability of sHype/ACM for Xen.It is included in a single
file to make it easy to try it out on different platforms (it inherits
the look and feel of the base platform). It is tested on Linux and
Windows. Please read the new user guide section about how to start and
use the tool (section 10.2).

Requirements: python (www.python.org), wxPython (www.wxpython.org or
try 'yum install wxPython').

Signed-off by: Reiner Sailer <sailer@us.ibm.com>
author kfraser@localhost.localdomain
date Mon Jul 31 18:12:53 2006 +0100 (2006-07-31)
parents 3fae79942240
children 5379548bfc79
files tools/security/Makefile tools/security/xensec_ezpolicy
line diff
     1.1 --- a/tools/security/Makefile	Mon Jul 31 18:12:04 2006 +0100
     1.2 +++ b/tools/security/Makefile	Mon Jul 31 18:12:53 2006 +0100
     1.3 @@ -32,6 +32,7 @@ SRCS_XML2BIN  = secpol_xml2bin.c secpol_
     1.4  OBJS_XML2BIN := $(patsubst %.c,%.o,$(filter %.c,$(SRCS_XML2BIN)))
     1.5  
     1.6  ACM_INST_TOOLS    = xensec_tool xensec_xml2bin xensec_gen
     1.7 +ACM_EZPOLICY      = xensec_ezpolicy
     1.8  ACM_OBJS          = $(OBJS_TOOL) $(OBJS_XML2BIN) $(OBJS_GETD)
     1.9  ACM_SCRIPTS       = python/xensec_tools/acm_getlabel
    1.10  
    1.11 @@ -56,6 +57,7 @@ all: build
    1.12  install: all $(ACM_CONFIG_FILE)
    1.13  	$(INSTALL_DIR) -p $(DESTDIR)/usr/sbin
    1.14  	$(INSTALL_PROG) -p $(ACM_INST_TOOLS) $(DESTDIR)/usr/sbin
    1.15 +	$(INSTALL_PROG) -p $(ACM_EZPOLICY) $(DESTDIR)/usr/sbin
    1.16  	$(INSTALL_DIR) -p $(DESTDIR)$(ACM_CONFIG_DIR)
    1.17  	$(INSTALL_DIR) -p $(DESTDIR)$(ACM_POLICY_DIR)
    1.18  	$(INSTALL_DATA) -p policies/$(ACM_SCHEMA) $(DESTDIR)$(ACM_POLICY_DIR)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/tools/security/xensec_ezpolicy	Mon Jul 31 18:12:53 2006 +0100
     2.3 @@ -0,0 +1,1628 @@
     2.4 +#!/usr/bin/env python
     2.5 +#===========================================================================
     2.6 +# This program is free software; you can redistribute it and/or
     2.7 +# modify it under the terms of version 2.1 of the GNU Lesser General Public
     2.8 +# License as published by the Free Software Foundation.
     2.9 +#
    2.10 +# This library is distributed in the hope that it will be useful,
    2.11 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.12 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.13 +# Lesser General Public License for more details.
    2.14 +#
    2.15 +# You should have received a copy of the GNU Lesser General Public
    2.16 +# License along with this library; if not, write to the Free Software
    2.17 +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    2.18 +#============================================================================
    2.19 +# Copyright (C) 2006 International Business Machines Corp.
    2.20 +# Author: Reiner Sailer
    2.21 +#============================================================================
    2.22 +# use 'yum install wxPython' to get wx or download from www.wxpython.org
    2.23 +import sys, time, string
    2.24 +import wx
    2.25 +import wx.lib.buttons as buttons
    2.26 +"""
    2.27 +This program creates a default policy based on names of organizations and departments.
    2.28 +The resulting policy can be refined using the policy generation tool (xensec_gen).
    2.29 +"""
    2.30 +
    2.31 +helpprovider = wx.SimpleHelpProvider()
    2.32 +wx.HelpProvider_Set(helpprovider)
    2.33 +
    2.34 +ID_CS_START=1000
    2.35 +
    2.36 +realm_bmp = None
    2.37 +workload_bmp = None
    2.38 +conflict_bmp = None
    2.39 +realm_icon = None
    2.40 +workload_icon = None
    2.41 +
    2.42 +class orgTreeCtrl(wx.TreeCtrl):
    2.43 +
    2.44 +    event = None
    2.45 +
    2.46 +    def __init__(self, parent, id, pos, size, style, validator, name):
    2.47 +        wx.TreeCtrl.__init__(self, parent, id, pos, size, style,
    2.48 +                             validator, name)
    2.49 +        self.parent = parent
    2.50 +        orgs_root = self.AddRoot(text="Organization / Department")
    2.51 +        rootfont = wx.Font(pointSize=12, family=wx.FONTFAMILY_DEFAULT,
    2.52 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_LIGHT)
    2.53 +        self.SetItemFont(orgs_root, rootfont)
    2.54 +        self.SetItemBackgroundColour(orgs_root, wx.LIGHT_GREY)
    2.55 +
    2.56 +
    2.57 +    def LabelExists(self, label, item):
    2.58 +        for i in iterchildren(self.GetItemParent(item)):
    2.59 +            if (self.GetItemText(i) == label) and (i != item):
    2.60 +                return True
    2.61 +        return False
    2.62 +
    2.63 +
    2.64 +    def _OrgEdt(self, event):
    2.65 +        item = self.event.GetItem()
    2.66 +        self.OrgEdt(item)
    2.67 +
    2.68 +
    2.69 +    def OrgEdt(self, item):
    2.70 +        oldlabel= self.GetItemText(item)
    2.71 +        #get new name
    2.72 +        dlg = wx.TextEntryDialog(self, "Please enter org/dept name:",
    2.73 +                                 "Naming a Workload",
    2.74 +                                 style=wx.CANCEL | wx.OK | wx.CENTRE | wx.TE_NOHIDESEL)
    2.75 +        dlg.SetValue(oldlabel)
    2.76 +        ret = dlg.ShowModal()
    2.77 +        newlabel = dlg.GetValue()
    2.78 +        dlg.Destroy()
    2.79 +        if (ret == wx.ID_CANCEL) or (newlabel == ''):
    2.80 +            return False
    2.81 +
    2.82 +        #now check if the new name is permissible
    2.83 +        if self.LabelExists(newlabel, item):
    2.84 +            dlg = wx.MessageDialog(self, 'Item with name ' + newlabel + ' already exists!',
    2.85 +                                   'Rename', style=wx.OK)
    2.86 +            dlg.ShowModal()
    2.87 +            dlg.Destroy()
    2.88 +            return False
    2.89 +
    2.90 +        #all checkspassed, change item and adapt runtime exclusion rules
    2.91 +        self.SetItemText(item, newlabel)
    2.92 +        app.win.LabelReplaceInConflictsets(item, oldlabel, newlabel)
    2.93 +        return True
    2.94 +
    2.95 +
    2.96 +    def _OrgRAdd(self, event):
    2.97 +        self.OrgRAdd()
    2.98 +
    2.99 +
   2.100 +    def OrgRAdd(self):
   2.101 +        new = self.AppendItem(self.GetRootItem(), text="")
   2.102 +        self.SetItemBold(new, True)
   2.103 +        self.SetItemImage(new, realm_icon, wx.TreeItemIcon_Normal)
   2.104 +        self.EnsureVisible(new)
   2.105 +        if not self.OrgEdt(new):
   2.106 +            self.Delete(new)
   2.107 +
   2.108 +
   2.109 +    def _OrgWAdd(self, event):
   2.110 +        item = self.event.GetItem()
   2.111 +        self.OrgWAdd(item)
   2.112 +
   2.113 +
   2.114 +    def OrgWAdd(self, item):
   2.115 +        new = self.AppendItem(item, text="")
   2.116 +        self.Expand(item)
   2.117 +        self.SetItemImage(new, workload_icon, wx.TreeItemIcon_Normal)
   2.118 +        self.EnsureVisible(new)
   2.119 +        if not self.OrgEdt(new):
   2.120 +            self.Delete(new)
   2.121 +
   2.122 +
   2.123 +class OrgsPanel(wx.Panel):
   2.124 +    ID_CONSADDBTN = 145
   2.125 +    ID_REALMADDBTN = 144
   2.126 +
   2.127 +    def __init__(self, parent, ID):
   2.128 +        global realm_icon, workload_icon
   2.129 +
   2.130 +        wx.Panel.__init__(self, parent, -1)
   2.131 +
   2.132 +        #create image list
   2.133 +        imagelist = wx.ImageList(16, 17, True)
   2.134 +        #define generic function and use it for all input
   2.135 +        realm_icon = imagelist.Add(realm_bmp)
   2.136 +        workload_icon = imagelist.Add(workload_bmp)
   2.137 +
   2.138 +        #left tree control for organizations / workload definitions
   2.139 +        orgshdrbox = wx.StaticBox(self, -1, "")
   2.140 +        orgshdrboxsizer = wx.StaticBoxSizer(orgshdrbox, wx.HORIZONTAL)
   2.141 +        orgshdr = wx.StaticText(self, -1, "Organization / Department Definition",
   2.142 +                                style=wx.ALIGN_CENTER)
   2.143 +        orgshdr.SetHelpText(RealmWorkloadPanelHelp)
   2.144 +        points = orgshdr.GetFont().GetPointSize()  # get the current size
   2.145 +        hdrfont = wx.Font(points + 2, family=wx.DEFAULT,
   2.146 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD)
   2.147 +        orgshdr.SetFont(hdrfont)
   2.148 +        orgshdr.SetForegroundColour('MEDIUMBLUE')
   2.149 +        orgshdr.SetBackgroundColour('SNOW')
   2.150 +        orgshdrboxsizer.Add(orgshdr, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=5)
   2.151 +        addorgsbutton = wx.Button(self, self.ID_REALMADDBTN, "New Org", style=wx.BU_EXACTFIT)
   2.152 +        addorgsbutton.SetToolTipString("Add A New Organization")
   2.153 +        addorgsbutton.SetHelpText(NewRealmButtonHelp)
   2.154 +        addorgsbutton.SetForegroundColour('MEDIUMBLUE')
   2.155 +        addfont = wx.Font(points, family=wx.DEFAULT,
   2.156 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD)
   2.157 +        addorgsbutton.SetFont(addfont)
   2.158 +        orgshdrboxsizer.Add(addorgsbutton, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=0)
   2.159 +
   2.160 +        self.orgs = orgTreeCtrl(self, -1,
   2.161 +                                pos=wx.DefaultPosition,
   2.162 +                                size=wx.DefaultSize,
   2.163 +                                style=wx.TR_HAS_BUTTONS | wx.TR_HIDE_ROOT | wx.TR_NO_LINES
   2.164 +                                | wx.TR_MULTIPLE,
   2.165 +                                validator=wx.DefaultValidator,
   2.166 +                                name="orgs")
   2.167 +        self.orgs.AssignImageList(imagelist)
   2.168 +        self.orgs.SetHelpText(RealmWorkloadPanelHelp)
   2.169 +
   2.170 +        self.addconsbutton = wx.Button(self, self.ID_CONSADDBTN,
   2.171 +                                       "Create run-time exclusion rule from selection -->",
   2.172 +                                       style=wx.BU_EXACTFIT)
   2.173 +        self.addconsbutton.SetToolTipString("Create New Exclusion rule From Above Workload Selection")
   2.174 +        self.addconsbutton.SetHelpText(CreateRunTimeButtonHelp)
   2.175 +        self.addconsbutton.SetForegroundColour('MEDIUMBLUE')
   2.176 +        addfont = wx.Font(points, family=wx.DEFAULT,
   2.177 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD)
   2.178 +        self.addconsbutton.SetFont(addfont)
   2.179 +        self.addconsbutton.Bind(wx.EVT_BUTTON, self._AddConflict, id=self.ID_CONSADDBTN)
   2.180 +
   2.181 +        orgsvbox = wx.BoxSizer(wx.VERTICAL)
   2.182 +        orgsvbox.Add(orgshdrboxsizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
   2.183 +        orgsvbox.Add(self.orgs, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
   2.184 +        orgsvbox.Add(self.addconsbutton, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
   2.185 +        self.SetSizer(orgsvbox)
   2.186 +        addorgsbutton.Bind(wx.EVT_BUTTON, self.orgs._OrgRAdd, id= self.ID_REALMADDBTN)
   2.187 +
   2.188 +
   2.189 +    def _AddConflict(self, event):
   2.190 +        app.win.conspanel._AddNewConflict(event)
   2.191 +
   2.192 +
   2.193 +class ConsPanel(wx.Panel):
   2.194 +    ID_CONSSELECT = 151
   2.195 +    ID_CONSADD = 152
   2.196 +    ID_CONSRENAME = 153
   2.197 +    ID_CONSDEL = 154
   2.198 +    ID_CONSSELECTSUB= 155
   2.199 +
   2.200 +    conflictMAX = ID_CS_START
   2.201 +
   2.202 +    def __init__(self, parent, ID):
   2.203 +        self.conflictsets = []
   2.204 +        self.parent = parent
   2.205 +        wx.Panel.__init__(self, parent, -1)
   2.206 +        #header
   2.207 +        conshdrbox = wx.StaticBox(self, -1, "")
   2.208 +        conshdrboxsizer = wx.StaticBoxSizer(conshdrbox, wx.HORIZONTAL)
   2.209 +        conshdr = wx.StaticText(self, -1, "Run-time Exclusion Rules", style=wx.ALIGN_CENTER)
   2.210 +        conshdr.SetHelpText(RunTimeExclusionPanelHelp)
   2.211 +        points = conshdr.GetFont().GetPointSize()  # get the current size
   2.212 +        hdrfont = wx.Font(points + 2, family=wx.DEFAULT,
   2.213 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD)
   2.214 +        conshdr.SetFont(hdrfont)
   2.215 +        conshdr.SetForegroundColour('ORANGERED')
   2.216 +
   2.217 +        #context help button
   2.218 +        ctxHelp = wx.ContextHelpButton(self)
   2.219 +        ctxHelp.SetHelpText("Context Help Button.")
   2.220 +        ctxHelp.SetToolTipString("Context Help: Press this button, then press any other button or panel to get help.")
   2.221 +
   2.222 +
   2.223 +        conshdrboxsizer.Add(conshdr, proportion=1, flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT, border=5)
   2.224 +        conshdrboxsizer.Add(ctxHelp, proportion=0, flag=wx.EXPAND | wx.ALL | wx.ALIGN_RIGHT, border=0)
   2.225 +        #scrolledwindow for all the run-time exclusion rules
   2.226 +        conflictspanel = wx.ScrolledWindow(self, -1, (0,0),
   2.227 +                                           style = wx.FULL_REPAINT_ON_RESIZE |
   2.228 +                                                   wx.VSCROLL )
   2.229 +        conflictspanel.SetVirtualSize((1000, 1000))
   2.230 +        conflictspanel.SetScrollRate(5,5)
   2.231 +        self.conflictsboxsizer = wx.BoxSizer(wx.VERTICAL)
   2.232 +
   2.233 +        #self.conflictsboxsizer.Fit(self)
   2.234 +        conflictspanel.SetSizer(self.conflictsboxsizer)
   2.235 +        consvbox = wx.BoxSizer(wx.VERTICAL)
   2.236 +        consvbox.Add(conshdrboxsizer, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
   2.237 +        consvbox.Add(conflictspanel, proportion=1, flag=wx.EXPAND | wx.ALL, border=5)
   2.238 +        self.SetSizer(consvbox)
   2.239 +        self.consvbox = consvbox
   2.240 +        self.conflictspanel=conflictspanel
   2.241 +
   2.242 +        self.cmenu = wx.Menu()
   2.243 +        self.cmenu.Append(self.ID_CONSRENAME, "Rename Run-time Exclusion Rule", "Rename Run-time Exclusion Rule")
   2.244 +        self.cmenu.AppendSeparator()
   2.245 +        self.cmenu.Append(self.ID_CONSDEL,    "Delete Run-time Exclusion Rule", "Delete Run-time Exclusion Rule")
   2.246 +        self.Bind(wx.EVT_MENU, self._CSRename, id=self.ID_CONSRENAME)
   2.247 +        self.Bind(wx.EVT_MENU, self._CSDelete, id=self.ID_CONSDEL)
   2.248 +
   2.249 +
   2.250 +    #Helper methods called from anywhere
   2.251 +    def New(self):
   2.252 +        #delete all run-time exclusion rules
   2.253 +        for i in self.conflictsets:
   2.254 +            i.Disable()
   2.255 +            i.Destroy()
   2.256 +        self.conflictsets = []
   2.257 +        self.conflictsboxsizer.Layout()
   2.258 +        size=self.GetSize()
   2.259 +        self.Fit()
   2.260 +        self.SetSize(size)
   2.261 +
   2.262 +
   2.263 +    def DelCSById(self, delid):
   2.264 +        #delete CS representation
   2.265 +        delpos, item = self.GetCSBox(delid)
   2.266 +        if item:
   2.267 +            self.DelCSByItem(item)
   2.268 +
   2.269 +
   2.270 +    def DelCSByItem(self, item):
   2.271 +        #delete CS representation
   2.272 +        self.conflictsets.remove(item)
   2.273 +        exists = self.conflictsboxsizer.Detach(item)
   2.274 +        if exists:
   2.275 +            item.Destroy()
   2.276 +        self.RefreshMe()
   2.277 +
   2.278 +
   2.279 +    def RefreshMe(self):
   2.280 +        size=self.parent.GetSize()
   2.281 +        self.parent.Fit()
   2.282 +        self.parent.SetSize(size)
   2.283 +
   2.284 +
   2.285 +    def GetOrgSelection(self):
   2.286 +        (tree, selection) = GetOrgsSelection()
   2.287 +        if not len(selection):
   2.288 +            dlg = wx.MessageDialog(self, 'You must select first at least one Organization/Department workload!',
   2.289 +                                   'Creating A New Run-time  Rule', wx.OK | wx.ICON_ERROR)
   2.290 +            dlg.ShowModal()
   2.291 +            dlg.Destroy()
   2.292 +            return None,None
   2.293 +        # now rewrite selection (realm.workload extension, check consistency)
   2.294 +        alist = []
   2.295 +        for i in selection:
   2.296 +            if isRealm(i):
   2.297 +                alist.append(tree.GetItemText(i))
   2.298 +            else:
   2.299 +                alist.append(tree.GetItemText(tree.GetItemParent(i))
   2.300 +                            + "." + tree.GetItemText(i))
   2.301 +
   2.302 +            if isRealm(i):
   2.303 +                for j in selection:
   2.304 +                    if tree.GetItemParent(j) == i:
   2.305 +                        violation = ("[ " + tree.GetItemText(i) + ", " +
   2.306 +                                     tree.GetItemText(i) + "." + tree.GetItemText(j) + " ]")
   2.307 +                        dlg = wx.MessageDialog(self,
   2.308 +                                               'Invalid Selection ' + violation + '.\n\n' +
   2.309 +                                               'You can only select EITHER an Organization OR specific Department!',
   2.310 +                                   'Creating A New Run-time Exclusion Rule', wx.OK | wx.ICON_ERROR)
   2.311 +                        dlg.ShowModal()
   2.312 +                        dlg.Destroy()
   2.313 +                        return None,None
   2.314 +        return (alist, selection)
   2.315 +
   2.316 +
   2.317 +    def AddConflict(self, name, types):
   2.318 +        csbox = myCSPanel(self, self.conflictMAX, name, types)
   2.319 +        self.conflictsboxsizer.Add(csbox, proportion=0, flag=wx.EXPAND | wx.ALL, border=5)
   2.320 +        self.conflictsets.append(csbox)
   2.321 +        self.conflictMAX = self.conflictMAX+3
   2.322 +        self.RefreshMe()
   2.323 +        csbox.RefreshMe()
   2.324 +
   2.325 +
   2.326 +    def GetCSBox(self, id):
   2.327 +        pos = -1
   2.328 +        i = 0
   2.329 +        while self.conflictsboxsizer.GetItem(i):
   2.330 +            item = self.conflictsboxsizer.GetItem(i).GetWindow()
   2.331 +            if ((item.cbmp.GetId() == id) or
   2.332 +                (item.add_selection.GetId() == id) or
   2.333 +                (item.del_selection.GetId() == id)):
   2.334 +                pos = i
   2.335 +                box = item
   2.336 +                break
   2.337 +            i = i +  1
   2.338 +        if pos < 0:
   2.339 +            print "Run-time Exclusion Rule Not Found ERROR!"
   2.340 +            return (None, None)
   2.341 +        else:
   2.342 +            return (pos, box)
   2.343 +
   2.344 +
   2.345 +    #bind methods
   2.346 +    def _AddNewConflict(self, event):
   2.347 +        # first get the conflicting workload types with current selection
   2.348 +        types, items = self.GetOrgSelection()
   2.349 +        if not types:
   2.350 +            return
   2.351 +        #get name for conflict set
   2.352 +        dlg = wx.TextEntryDialog(
   2.353 +            self, 'Please enter a name for the Run-time Exclusion Rule:', 'Creating A New Run-time Exclusion Rule')
   2.354 +        dlg.SetValue("")
   2.355 +        ret = dlg.ShowModal()
   2.356 +        name = dlg.GetValue()
   2.357 +        dlg.Destroy()
   2.358 +        if ret != wx.ID_OK:
   2.359 +            return
   2.360 +        self.AddConflict(name, types)
   2.361 +
   2.362 +
   2.363 +    def _OnClick(self, event):
   2.364 +        self.event = event
   2.365 +        app.win.SetStatusText("")
   2.366 +        self.PopupMenu(self.cmenu)
   2.367 +
   2.368 +
   2.369 +    def _CSRename(self, event):
   2.370 +        delpos, item = self.GetCSBox(self.event.GetId())
   2.371 +        if not item:
   2.372 +            return
   2.373 +        #allow to name the conflict set
   2.374 +        dlg = wx.TextEntryDialog(
   2.375 +            self, 'Please enter a new name for the Conflict Set:', 'Renaming A Run-time Exclusion Rule')
   2.376 +        dlg.SetValue(item.box.GetLabel())
   2.377 +        ret = dlg.ShowModal()
   2.378 +        name = dlg.GetValue()
   2.379 +        dlg.Destroy()
   2.380 +        if ret != wx.ID_OK:
   2.381 +            return
   2.382 +        item.box.SetLabel(name)
   2.383 +        item.box.SetFont(wx.Font(item.GetFont().GetPointSize(), family=wx.DEFAULT,
   2.384 +                                style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD))
   2.385 +
   2.386 +
   2.387 +    def _CSDelete(self, event):
   2.388 +        delid = self.event.GetId()
   2.389 +        self.DelCSById(delid)
   2.390 +
   2.391 +
   2.392 +    def _AddOrgSelection(self, event):
   2.393 +        addid = event.GetId()
   2.394 +        addpos, item = self.GetCSBox(addid)
   2.395 +        alist, items = self.GetOrgSelection()
   2.396 +        if not alist:
   2.397 +            return
   2.398 +        existing = []
   2.399 +        for i in range(0, item.clb.GetCount()):
   2.400 +            existing.append(item.clb.GetString(i))
   2.401 +
   2.402 +        #now make sure that we don't get realm + workload into the same CS
   2.403 +        for i in items:
   2.404 +            if isRealm(i):
   2.405 +                #ensure no workload of this realm is already in CS
   2.406 +                realm = app.win.orgs.GetItemText(i)
   2.407 +                for j in iterchildren(i):
   2.408 +                    workload = app.win.orgs.GetItemText(j)
   2.409 +                    try:
   2.410 +                        idx = existing.index (realm + "." + workload)
   2.411 +                    except:
   2.412 +                        #ok, does not exist
   2.413 +                        continue
   2.414 +                    #nok, exists already
   2.415 +                    violation = ("[ " + realm + ", " +
   2.416 +                                  realm + "." + workload + " ]")
   2.417 +                    dlg = wx.MessageDialog(self,
   2.418 +                            'Invalid Selection ' + violation + '.\n\n' +
   2.419 +                            'You can only have EITHER an Organization OR a specific Department workload\n' +
   2.420 +                            'in a single Run-time Exclusion Rule',
   2.421 +                            'Adding Orgs/Depts workloads to a Run-time Exclusion Rule',
   2.422 +                            wx.OK | wx.ICON_ERROR)
   2.423 +                    dlg.ShowModal()
   2.424 +                    dlg.Destroy()
   2.425 +                    return
   2.426 +
   2.427 +            else:
   2.428 +                #ensure realm of this workload is not in CS
   2.429 +                realm = app.win.orgs.GetItemText(app.win.orgs.GetItemParent(i))
   2.430 +                try:
   2.431 +                    idx = existing.index(realm)
   2.432 +                except:
   2.433 +                    #ok, does not exist
   2.434 +                    continue
   2.435 +                #nok, exists already
   2.436 +                violation = ("[ " + realm + "." + app.win.orgs.GetItemText(i) +
   2.437 +                                 ", " + realm + " ]")
   2.438 +                dlg = wx.MessageDialog(self,
   2.439 +                            'Invalid Selection ' + violation + '.\n\n' +
   2.440 +                            'You can only have EITHER an Organization OR a specific Department workload\n' +
   2.441 +                            'in a single Run-time Exclusion Rule',
   2.442 +                            'Adding Orgs/Depts workloads to a Run-time Exclusion Rule',
   2.443 +                            wx.OK | wx.ICON_ERROR)
   2.444 +                dlg.ShowModal()
   2.445 +                dlg.Destroy()
   2.446 +                return
   2.447 +        #check if any of the selections are already in the conflict set
   2.448 +        overlap=[]
   2.449 +        for l in alist:
   2.450 +            for e in existing:
   2.451 +                if l == e:
   2.452 +                    overlap.append(str(l))
   2.453 +        if len(overlap):
   2.454 +            if len(overlap) == 1:
   2.455 +                message = "Selected item " + str(overlap) +\
   2.456 +                    " is already in the Run-time Exclusion rule and will be ignored.\n\n Continue?"
   2.457 +            else:
   2.458 +                message = "Selected items " + str(overlap) +\
   2.459 +                    " are already in the Run-time Exclusion rule and will be ignored.\n\n Continue?"
   2.460 +            dlg = wx.MessageDialog(self,
   2.461 +                            message, 'Adding Orgs/Depts workloads to a Run-time Exclusion rule',
   2.462 +                            wx.YES | wx.NO | wx.ICON_EXCLAMATION)
   2.463 +            ret = dlg.ShowModal()
   2.464 +            dlg.Destroy()
   2.465 +            if ret != wx.ID_YES:
   2.466 +                return
   2.467 +
   2.468 +        for s in alist:
   2.469 +            try:
   2.470 +                existing.index(s)
   2.471 +            except Exception:
   2.472 +                # s not yet in list box, add it
   2.473 +                item.AddTypes([s])
   2.474 +        self.RefreshMe()
   2.475 +
   2.476 +
   2.477 +    def _DelConSelection(self, event):
   2.478 +        eventid = event.GetId()
   2.479 +        pos, item = self.GetCSBox(eventid)
   2.480 +        idtuple = item.clb.GetSelections()
   2.481 +        idlist = []
   2.482 +        for i in idtuple:
   2.483 +            idlist.append(i)
   2.484 +        #delete reverse, otherwise item mubers get messed up while deleting
   2.485 +        idlist.reverse()
   2.486 +        for i in idlist:
   2.487 +            item.clb.Delete(i)
   2.488 +        item.RefreshMe()
   2.489 +        if item.clb.GetCount() < 2:
   2.490 +            dlg = wx.MessageDialog(self,
   2.491 +                    """Run-time exclusion set has less than two types.\n\n
   2.492 +                    Do you want to delete this rule?""",
   2.493 +                    'Deleting Orgs/Depts workloads from a Run-time Exclusion rule',
   2.494 +                    wx.YES| wx.NO | wx.ICON_QUESTION)
   2.495 +            ret = dlg.ShowModal()
   2.496 +            dlg.Destroy()
   2.497 +            if ret == wx.ID_YES:
   2.498 +                self.DelCSById(eventid)
   2.499 +            return
   2.500 +        else:
   2.501 +            for i in item.clb.GetSelections():
   2.502 +                item.clb.Deselect(i)
   2.503 +        self.RefreshMe()
   2.504 +
   2.505 +
   2.506 +class myCSPanel(wx.Panel):
   2.507 +    def __init__(self, parent, ID, title, list=[]):
   2.508 +        wx.Panel.__init__(self, parent.conflictspanel, -1)
   2.509 +        self.parent = parent
   2.510 +        cspansizer = wx.BoxSizer(wx.VERTICAL)
   2.511 +        self.box = wx.StaticBox(self, -1, title)
   2.512 +        csboxsizer = wx.StaticBoxSizer(self.box, wx.HORIZONTAL)
   2.513 +        #left: type add/del
   2.514 +        typesizer = wx.BoxSizer(wx.VERTICAL)
   2.515 +        self.add_selection = wx.Button(self, ID+1, "--> Add", style=wx.BU_EXACTFIT)
   2.516 +        self.add_selection.SetToolTipString("Add Workload Selection To Run-time Exclusion rule")
   2.517 +        self.add_selection.SetHelpText(AddToExclusionButtonHelp)
   2.518 +        self.add_selection.SetForegroundColour('MEDIUMBLUE')
   2.519 +        points = self.add_selection.GetFont().GetPointSize()
   2.520 +        addfont = wx.Font(points, family=wx.DEFAULT,
   2.521 +                          style=wx.FONTSTYLE_NORMAL, weight=wx.BOLD)
   2.522 +        self.add_selection.SetFont(addfont)
   2.523 +        self.box.SetFont(addfont)
   2.524 +        typesizer.Add(self.add_selection, proportion = 0, flag = wx.EXPAND | wx.ALL,border=0)
   2.525 +        typesizer.Add((5,5))
   2.526 +        self.del_selection = wx.Button(self, ID+2, "<-- Del", style=wx.BU_EXACTFIT)
   2.527 +        self.del_selection.SetToolTipString("Delete Workload Selection From Run-time Exclusion Rule")
   2.528 +        self.del_selection.SetHelpText(DelFromExclusionButtonHelp)
   2.529 +        self.del_selection.SetForegroundColour('ORANGERED')
   2.530 +        self.del_selection.SetFont(addfont)
   2.531 +        typesizer.Add(self.del_selection, proportion = 0, flag = wx.EXPAND | wx.ALL, border=0)
   2.532 +        csboxsizer.Add(typesizer, proportion = 0, border=0)
   2.533 +        csboxsizer.Add((5,5))
   2.534 +        #middle: types
   2.535 +        self.clb = wx.ListBox(self, id=-1, choices=list,
   2.536 +                              style= wx.LB_MULTIPLE | wx.LB_SORT )
   2.537 +        self.clb.SetHelpText(ExclusionSetHelp)
   2.538 +        csboxsizer.Add(self.clb, proportion=1, flag=wx.EXPAND | wx.ALL, border=0)
   2.539 +        csboxsizer.Add((5,5))
   2.540 +        #right: Conflictset-global ops button
   2.541 +        bmpsizer = wx.BoxSizer(wx.VERTICAL)
   2.542 +        self.cbmp = buttons.GenBitmapButton(self, ID, conflict_bmp, style=wx.BU_EXACTFIT)
   2.543 +        self.cbmp.SetHelpText(ManageExclusionButtonHelp)
   2.544 +        self.cbmp.SetToolTipString("Rename/Delete\nAssociated Run-time Exclusion Rule")
   2.545 +        bmpsizer.Add(self.cbmp, proportion = 0, flag = wx.EXPAND | wx.ALL, border=0)
   2.546 +        csboxsizer.Add(bmpsizer, proportion=0, border=5)
   2.547 +        cspansizer.Add(csboxsizer,  proportion=0, flag=wx.EXPAND | wx.ALL, border=0)
   2.548 +        self.csboxsizer=csboxsizer
   2.549 +        self.cspansizer=cspansizer
   2.550 +        self.SetSizer(cspansizer)
   2.551 +        self.cbmp.Bind(wx.EVT_LEFT_DOWN, parent._OnClick, id=ID)
   2.552 +        self.add_selection.Bind(wx.EVT_BUTTON, parent._AddOrgSelection, id=ID + 1)
   2.553 +        self.del_selection.Bind(wx.EVT_BUTTON, parent._DelConSelection, id=ID + 2)
   2.554 +
   2.555 +    # append and delete an item to get rid of
   2.556 +    # the ugly vertical scroll bar on the Listbox on Linux
   2.557 +    def RefreshMe(self):
   2.558 +        x = self.clb.Append(" ")
   2.559 +        app.win.conspanel.RefreshMe()
   2.560 +        self.clb.Delete(x)
   2.561 +        self.Layout()
   2.562 +        app.win.conspanel.Layout()
   2.563 +
   2.564 +
   2.565 +    def AddTypes(self, list):
   2.566 +        for i in list:
   2.567 +            self.clb.Append(i)
   2.568 +        self.RefreshMe()
   2.569 +
   2.570 +
   2.571 +    def GetTypes(self):
   2.572 +        alist = []
   2.573 +        for i in range(0, self.clb.GetCount()):
   2.574 +            alist.append(self.clb.GetString(i))
   2.575 +        return alist
   2.576 +
   2.577 +
   2.578 +    def GetBoxName(self):
   2.579 +        return self.box.GetLabel()
   2.580 +
   2.581 +
   2.582 +    def Replace(self, oldlabel, newlabel):
   2.583 +        index = self.clb.FindString(oldlabel)
   2.584 +        if index != wx.NOT_FOUND:
   2.585 +            self.clb.SetString(index, newlabel)
   2.586 +
   2.587 +
   2.588 +    def Delete(self, label):
   2.589 +        index = self.clb.FindString(label)
   2.590 +        if index != wx.NOT_FOUND:
   2.591 +            self.clb.Delete(index)
   2.592 +
   2.593 +
   2.594 +class myHelpPanel(wx.Panel):
   2.595 +    def __init__(self, parent, ID):
   2.596 +        wx.Panel.__init__(self, parent, -1)
   2.597 +
   2.598 +
   2.599 +class ezFrame(wx.Frame):
   2.600 +
   2.601 +    ID_ABOUT  = 101
   2.602 +    ID_NEW    = 102
   2.603 +    ID_OPEN   = 103
   2.604 +    ID_SAVE   = 104
   2.605 +    ID_SAVEAS = 105
   2.606 +    ID_EXIT   = 106
   2.607 +    ID_HELP   = 107
   2.608 +
   2.609 +    ID_ITRENAME = 111
   2.610 +    ID_ITADD    = 112
   2.611 +    ID_ITDEL    = 113
   2.612 +
   2.613 +    ID_COLLAPSEALL = 121
   2.614 +    ID_EXPANDALL = 122
   2.615 +    ID_SORTALL = 123
   2.616 +
   2.617 +    ID_TRANSLATE = 131
   2.618 +
   2.619 +    ID_ORGEDT = 141
   2.620 +    ID_ORGADD = 142
   2.621 +    ID_ORGDEL = 143
   2.622 +
   2.623 +    def __init__(self, parent, ID, title):
   2.624 +        global realm_bmp, workload_bmp, conflict_bmp
   2.625 +
   2.626 +        wx.Frame.__init__(self, parent, ID, title,
   2.627 +                         wx.DefaultPosition,
   2.628 +                         wx.Size(700,450)
   2.629 +                          )
   2.630 +
   2.631 +        realm_bmp = GetIconBitmap('Organization')
   2.632 +        workload_bmp = GetIconBitmap('Department')
   2.633 +        conflict_bmp = GetIconBitmap('Conflict')
   2.634 +        self.SetHelpText(GetHelp)
   2.635 +        self.orgfilename = None
   2.636 +        self.CreateStatusBar()
   2.637 +        self.SetStatusText("")
   2.638 +        self.bkg = wx.Panel(self)
   2.639 +
   2.640 +        self.orgswin =  wx.SashLayoutWindow(
   2.641 +            self.bkg, -1, wx.DefaultPosition, (300, 150),wx.SW_3DSASH | wx.SW_BORDER)
   2.642 +
   2.643 +        self.orgswin.SetDefaultSize((300,150))
   2.644 +        self.orgswin.SetOrientation(wx.LAYOUT_VERTICAL)
   2.645 +        self.orgswin.SetAlignment(wx.LAYOUT_LEFT)
   2.646 +        self.orgspanel = OrgsPanel(self.orgswin, -1)
   2.647 +        self.orgs = self.orgspanel.orgs
   2.648 +
   2.649 +        self.realm_menu = wx.Menu()
   2.650 +        self.realm_menu.Append(self.ID_ORGADD, "Add Department\tctrl-a", "Add Department Workload")
   2.651 +        self.realm_menu.AppendSeparator()
   2.652 +        self.realm_menu.AppendSeparator()
   2.653 +        self.realm_menu.Append(self.ID_ORGEDT, "Rename Organization\tctrl-r", "Rename Organization Workload")
   2.654 +        self.realm_menu.Append(self.ID_ORGDEL, "Delete Organization\tctrl-d", "Delete Organization Workload")
   2.655 +        self.realm_menu.Bind(wx.EVT_MENU, self.orgs._OrgEdt, id= self.ID_ORGEDT)
   2.656 +        self.realm_menu.Bind(wx.EVT_MENU, self.orgs._OrgWAdd, id= self.ID_ORGADD)
   2.657 +        self.realm_menu.Bind(wx.EVT_MENU, self._ItemDel, id=self.ID_ORGDEL)
   2.658 +
   2.659 +        self.workload_menu = wx.Menu()
   2.660 +        self.workload_menu.Append(self.ID_ORGEDT, "Rename Department\tctrl-r", "Rename Department Workload")
   2.661 +        self.workload_menu.Append(self.ID_ORGDEL, "Delete Department\tctrl-d", "Delete Department Workload")
   2.662 +        self.workload_menu.Bind(wx.EVT_MENU, self.orgs._OrgEdt, id= self.ID_ORGEDT)
   2.663 +        self.workload_menu.Bind(wx.EVT_MENU, self._ItemDel, id=self.ID_ORGDEL)
   2.664 +
   2.665 +        self.orgs.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self._OrgRightClick)
   2.666 +        self.orgs.Bind(wx.EVT_TREE_SEL_CHANGED, self._OrgSelectionChanged)
   2.667 +
   2.668 +        self.conswin =  wx.SashLayoutWindow(
   2.669 +            self.bkg, -1, wx.DefaultPosition, (300, 150),
   2.670 +            #wx.NO_BORDER | wx.SW_3D
   2.671 +            wx.SW_3DSASH | wx.SW_BORDER
   2.672 +            )
   2.673 +        self.conswin.SetDefaultSize((300,150))
   2.674 +        self.conswin.SetOrientation(wx.LAYOUT_VERTICAL)
   2.675 +        self.conswin.SetAlignment(wx.LAYOUT_RIGHT)
   2.676 +        self.conswin.SetSashVisible(wx.SASH_LEFT, True)
   2.677 +        self.conswin.SetSashVisible(wx.SASH_RIGHT, False)
   2.678 +
   2.679 +        #right tree control for non-concurrent workload execution
   2.680 +        self.conspanel = ConsPanel(self.conswin, -1)
   2.681 +        self.conspanel.RefreshMe()
   2.682 +        self.bkg.Bind(wx.EVT_SASH_DRAGGED_RANGE, self._OnSashDrag, id=self.conswin.GetId(),
   2.683 +                      id2=self.conswin.GetId())
   2.684 +        self.bkg.Bind(wx.EVT_SIZE, self._OnSize)
   2.685 +
   2.686 +        # Main Menu
   2.687 +        #      -File
   2.688 +        fmenu = wx.Menu()
   2.689 +        fmenu.Append(self.ID_OPEN, "Open Workload Definition...\tctrl-o", "Open current workload definition")
   2.690 +        fmenu.Append(self.ID_SAVE, "Save Workload Definition\tctrl-s", "Save workload defintion")
   2.691 +        fmenu.Append(self.ID_SAVEAS, "Save Workload Defintion as...\talt-s", "Save into new file")
   2.692 +        fmenu.AppendSeparator()
   2.693 +        fmenu.Append(self.ID_TRANSLATE, "Save as Xen ACM Security Policy ...\talt-t", "Create Xen ACM security policy")
   2.694 +        fmenu.AppendSeparator()
   2.695 +        fmenu.Append(self.ID_NEW, "New\tctrl-n", "Create a new oganization definition")
   2.696 +        fmenu.AppendSeparator()
   2.697 +        fmenu.Append(self.ID_EXIT, "Exit\tctrl-x", "Terminate the program")
   2.698 +        self.fmenu = fmenu
   2.699 +
   2.700 +        #      -Edit
   2.701 +        emenu = wx.Menu()
   2.702 +        emenu.Append(self.ID_ITRENAME, "Rename\tctrl-r", "Rename Selected Organization/Department")
   2.703 +        emenu.Append(self.ID_ITADD, "Add\tctrl-a", "Add Child to Selected Organization/Department")
   2.704 +        emenu.Append(self.ID_ITDEL, "Delete\tctrl-d", "Delete Selected Organization/Department")
   2.705 +        self.emenu = emenu
   2.706 +        #      -Help
   2.707 +        hmenu = wx.Menu()
   2.708 +        hmenu.Append(self.ID_HELP, "Step-By-Step Help\tctrl-h", "More information about this program")
   2.709 +        hmenu.Append(self.ID_ABOUT, "About", "More information about this program")
   2.710 +        self.hmenu = hmenu
   2.711 +
   2.712 +        #      -View
   2.713 +        vmenu = wx.Menu()
   2.714 +        vmenu.Append(self.ID_SORTALL, "Sort All", "Sort Entries In All Trees")
   2.715 +        vmenu.Append(self.ID_COLLAPSEALL, "Collapse All\tctrl-c", "Collapse All Trees")
   2.716 +        vmenu.Append(self.ID_EXPANDALL, "Expand All\tctrl-e", "Expand All Trees")
   2.717 +        self.vmenu = vmenu
   2.718 +
   2.719 +        menuBar = wx.MenuBar()
   2.720 +        menuBar.Append(fmenu, "&File");
   2.721 +        menuBar.Append(emenu, "&Edit");
   2.722 +        menuBar.Append(vmenu, "&View");
   2.723 +        menuBar.Append(hmenu, "&Help");
   2.724 +
   2.725 +        self.SetMenuBar(menuBar)
   2.726 +
   2.727 +        self.Bind(wx.EVT_MENU, self._OpenSpec,  id=self.ID_OPEN)
   2.728 +        self.Bind(wx.EVT_MENU, self._SaveSpec,  id=self.ID_SAVE)
   2.729 +        self.Bind(wx.EVT_MENU, self._SaveAsSpec,id=self.ID_SAVEAS)
   2.730 +        self.Bind(wx.EVT_MENU, self._NewSpec,   id=self.ID_NEW)
   2.731 +        self.Bind(wx.EVT_MENU, self._TimeToQuit,id=self.ID_EXIT)
   2.732 +        self.Bind(wx.EVT_MENU, self._TranslateSpec, id=self.ID_TRANSLATE)
   2.733 +
   2.734 +        self.Bind(wx.EVT_MENU, self._ItemRename, id=self.ID_ITRENAME)
   2.735 +        self.Bind(wx.EVT_MENU, self._ItemAdd,    id=self.ID_ITADD)
   2.736 +        self.Bind(wx.EVT_MENU, self._ItemDel,    id=self.ID_ITDEL)
   2.737 +
   2.738 +        self.Bind(wx.EVT_MENU, self._SortAll,    id=self.ID_SORTALL)
   2.739 +        self.Bind(wx.EVT_MENU, self._CollapseAll,id=self.ID_COLLAPSEALL)
   2.740 +        self.Bind(wx.EVT_MENU, self._ExpandAll,  id=self.ID_EXPANDALL)
   2.741 +
   2.742 +        self.Bind(wx.EVT_MENU, self._Help, id=self.ID_HELP)
   2.743 +        self.Bind(wx.EVT_MENU, self._OnAbout, id=self.ID_ABOUT)
   2.744 +        self.Bind(wx.EVT_CLOSE, self._TimeToQuit)
   2.745 +
   2.746 +
   2.747 +    def RefreshMe(self):
   2.748 +        size=self.GetSize()
   2.749 +        self.Fit()
   2.750 +        self.SetSize(size)
   2.751 +
   2.752 +    #helper methods
   2.753 +    def Load(self, file):
   2.754 +        self.orgfilename = file
   2.755 +        dictname = 'ezpolicy'
   2.756 +        d = {}
   2.757 +        # read in the config file
   2.758 +        globs = {}
   2.759 +        locs = {}
   2.760 +        execfile(file, globs, locs)
   2.761 +        for (k, v) in locs.items():
   2.762 +            if k == dictname:
   2.763 +                d = v
   2.764 +                break
   2.765 +        dict2org(d)
   2.766 +        self.orgspanel.orgs.UnselectAll()
   2.767 +        self.SetTitle("ezPolicy: " + self.orgfilename)
   2.768 +        self._ExpandAll(None)
   2.769 +
   2.770 +
   2.771 +    def Save(self, file):
   2.772 +        dictname = 'ezpolicy'
   2.773 +        d = org2dict()
   2.774 +        fd = open(file, "w")
   2.775 +        fd.write(dictname + " = ")
   2.776 +        fd.write(str(d))
   2.777 +        fd.close()
   2.778 +
   2.779 +
   2.780 +    def New(self):
   2.781 +        self.orgspanel.orgs.DeleteChildren(self.orgspanel.orgs.GetRootItem())
   2.782 +        self.conspanel.New()
   2.783 +
   2.784 +
   2.785 +    def LabelReplaceInConflictsets(self, item, oldlabel, newlabel):
   2.786 +        if isRealm(item):
   2.787 +            replace = [[ oldlabel, newlabel]]
   2.788 +            for i in iterchildren(item):
   2.789 +                replace.append([(oldlabel + "." + self.orgs.GetItemText(i)),
   2.790 +                                (newlabel + "." + self.orgs.GetItemText(i))])
   2.791 +        else:
   2.792 +            parent = self.orgs.GetItemParent(item)
   2.793 +            replace =   [
   2.794 +                            [(self.orgs.GetItemText(parent) + "." + oldlabel),
   2.795 +                             (self.orgs.GetItemText(parent) + "." + newlabel)]
   2.796 +                        ]
   2.797 +        for r in replace:
   2.798 +            for i in self.conspanel.conflictsets:
   2.799 +                if r[0] in i.GetTypes():
   2.800 +                    i.Replace(r[0], r[1])
   2.801 +
   2.802 +
   2.803 +    def OrgDelItem(self, item):
   2.804 +        label = self.orgs.GetItemText(item)
   2.805 +        if isRealm(item):
   2.806 +            delset = [label]
   2.807 +            for i in iterchildren(item):
   2.808 +                delset.append(label + "." + self.orgs.GetItemText(i))
   2.809 +        else:
   2.810 +            parent = self.orgs.GetItemParent(item)
   2.811 +            delset = [self.orgs.GetItemText(parent) + "." + label]
   2.812 +        for i in self.conspanel.conflictsets:
   2.813 +            for l in delset:
   2.814 +                i.Delete(l)
   2.815 +        #need to run in reverse order when deleting items
   2.816 +        rev = []
   2.817 +        for i in self.conspanel.conflictsets:
   2.818 +            rev.append(i)
   2.819 +        rev.reverse()
   2.820 +        for i in rev:
   2.821 +            if len(i.GetTypes()) < 1:
   2.822 +                self.conspanel.DelCSByItem(i)
   2.823 +        self.orgs.Delete(item)
   2.824 +
   2.825 +
   2.826 +    def _OnSashDrag(self, event):
   2.827 +        if event.GetDragStatus() == wx.SASH_STATUS_OUT_OF_RANGE:
   2.828 +            return
   2.829 +        w = event.GetEventObject()
   2.830 +        if w is self.conswin:
   2.831 +            self.conswin.SetDefaultSize((event.GetDragRect().width, 1000))
   2.832 +        wx.LayoutAlgorithm().LayoutWindow(self.bkg, self.orgswin)
   2.833 +        self.RefreshMe()
   2.834 +
   2.835 +
   2.836 +    def _OnSize(self, event):
   2.837 +        wx.LayoutAlgorithm().LayoutWindow(self.bkg, self.orgswin)
   2.838 +
   2.839 +
   2.840 +    def _OrgSelectionChanged(self, event):
   2.841 +        self.orgs.event = event
   2.842 +        item = self.orgs.event.GetItem()
   2.843 +        if not item.IsOk() or not self.orgs.IsSelected(item):
   2.844 +            self.emenu.Enable(self.ID_ITRENAME, False)
   2.845 +            self.emenu.Enable(self.ID_ITADD, False)
   2.846 +            self.emenu.Enable(self.ID_ITDEL, False)
   2.847 +            return
   2.848 +        self.SetStatusText("")
   2.849 +        #enable/disable edit menu functions
   2.850 +        if isRealm(item):
   2.851 +            self.emenu.Enable(self.ID_ITRENAME, True)
   2.852 +            self.emenu.Enable(self.ID_ITADD, True)
   2.853 +            self.emenu.Enable(self.ID_ITDEL, True)
   2.854 +        elif isWorkload(item):
   2.855 +            self.emenu.Enable(self.ID_ITRENAME, True)
   2.856 +            self.emenu.Enable(self.ID_ITADD, False)
   2.857 +            self.emenu.Enable(self.ID_ITDEL, True)
   2.858 +        if len(self.orgs.GetSelections()) > 1:
   2.859 +            self.emenu.Enable(self.ID_ITRENAME, False)
   2.860 +            self.emenu.Enable(self.ID_ITADD, False)
   2.861 +
   2.862 +
   2.863 +    def _OrgRightClick(self, event):
   2.864 +        self.SetStatusText("")
   2.865 +        self.orgs.event = event
   2.866 +        item = self.orgs.event.GetItem()
   2.867 +        #del not permitted on root items
   2.868 +        if isWorkload(item):
   2.869 +            self.workload_menu.Enable(self.ID_ORGDEL, True)
   2.870 +            self.workload_menu.Enable(self.ID_ORGEDT, True)
   2.871 +            if len(self.orgs.GetSelections()) > 1:
   2.872 +                self.workload_menu.Enable(self.ID_ORGEDT, False)
   2.873 +            self.PopupMenu(self.workload_menu)
   2.874 +        else:
   2.875 +            self.realm_menu.Enable(self.ID_ORGDEL, True)
   2.876 +            self.realm_menu.Enable(self.ID_ORGEDT, True)
   2.877 +            self.realm_menu.Enable(self.ID_ORGADD, True)
   2.878 +            if len(self.orgs.GetSelections()) > 1:
   2.879 +                self.realm_menu.Enable(self.ID_ORGEDT, False)
   2.880 +                self.realm_menu.Enable(self.ID_ORGADD, False)
   2.881 +            self.PopupMenu(self.realm_menu)
   2.882 +
   2.883 +
   2.884 +    def _OpenSpec(self, event):
   2.885 +        filediag = wx.FileDialog(self, defaultFile="myspec.wld",
   2.886 +                                wildcard="*.wld", style=wx.OPEN | wx.OVERWRITE_PROMPT,
   2.887 +                                message="Select Workload Definition file name")
   2.888 +        ret = filediag.ShowModal()
   2.889 +        name = filediag.GetPath()
   2.890 +        filediag.Destroy()
   2.891 +        if ret not in [wx.ID_OK]:
   2.892 +            return
   2.893 +        self.orgfilename = name
   2.894 +        self.Load(self.orgfilename)
   2.895 +        self.SetTitle("ezPolicy: " + self.orgfilename)
   2.896 +
   2.897 +
   2.898 +    def _SaveSpec(self, event):
   2.899 +        if not self.orgfilename:
   2.900 +            filediag = wx.FileDialog(self, defaultFile="myspec.wld",
   2.901 +                                    wildcard="*.wld", style=wx.SAVE | wx.OVERWRITE_PROMPT,
   2.902 +                                    message="Select Workload Definition file name")
   2.903 +            ret = filediag.ShowModal()
   2.904 +            name = filediag.GetPath()
   2.905 +            filediag.Destroy()
   2.906 +            if ret not in [wx.ID_OK]:
   2.907 +                return
   2.908 +            self.orgfilename = name
   2.909 +        self.Save(self.orgfilename)
   2.910 +        self.SetTitle("ezPolicy: " + self.orgfilename)
   2.911 +
   2.912 +
   2.913 +    def _SaveAsSpec(self, event):
   2.914 +        if not self.orgfilename:
   2.915 +            self.orgfilename = "DEFAULT.wld"
   2.916 +        filediag = wx.FileDialog(self, defaultFile=self.orgfilename,
   2.917 +                                wildcard="*.wld", style=wx.SAVE | wx.OVERWRITE_PROMPT,
   2.918 +                                message="Select Workload Definition file name")
   2.919 +        ret = filediag.ShowModal()
   2.920 +        name = filediag.GetPath()
   2.921 +        filediag.Destroy()
   2.922 +        if ret not in [wx.ID_OK]:
   2.923 +            return
   2.924 +        self.orgfilename = name
   2.925 +        self.Save(self.orgfilename)
   2.926 +        self.SetTitle("ezPolicy: " + self.orgfilename)
   2.927 +
   2.928 +
   2.929 +    def _NewSpec(self, event):
   2.930 +        self.orgfilename = None
   2.931 +        #reset trees etc
   2.932 +        self.New()
   2.933 +        self.SetTitle("ezPolicy: *New File*")
   2.934 +
   2.935 +
   2.936 +    def _TranslateSpec(self, event):
   2.937 +        policyname = transInfo()
   2.938 +        if not policyname:
   2.939 +            return
   2.940 +        path="/etc/xen/acm-security/policies/"
   2.941 +        nameparts=string.split(policyname, ".")
   2.942 +        if len(nameparts) > 1:
   2.943 +            path = path + "/".join(nameparts[0:len(nameparts)-1])
   2.944 +        deffile = nameparts[len(nameparts) - 1] + "-security_policy.xml"
   2.945 +        filediag = wx.FileDialog(self, defaultDir=path, defaultFile=deffile,
   2.946 +                                wildcard="*.xml", message="Select Policy File Name",
   2.947 +                                style=wx.SAVE | wx.OVERWRITE_PROMPT)
   2.948 +        ret = filediag.ShowModal()
   2.949 +        filename = filediag.GetPath()
   2.950 +        filediag.Destroy()
   2.951 +        if ret not in [wx.ID_OK]:
   2.952 +            return
   2.953 +        #translate data into default policy
   2.954 +        timestamp = time.asctime()
   2.955 +        d = org2dict()
   2.956 +        types = []
   2.957 +        for i in d['orgs']:
   2.958 +            types.append(str(i[0]))
   2.959 +            for j in i[1]:
   2.960 +                types.append(str(i[0]) + "." + str(j))
   2.961 +        f = open(filename, "w")
   2.962 +        printPolicyHeader (f, policyname, timestamp)
   2.963 +        printPolicy(f, types, d['cons'])
   2.964 +        printLabels(f, d, types)#, d['cons'])
   2.965 +        printTrailer(f)
   2.966 +        f.close()
   2.967 +
   2.968 +
   2.969 +    def _ItemRename(self, event):
   2.970 +        #ensure only 1 item is selected
   2.971 +        sels = self.orgs.GetSelections()
   2.972 +        if len(sels) != 1:
   2.973 +            return
   2.974 +        self.orgs.OrgEdt(sels[0])
   2.975 +
   2.976 +
   2.977 +    def _ItemAdd(self, event):
   2.978 +        #ensure only 1 item is selected + add figure
   2.979 +        sels = self.orgs.GetSelections()
   2.980 +        if len(sels) != 1:
   2.981 +            return
   2.982 +        self.orgs.OrgWAdd(sels[0])
   2.983 +
   2.984 +
   2.985 +    def _ItemDel(self, event):
   2.986 +        sels = self.orgs.GetSelections()
   2.987 +        for i in sels:
   2.988 +            self.OrgDelItem(i)
   2.989 +
   2.990 +
   2.991 +    def _CollapseAll(self, event):
   2.992 +        for i in iterchildren(self.orgs.GetRootItem()):
   2.993 +            self.orgs.Collapse(i)
   2.994 +
   2.995 +
   2.996 +    def _ExpandAll(self, event):
   2.997 +        for i in iterchildren(self.orgs.GetRootItem()):
   2.998 +            self.orgs.Expand(i)
   2.999 +
  2.1000 +
  2.1001 +    def _SortAll(self, event):
  2.1002 +        #would be nice to also sort the organizations
  2.1003 +        for i in iterchildren(self.orgs.GetRootItem()):
  2.1004 +            if self.orgs.GetChildrenCount(i) > 0:
  2.1005 +                self.orgs.SortChildren(i)
  2.1006 +
  2.1007 +
  2.1008 +    def _OnAbout(self, event):
  2.1009 +        dlg = wx.MessageDialog(self,
  2.1010 +                               "This program helps you to define the structure\n"
  2.1011 +                               "of organizations and their departments.\n\n"
  2.1012 +                               "It translates this \'Workload Definition\' into\n"
  2.1013 +                               "a simple workload protection policy for the\n"
  2.1014 +                               "Xen Access Control Module.\n\n\n"
  2.1015 +                               "Copyright (c) 2006: IBM Corporation\n"
  2.1016 +                               "Author:\nReiner Sailer <sailer@us.ibm.com>",
  2.1017 +                              "About Me", wx.OK | wx.ICON_INFORMATION)
  2.1018 +        dlg.ShowModal()
  2.1019 +        dlg.Destroy()
  2.1020 +
  2.1021 +
  2.1022 +    def _Help(self, event):
  2.1023 +        hpopup = wx.Frame(self,-1, "HELP: Creating a Xen Security Policy in 3 Steps" )
  2.1024 +        HelpHtmlWindow(hpopup, -1)
  2.1025 +        hpopup.SetSize((650,650))
  2.1026 +        hpopup.Show(True)
  2.1027 +
  2.1028 +
  2.1029 +    def _TimeToQuit(self, event):
  2.1030 +        self.Bind(wx.EVT_CLOSE, None)
  2.1031 +        self.orgs.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, None)
  2.1032 +        self.orgs.Bind(wx.EVT_TREE_SEL_CHANGED, None)
  2.1033 +        self.Close(True)
  2.1034 +
  2.1035 +
  2.1036 +class ezApp(wx.App):
  2.1037 +
  2.1038 +    def OnInit(self):
  2.1039 +        self.win = ezFrame(None, -1, title="EZ Workload Protection Policy Tool")
  2.1040 +        self.win.Show(True)
  2.1041 +        self.SetTopWindow(self.win)
  2.1042 +        return True
  2.1043 +
  2.1044 +
  2.1045 +    def Load(self, file):
  2.1046 +        self.win.Load(file)
  2.1047 +
  2.1048 +
  2.1049 +    def New(self):
  2.1050 +        self.win.New()
  2.1051 +
  2.1052 +
  2.1053 +def isRealm(it):
  2.1054 +    if not it:
  2.1055 +        return False
  2.1056 +    return (app.win.orgspanel.orgs.GetItemParent(it) == app.win.orgspanel.orgs.GetRootItem())
  2.1057 +
  2.1058 +
  2.1059 +def isWorkload(it):
  2.1060 +    if not it or not app.win.orgs.GetItemParent(it):
  2.1061 +        return False
  2.1062 +    return (app.win.orgspanel.orgs.GetItemParent(app.win.orgspanel.orgs.GetItemParent(it))
  2.1063 +            == app.win.orgspanel.orgs.GetRootItem())
  2.1064 +
  2.1065 +
  2.1066 +def GetOrgsSelection():
  2.1067 +        return (app.win.orgspanel.orgs, app.win.orgspanel.orgs.GetSelections())
  2.1068 +
  2.1069 +
  2.1070 +def transInfo():
  2.1071 +    info = wx.TextEntryDialog(app.win, message="POLICYNAME",
  2.1072 +                              caption="Translate: Creating The Xen/ACM Policy")
  2.1073 +    ret = info.ShowModal()
  2.1074 +    name = info.GetValue()
  2.1075 +    info.Destroy()
  2.1076 +    if ret in [wx.ID_OK]:
  2.1077 +        return name
  2.1078 +    return None
  2.1079 +
  2.1080 +
  2.1081 +def iterchildren(node):
  2.1082 +    cid, citem = app.win.orgspanel.orgs.GetFirstChild(node)
  2.1083 +    while cid.IsOk():
  2.1084 +        yield cid
  2.1085 +        cid, citem = app.win.orgspanel.orgs.GetNextChild(node, citem)
  2.1086 +
  2.1087 +
  2.1088 +def dict2org(d):
  2.1089 +    # release old structure
  2.1090 +    app.New()
  2.1091 +    # fill them with dict content
  2.1092 +    for i in d['orgs']:
  2.1093 +        orgnode = app.win.orgspanel.orgs.AppendItem(app.win.orgspanel.orgs.GetRootItem(), text=i[0])
  2.1094 +        app.win.orgspanel.orgs.SetItemBold(orgnode, True)
  2.1095 +        app.win.orgspanel.orgs.SetItemImage(orgnode, realm_icon, wx.TreeItemIcon_Normal)
  2.1096 +        for j in i[1]:
  2.1097 +            wlnode = app.win.orgspanel.orgs.AppendItem(orgnode, text=j)
  2.1098 +            app.win.orgspanel.orgs.SetItemImage(wlnode, workload_icon, wx.TreeItemIcon_Normal)
  2.1099 +    for i in d['cons']:
  2.1100 +        app.win.conspanel.AddConflict(i[0], i[1])
  2.1101 +
  2.1102 +
  2.1103 +def org2dict():
  2.1104 +    global app
  2.1105 +    dic = {}
  2.1106 +    o= []
  2.1107 +    for i in iterchildren(app.win.orgs.GetRootItem()):
  2.1108 +        d = []
  2.1109 +        for j in iterchildren(i):
  2.1110 +            d.append(str(app.win.orgspanel.orgs.GetItemText(j)))
  2.1111 +        o.append([str(app.win.orgspanel.orgs.GetItemText(i)) , d])
  2.1112 +    dic['orgs'] = o
  2.1113 +    c=[]
  2.1114 +    for i in app.win.conspanel.conflictsets:
  2.1115 +        c.append([i.GetBoxName() , i.GetTypes()])
  2.1116 +    dic['cons'] = c
  2.1117 +    return dic
  2.1118 +
  2.1119 +
  2.1120 +def dict_read(dictname, filename):
  2.1121 +    """Loads <filename> and returns the dictionary named <dictname> from
  2.1122 +       the file.
  2.1123 +    """
  2.1124 +    dic = {}
  2.1125 +
  2.1126 +    # read in the config file
  2.1127 +    globs = {}
  2.1128 +    locs = {}
  2.1129 +    execfile(filename, globs, locs)
  2.1130 +
  2.1131 +    for (k, v) in locs.items():
  2.1132 +        if k == dictname:
  2.1133 +            dic = v
  2.1134 +            break
  2.1135 +    return dic
  2.1136 +
  2.1137 +#==================== Policy Generation/Translation functions
  2.1138 +
  2.1139 +def printPolicyHeader (fd, policyname, timestamp):
  2.1140 +    fd.write( """<?xml version=\"1.0\" encoding=\"UTF-8\"?>
  2.1141 +<!-- Auto-generated by ezPolicy        -->
  2.1142 +<SecurityPolicyDefinition xmlns=\"http://www.ibm.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.ibm.com ../../security_policy.xsd \">
  2.1143 +    <PolicyHeader>
  2.1144 +        <PolicyName>%s</PolicyName>
  2.1145 +        <Date>%s</Date>
  2.1146 +    </PolicyHeader>
  2.1147 +""" % (policyname, timestamp))
  2.1148 +
  2.1149 +
  2.1150 +
  2.1151 +def printPolicy(fd, types, cons):
  2.1152 +    fd.write("""
  2.1153 +    <SimpleTypeEnforcement>
  2.1154 +        <SimpleTypeEnforcementTypes>
  2.1155 +            <Type>SystemManagement</Type>\n""")
  2.1156 +
  2.1157 +    # add dynamically created type definitions org.dept
  2.1158 +    for i in types:
  2.1159 +        fd.write("""            <Type>%s</Type>\n""" % i)
  2.1160 +
  2.1161 +    fd.write("""        </SimpleTypeEnforcementTypes>
  2.1162 +    </SimpleTypeEnforcement>
  2.1163 +
  2.1164 +    <ChineseWall priority="PrimaryPolicyComponent">
  2.1165 +        <ChineseWallTypes>
  2.1166 +            <Type>SystemManagement</Type>\n""")
  2.1167 +
  2.1168 +    #add dinamically created cw types
  2.1169 +    for i in types:
  2.1170 +        fd.write("""            <Type>%s</Type>\n""" % i)
  2.1171 +
  2.1172 +    fd.write("""        </ChineseWallTypes>\n\n""")
  2.1173 +
  2.1174 +    if len(cons):
  2.1175 +        fd.write("""        <ConflictSets>\n""")
  2.1176 +        for i in cons:
  2.1177 +            if len(i[1]) < 2:
  2.1178 +                print "Ignoring Run-time exclusion set %s (less than 2 types}" % i[0]
  2.1179 +                continue
  2.1180 +            #name is optional but must be set
  2.1181 +            if i[0]:
  2.1182 +                rer_name = str(i[0])
  2.1183 +            else:
  2.1184 +                rer_name = str("RER")
  2.1185 +            fd.write("""            <Conflict name=\"%s\">\n""" % rer_name)
  2.1186 +            for j in i[1]:
  2.1187 +                fd.write("""                <Type>%s</Type>\n""" % str(j))
  2.1188 +            fd.write("""            </Conflict>\n""")
  2.1189 +        fd.write("""       </ConflictSets>\n""")
  2.1190 +
  2.1191 +    fd.write("""    </ChineseWall>\n\n""")
  2.1192 +
  2.1193 +
  2.1194 +
  2.1195 +def printLabels(fd, d, types): #, cons):
  2.1196 +    fd.write( """    <SecurityLabelTemplate>
  2.1197 +        <SubjectLabels bootstrap=\"SystemManagement\">""")
  2.1198 +
  2.1199 +    # create default boot label for dom0
  2.1200 +    fd.write("""\n            <VirtualMachineLabel>
  2.1201 +                <Name>SystemManagement</Name>
  2.1202 +                <SimpleTypeEnforcementTypes>
  2.1203 +                    <Type>SystemManagement</Type>\n""")
  2.1204 +    # add dynamically created type definitions org.dept
  2.1205 +    for i in types:
  2.1206 +        fd.write("""                    <Type>%s</Type>\n""" % i)
  2.1207 +
  2.1208 +    fd.write("""                </SimpleTypeEnforcementTypes>
  2.1209 +                <ChineseWallTypes>
  2.1210 +                    <Type>SystemManagement</Type>
  2.1211 +                </ChineseWallTypes>
  2.1212 +            </VirtualMachineLabel>\n""")
  2.1213 +
  2.1214 +    # create one Udom label for each type ste type
  2.1215 +    for i in d['orgs']:
  2.1216 +        organization = i[0]
  2.1217 +        fd.write("""\n            <VirtualMachineLabel>
  2.1218 +                <Name>%s</Name>
  2.1219 +                <SimpleTypeEnforcementTypes>
  2.1220 +                    <Type>%s</Type>
  2.1221 +                </SimpleTypeEnforcementTypes>
  2.1222 +                <ChineseWallTypes>
  2.1223 +                    <Type>%s</Type>
  2.1224 +                </ChineseWallTypes>
  2.1225 +            </VirtualMachineLabel>\n""" % (organization, organization, organization))
  2.1226 +        for j in i[1]:
  2.1227 +            workload = organization + "." + j
  2.1228 +            fd.write("""\n            <VirtualMachineLabel>
  2.1229 +                <Name>%s</Name>
  2.1230 +                <SimpleTypeEnforcementTypes>
  2.1231 +                    <Type>%s</Type>
  2.1232 +                </SimpleTypeEnforcementTypes>
  2.1233 +                <ChineseWallTypes>
  2.1234 +                    <Type>%s</Type>
  2.1235 +                    <Type>%s</Type>
  2.1236 +                </ChineseWallTypes>
  2.1237 +            </VirtualMachineLabel>\n""" % (workload, workload, organization , workload))
  2.1238 +
  2.1239 +    fd.write("""        </SubjectLabels>\n\n""")
  2.1240 +
  2.1241 +    #create resource labels for each type
  2.1242 +    fd.write("""        <ObjectLabels>""")
  2.1243 +    for i in ['SystemManagement'] + types:
  2.1244 +        fd.write("""\n            <ResourceLabel>
  2.1245 +                <Name>%s</Name>
  2.1246 +                <SimpleTypeEnforcementTypes>
  2.1247 +                    <Type>%s</Type>
  2.1248 +                </SimpleTypeEnforcementTypes>
  2.1249 +            </ResourceLabel>\n""" % (i, i))
  2.1250 +    fd.write("""        </ObjectLabels>
  2.1251 +    </SecurityLabelTemplate>\n""")
  2.1252 +
  2.1253 +def printTrailer(fd):
  2.1254 +    fd.write( """</SecurityPolicyDefinition>\n""")
  2.1255 +
  2.1256 +#============== the icons/bitmaps ======================================
  2.1257 +# to ensure the program runs anywhere, we include the buttons right here
  2.1258 +# while this makes the file even bigger, it also makes it easier to use
  2.1259 +import cStringIO
  2.1260 +
  2.1261 +def GetIconBitmap(name):
  2.1262 +    return wx.BitmapFromImage(GetIconImage(name))
  2.1263 +
  2.1264 +def GetIconImage(name):
  2.1265 +    if name == 'Organization':
  2.1266 +        iostream = cStringIO.StringIO(GetOrganizationIconData())
  2.1267 +    elif name == 'Department':
  2.1268 +        iostream = cStringIO.StringIO(GetDepartmentIconData())
  2.1269 +    elif name == 'Conflict':
  2.1270 +        iostream = cStringIO.StringIO(GetConflictIconData())
  2.1271 +    else:
  2.1272 +        sys.exit("UNKNOWN ICON NAME")
  2.1273 +    return wx.ImageFromStream(iostream)
  2.1274 +
  2.1275 +def GetOrganizationIconData():
  2.1276 +    return \
  2.1277 +'\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\
  2.1278 +\x00\x00\x00\x10\x00\x00\x00\x11\x08\x02\x00\x00\x00\x5b\xcd\xbb\
  2.1279 +\x93\x00\x00\x00\x03\x73\x42\x49\x54\x08\x08\x08\xdb\xe1\x4f\xe0\
  2.1280 +\x00\x00\x02\x7b\x49\x44\x41\x54\x28\x91\x5d\xd1\xcb\x4f\x13\x51\
  2.1281 +\x14\x06\xf0\x73\x1f\x74\x3a\x33\x9d\x96\x87\x0a\x14\x30\x3c\xd4\
  2.1282 +\x60\x34\xf1\xb1\x70\xa5\x26\x2e\xfc\x87\x4d\xdc\x18\x17\x26\x08\
  2.1283 +\x26\x44\x01\xc1\x07\x10\x52\x1e\x96\xb6\x94\x4a\x87\x0e\x33\x73\
  2.1284 +\xef\xdc\x7b\xcf\x71\x01\x31\x81\x6f\x73\x36\xe7\xb7\xf8\xf2\x31\
  2.1285 +\x22\x82\xab\x50\x51\x68\xa5\xd2\x6e\x77\xbf\xdd\xf8\x36\x52\x1b\
  2.1286 +\x5f\x78\xfc\xc6\x0f\x6b\x70\x3d\xf2\xea\x97\x28\x8e\xbb\xfd\x7e\
  2.1287 +\xd7\xb9\xb4\x3e\xe9\xe3\x99\x1d\x34\x3f\x34\xb9\xaa\x2f\xbe\x0d\
  2.1288 +\x2a\xa3\x8c\xb1\xff\x80\x5f\x1e\x63\x4c\x9a\x1e\x23\xaa\x24\xd1\
  2.1289 +\x8c\x91\xe0\xae\x04\xb1\xed\x7e\x6a\xff\x7e\x7f\x11\xb7\x01\xe8\
  2.1290 +\x26\x90\x52\x02\x98\x30\xac\xf8\x7e\x95\x88\x13\x5a\x0e\x4e\xe0\
  2.1291 +\xb9\xe9\x6f\xf5\xbb\x87\x5a\x17\x37\x01\xe7\x1c\x00\x38\x37\x9e\
  2.1292 +\x87\x9c\x91\xb3\xce\x21\x2f\xc8\x4b\xac\xec\xf5\xf6\x76\xd7\xdf\
  2.1293 +\xa9\x6c\x70\xad\x03\x00\x30\xc6\x6b\x35\x19\x86\x5c\x48\x42\x59\
  2.1294 +\x71\xd1\x3d\x88\x26\x82\x68\x8a\xf4\xa0\x68\x7f\x69\xed\xc0\x9d\
  2.1295 +\xb9\xd7\x41\xf5\xf6\x15\x50\x2a\x07\x60\xe5\xb2\x04\x00\x6b\x1d\
  2.1296 +\x56\x67\x71\x68\xbc\x67\x43\xe3\xa2\x49\x8c\xcb\x10\xe7\xad\xa5\
  2.1297 +\x53\x80\x5b\xb3\xaf\xa4\x52\x79\x9e\x0f\x8c\x4d\x01\xdc\x25\xb6\
  2.1298 +\x08\x27\x38\xaa\xb9\x3b\x4a\xb4\x13\x30\x02\x69\xc0\x1c\xc7\x9e\
  2.1299 +\xea\x2c\x1f\x1b\x23\x9b\xad\x46\xaa\xce\x53\x60\x7e\x09\xa7\x2e\
  2.1300 +\x81\xc3\xf6\x05\x58\xc7\x12\x2c\x45\x1e\x17\x45\xce\x19\x32\x42\
  2.1301 +\x61\xbb\x67\xad\x75\x79\xd0\x69\x9f\x23\x0e\xc0\x1f\x2e\xb3\x67\
  2.1302 +\x00\x00\x80\x04\x85\x25\x72\x56\x7a\xa1\xc7\x32\x61\x33\xb8\x1a\
  2.1303 +\x97\xca\xc1\xa8\x74\xa2\xd2\xd3\x8a\x0b\xc8\x0c\x68\xa5\x8c\xb1\
  2.1304 +\x8e\x0d\x21\x22\x3a\xc7\x3c\xe9\x51\x21\x51\x01\x21\x00\x38\xe4\
  2.1305 +\x95\xb1\xfb\x7c\xb8\x12\x0a\x00\xb2\x46\x19\x6c\xfd\x39\xdc\xda\
  2.1306 +\xda\x56\xca\x5c\x6e\x6f\xb4\x4e\xe2\x93\xbf\x49\xac\x8d\x23\x00\
  2.1307 +\xc7\x82\x70\x64\x5a\xd6\xc2\x00\x6d\x47\x08\x40\x12\x8d\x9d\x5f\
  2.1308 +\x5f\x77\xe2\xdb\x33\x73\x51\x89\x98\x60\x71\xaf\xf9\xf3\x70\xa5\
  2.1309 +\x99\x1c\x3c\x19\xe3\xf5\x9a\x57\x1d\x1e\xf5\x82\x31\x59\xe8\x84\
  2.1310 +\x9b\x6c\x38\x08\x98\xc7\xb2\x76\x7a\xd2\xcf\x38\xc0\xf3\x49\xe6\
  2.1311 +\x97\x82\xc1\xc9\xd2\x86\x5b\xdf\x3f\x75\x8d\x01\x3d\xb9\x55\x79\
  2.1312 +\x51\xf2\x26\x84\x2f\x3f\xaf\x7d\x0c\xfd\xe0\xe9\xdd\xa7\xbe\x70\
  2.1313 +\xdb\x1d\x1f\x31\x16\x9c\xcd\x4f\x8d\x29\xad\x3b\x71\x13\x88\x72\
  2.1314 +\x8d\x22\xa2\x8d\x63\xdd\xef\x37\xa2\xf9\x16\xdf\x6d\x6f\x4a\x91\
  2.1315 +\xf9\x43\xae\x1a\xf9\x82\x0b\x21\xf8\x45\x9a\x69\x5d\x74\xba\xa7\
  2.1316 +\x44\x90\xb7\x1c\x9d\x1b\x8c\x2d\xa5\xf4\xeb\xa8\xb9\x77\xb4\x2f\
  2.1317 +\x1f\xd5\x17\xbf\x6f\xad\x2d\xaf\xad\x3e\x9c\x78\x50\xaf\x08\xa5\
  2.1318 +\xcc\xee\xee\xfe\x4e\x63\x73\xe5\xc7\xea\x41\xe3\xf8\x0e\x8a\x97\
  2.1319 +\xf7\x66\x92\x3c\xa9\x4f\x4f\x64\xa5\xb9\x87\x0b\x8b\xff\x00\x63\
  2.1320 +\xce\x84\xe6\xf7\x5b\x7e\xce\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
  2.1321 +\x42\x60\x82'
  2.1322 +
  2.1323 +def GetDepartmentIconData():
  2.1324 +    return \
  2.1325 +'\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\
  2.1326 +\x00\x00\x00\x10\x00\x00\x00\x11\x08\x06\x00\x00\x00\xd4\xaf\x2c\
  2.1327 +\xc4\x00\x00\x00\x04\x73\x42\x49\x54\x08\x08\x08\x08\x7c\x08\x64\
  2.1328 +\x88\x00\x00\x01\x52\x49\x44\x41\x54\x38\x8d\xd5\x92\x3d\x4b\x42\
  2.1329 +\x61\x18\x86\xaf\xf3\xfa\xfa\x81\xa9\x58\x48\x60\x08\x49\xd2\x26\
  2.1330 +\xb4\x37\x4a\x14\x6d\x6d\x42\x42\x7f\x20\x68\xae\x31\x28\xff\x85\
  2.1331 +\x83\xd0\x90\x05\x0d\x6d\x0d\xd2\x2a\x89\x24\x48\xb8\x85\x49\x1a\
  2.1332 +\x48\x87\xd4\xca\x93\xbe\xd4\x69\x38\x39\x1c\xa8\x34\x1a\xa2\x7b\
  2.1333 +\xbb\x79\xb8\xaf\x87\xe7\x43\x0b\x2f\x6c\xad\x05\x23\x4b\x39\x4d\
  2.1334 +\x38\x5d\xe6\xdb\x80\x9b\xab\xd3\x7a\xaf\x96\x99\x65\x4c\xc9\xfb\
  2.1335 +\x97\xd9\xdc\x43\xb3\xef\x82\x3e\xaf\xc6\x2d\x4a\x9b\x33\xc7\x0d\
  2.1336 +\x03\x48\x25\xa3\x4e\x25\x86\x0d\x0d\xbc\x8e\x8e\xff\x28\x95\x3a\
  2.1337 +\x70\x08\x21\x01\x0e\xcb\xe5\x5a\xb6\x52\xd9\xfe\x12\x60\x73\xa6\
  2.1338 +\x62\x7f\xae\x3a\x15\xf5\xf8\x52\x00\x8d\x6e\x97\xc5\x40\xe0\x32\
  2.1339 +\x0b\xdb\x00\x3e\x9f\xf0\xa4\xd3\x33\x9b\x5e\xaf\x70\x01\xe4\xf3\
  2.1340 +\x9d\xb6\x1d\xf0\xd6\x67\x3d\xe4\x60\xfa\xc3\xb6\x0d\x03\xb7\x10\
  2.1341 +\xc3\xaa\xd8\xd9\x99\x3c\x49\x24\x3c\xab\x00\xdd\xae\xc2\x30\x1e\
  2.1342 +\xaf\xed\x80\xef\xe5\x4e\x26\xf5\x95\x58\x4c\x07\xa0\x50\x80\x60\
  2.1343 +\x10\xc4\x88\xd0\x48\xfd\x1a\x30\x72\x84\x62\x24\x12\x9b\xdf\xdd\
  2.1344 +\x3d\x33\x95\x12\x26\x7b\xda\x8f\x00\xe7\x42\x70\x1c\x8f\x07\x34\
  2.1345 +\x29\x97\x91\x12\xd0\x00\xfb\x9b\x7c\x0b\xd0\xc3\x61\x5a\xa1\x90\
  2.1346 +\x65\x06\x03\xcc\x4f\x5e\xec\xef\x97\xf8\xcf\x01\x4f\x4f\xd4\x25\
  2.1347 +\xbd\xea\x05\x4a\xb7\xee\xdb\xab\x3e\x17\x5a\xad\x89\xa0\xdb\x0d\
  2.1348 +\x40\x43\x08\x0d\xbf\xdf\xda\xbd\x52\x14\x8b\x26\x77\x4d\x2b\x5c\
  2.1349 +\x2a\xa1\x67\x32\x6c\xbc\x03\x17\xdb\x6e\x97\x68\x69\xf7\x4f\x00\
  2.1350 +\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82'
  2.1351 +
  2.1352 +def GetConflictIconData():
  2.1353 +    return \
  2.1354 +'\x89PNG\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\
  2.1355 +\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\x00\x00\x00\x90\x91\x68\
  2.1356 +\x36\x00\x00\x00\x03\x73\x42\x49\x54\x08\x08\x08\xdb\xe1\x4f\xe0\
  2.1357 +\x00\x00\x02\x45\x49\x44\x41\x54\x28\x91\x6d\x92\x4f\x48\x9a\x71\
  2.1358 +\x18\xc7\x7f\xbe\xef\xab\xcd\xed\x95\xcd\x8c\x25\x83\xc0\x24\xa9\
  2.1359 +\xc3\x4a\x17\xce\xea\x96\x3b\xe4\x0e\x5d\xba\xce\xa8\x88\xe8\x20\
  2.1360 +\x1a\x15\x1d\x3a\x78\x09\xf2\xed\xcf\xe8\x32\x68\x45\x56\x93\x66\
  2.1361 +\x94\x78\x99\x53\x68\x4e\x1b\xe1\x61\x30\xc2\x19\x5b\x16\xac\x9c\
  2.1362 +\x76\x19\x92\x2e\x35\xa6\x7b\xf7\xda\xfb\x3e\x3b\xd8\x9c\x9b\x7e\
  2.1363 +\x8e\xdf\xdf\xf3\x81\xdf\xf3\x87\x07\x00\xe8\x0f\x99\xb3\xb3\xd0\
  2.1364 +\xca\xca\x17\x97\x2b\x75\x7a\x8a\xf1\xf9\x77\xea\xeb\xe5\x3a\xdd\
  2.1365 +\x83\xe1\xe1\x6a\x85\xa2\x58\xc3\x2b\x08\x5c\x3e\x1f\x98\x9a\xfa\
  2.1366 +\xb0\xb0\x80\xf3\xf9\x72\x9d\xae\x56\xa5\xe2\x58\x36\x13\x8b\x9d\
  2.1367 +\xb8\xdd\x3f\x2f\x2e\x1e\x8e\x8c\x3c\x9a\x9d\xc5\xab\xaa\x10\x42\
  2.1368 +\x08\x00\x38\x96\x75\xf6\xf4\x58\x78\xbc\x37\x46\x23\x9d\x4e\x43\
  2.1369 +\x09\x57\x34\xfd\x7e\x6e\x6e\x4e\x28\xb4\x6b\xb5\x2c\xc3\x00\x00\
  2.1370 +\x02\x80\x77\x93\x93\xd3\x08\x51\x04\x71\xec\x74\x42\x25\xbe\xfa\
  2.1371 +\x7c\xf3\x24\xb9\x63\x30\x00\x00\x4a\x45\x22\x33\x02\x81\xd7\x64\
  2.1372 +\x5a\x69\x6e\x9e\xe1\xf3\x8f\x1c\x8e\x8a\xce\xc7\xe5\x65\x0b\x86\
  2.1373 +\x7d\xdb\xdf\x47\xfe\x89\x89\xa7\x22\xd1\xaf\xcb\xcb\x6c\x22\x61\
  2.1374 +\x55\x2a\x29\x82\x08\x6f\x6d\x95\x0b\x1c\xcb\x3e\x57\x28\x3c\x43\
  2.1375 +\x43\x68\x5d\xa3\x71\x74\x77\x17\xd2\x5c\x32\x69\x55\xa9\x28\x82\
  2.1376 +\x38\xdc\xdc\x2c\x77\xbc\x26\xd3\xb3\xba\x3a\xec\xfb\xf1\xb1\xb8\
  2.1377 +\xa1\xa1\x30\x32\xa1\x44\xa2\xdf\xdd\xbd\xdb\xd2\xf2\xba\xbf\xff\
  2.1378 +\xd0\x6e\x47\xff\x22\x69\x6a\xfa\x11\x8f\x63\x1c\xcb\xb2\x0c\x53\
  2.1379 +\x4c\x85\xd5\xd5\x7a\xbf\xbf\x56\xa9\x74\x0f\x0c\x7c\xde\xd8\x28\
  2.1380 +\x15\x80\xe3\x80\xe3\xb0\xdb\x32\x59\x26\x1a\x2d\x7d\xb8\x21\x16\
  2.1381 +\x3f\xf1\xf9\xa4\xad\xad\x9e\xc1\xc1\x4f\x36\x5b\x31\x4f\x47\xa3\
  2.1382 +\xa4\x54\x8a\x7c\xe3\xe3\xf3\x24\x99\x4b\x26\xff\xfb\x31\x9d\x4a\
  2.1383 +\xad\x6b\x34\x14\x8e\x1f\xac\xad\x15\x9a\x5e\x6a\x6c\x74\xf5\xf5\
  2.1384 +\xa1\x44\x38\x4c\xe1\xf8\xdb\xd1\xd1\xf2\x2e\xe9\x74\xfa\x45\x7b\
  2.1385 +\xbb\x05\xc3\x42\x56\x6b\x70\x69\xc9\xc2\xe3\x9d\x05\x02\x08\x00\
  2.1386 +\x76\x0c\x06\x8a\x20\xc2\xdb\xdb\x15\x9c\x4c\xc6\xd6\xd1\x61\xc1\
  2.1387 +\xb0\x79\x92\x7c\xa5\xd7\x5f\x6f\x9a\x65\x98\x97\x9d\x9d\x14\x8e\
  2.1388 +\xef\x99\xcd\x57\x34\x5d\x2a\xb0\x0c\xb3\x67\x36\x4f\x23\xb4\xae\
  2.1389 +\x56\xe7\x73\x39\x00\xb8\x3e\xbe\x7c\x2e\xe7\x1b\x1b\x3b\x58\x5d\
  2.1390 +\xbd\x59\x53\x23\xef\xea\x2a\x0c\x3a\x13\x8b\x45\xbc\xde\x6c\x3c\
  2.1391 +\x7e\xbf\xb7\xf7\xf1\xe2\xa2\x40\x24\xfa\x7b\xad\x05\xe2\xc1\x60\
  2.1392 +\xc8\x6a\x3d\xf1\x78\xb2\xe7\xe7\x88\xe3\x6e\x49\xa5\x32\xad\x56\
  2.1393 +\x6d\x34\xde\x6b\x6b\x2b\xd6\xfc\x06\xb3\xcb\xb3\xdb\x2f\x3f\x31\
  2.1394 +\xa9\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\x82'
  2.1395 +
  2.1396 +#=============== help texts
  2.1397 +
  2.1398 +NewRealmButtonHelp = \
  2.1399 +    "Use this button to add a new top-level REALM type. \n\n\
  2.1400 +You can refine an existing realm by right-clicking it \
  2.1401 +and selecting \"Add workload\" from the pop-up menu.\n\n<Ctrl>-h for help"
  2.1402 +
  2.1403 +RealmWorkloadPanelHelp = \
  2.1404 +    "\
  2.1405 +Use this panel to define names for  types of workloads that \
  2.1406 +shall be confined against each other.\n\n<Ctrl>-h for help"
  2.1407 +
  2.1408 +RunTimeExclusionPanelHelp = \
  2.1409 +    "\
  2.1410 +The run-time exclusion rules restrict which workload types \
  2.1411 +can run simultaneously on the same platform. At most one \
  2.1412 +type in an exclusion rule can run. If a domain starts, its \
  2.1413 +workload type is looked up and if it is in any exclusion rule \
  2.1414 +of which another type is already running, then it is denied \
  2.1415 +to start.\n\n<Ctrl>-h for help"
  2.1416 +
  2.1417 +CreateRunTimeButtonHelp = \
  2.1418 +    "\
  2.1419 +This button creates a new run-time exclusion rule using the \
  2.1420 +selection from the left side workload definition panel.\n\n<Ctrl>-h for help"
  2.1421 +
  2.1422 +AddToExclusionButtonHelp = \
  2.1423 +    "\
  2.1424 +This button adds the current selection in the left side \
  2.1425 +workload definition panel to the associated exclusion rule.\n\n<Ctrl>-h for help"
  2.1426 +
  2.1427 +DelFromExclusionButtonHelp = \
  2.1428 +    "\
  2.1429 +This button deletes the current selection of the associated \
  2.1430 +exclusion rule from the associated exclusion rule.\n\n<Ctrl>-h for help"
  2.1431 +
  2.1432 +ManageExclusionButtonHelp = \
  2.1433 +    "\
  2.1434 +This button allows to rename or delete the associated exclusion \
  2.1435 +rule. Left-click the button for the menu.\n\n<Ctrl>-h for help"
  2.1436 +
  2.1437 +ExclusionSetHelp = \
  2.1438 +    "\
  2.1439 +Of the workload types specified in an exclusion rule, \
  2.1440 +only one can run at a time on the same platform.\n\n<Ctrl>-h for help"
  2.1441 +
  2.1442 +GetHelp = \
  2.1443 +    "\
  2.1444 +Use <CTRL>-h to open the help window. Use the context help on buttons."
  2.1445 +
  2.1446 +#================ html help page =================
  2.1447 +# for ez use included in a single file, one could also
  2.1448 +# optionally try to fetch the page from a public location
  2.1449 +import wx.html as html
  2.1450 +
  2.1451 +class HelpHtmlWindow(html.HtmlWindow):
  2.1452 +    def __init__(self, parent, id):
  2.1453 +        html.HtmlWindow.__init__(self, parent, id, style=wx.NO_FULL_REPAINT_ON_RESIZE)
  2.1454 +        if "gtk2" in wx.PlatformInfo:
  2.1455 +            self.SetStandardFonts()
  2.1456 +        self.SetPage(helptext)
  2.1457 +
  2.1458 +helptext = """
  2.1459 +<HTML>
  2.1460 +<HEAD>
  2.1461 +<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  2.1462 +<META name="GENERATOR" content="IBM WebSphere Studio Homepage Builder V6.0.2 for Windows">
  2.1463 +<META http-equiv="Content-Style-Type" content="text/css">
  2.1464 +<TITLE>Overview</TITLE>
  2.1465 +</HEAD>
  2.1466 +<BODY bgcolor="#dfdfdf" text="#000000">
  2.1467 +<H3><FONT color="#000000" face="Palatino Linotype">Creating A Xen Workload-Protection Security Policy</FONT></H3>
  2.1468 +<FONT face="Palatino Linotype">The purpose of this tool is to create a Xen security policy that understands
  2.1469 +the workload types that you want to confine against each other. For this
  2.1470 +purpose you enter the names of workload types that you want to assign to
  2.1471 +domains and resources. You can also define groups of workload types that
  2.1472 +should not run on the same system simultaneously for any reason; such groups
  2.1473 +are called Runtime Exclusion Sets. Please refer to the Xen User Guide for
  2.1474 +more information.<BR>
  2.1475 +<BR>
  2.1476 +This tool will create a unique security label for each workload type. Every
  2.1477 +domain and resource must be labeled so that the hypervisor system can correctly
  2.1478 +identify the associated workload type and control the sharing among domains
  2.1479 +in a way that keeps different workload types confined from each other.
  2.1480 +This tool ensures two things:<BR>
  2.1481 +<BR>
  2.1482 +1. The created security policy includes a distinctive label for each workload
  2.1483 +type defined in step 1 below. These labels must later be assigned to Domains
  2.1484 +and Resources to enable Xen to enforce the confinement.<BR>
  2.1485 +<BR>
  2.1486 +2. The created security policy includes access control rules that are enforced
  2.1487 +by the Xen Hypervisor (independently of the guest Domains) and guarantee
  2.1488 +that:</FONT>
  2.1489 +<BLOCKQUOTE><FONT face="Palatino Linotype">(i) Domains that are assigned the same workload type label can
  2.1490 +share (communicate,
  2.1491 +use common resources) without restriction through the hypervisor. Their
  2.1492 +interoperation can still be constraint by the domains (domain-internal
  2.1493 +means).</FONT></BLOCKQUOTE>
  2.1494 +<BLOCKQUOTE><FONT face="Palatino Linotype">(ii) Domains that are assigned different workload type labels cannot share,
  2.1495 +i.e., cannot communicate or use common resources. Independently enforced
  2.1496 +by the hypervisor, the domains cannot overrule this decision.</FONT></BLOCKQUOTE>
  2.1497 +<BLOCKQUOTE><FONT face="Palatino Linotype">(iii) Once a Domain labeled with a workload type of a Runtime Exclusion
  2.1498 +Rule is running, no other domain labeled with another workload type of
  2.1499 +the same Runtime Exclusion Rule can start. This holds for all Runtime Exclusion
  2.1500 +Rules.</FONT></BLOCKQUOTE>
  2.1501 +<FONT face="Palatino Linotype">While all workloads share common hardware resources, the core hypervisor
  2.1502 +isolation and virtualization in combination with the Xen access control
  2.1503 +policy ensure that, e.g., viruses in one workload type cannot infect other
  2.1504 +workload types and that secrets used within one workload type cannot leak
  2.1505 +into another workload type. Currently the Xen access control enforcement
  2.1506 +covers domains, local storage resources, and the local virtual network
  2.1507 +interfaces. Protecting sharing through the open network is subject of ongoing
  2.1508 +work; such protection must currently be setup manually using IP filtering
  2.1509 +rules in Domain0.
  2.1510 +<BR>
  2.1511 +</FONT>
  2.1512 +<H2><FONT color="#000000" face="Palatino Linotype">Step 1</FONT></H2>
  2.1513 +<FONT face="Palatino Linotype">The first step of creating a workload protection policy is to determine
  2.1514 +names for the different workload types. The left panel offers the means
  2.1515 +to define and and manage workload type definitions.<BR>
  2.1516 +<BR>
  2.1517 +A workload can be an organization name (coarse-grained type), e.g. a corporate
  2.1518 +realm such as IBM or PepsiCo. An organization can be refined to describe
  2.1519 +independent functional groupings within the organization, such as IBM.Financing
  2.1520 +or Pepsi.Payroll. Use the<B><I> &lt;New Org&gt;</I></B> button on the left panel
  2.1521 +to create a new organization workload. To refine such a workload, right-click the
  2.1522 +organization and chose <B><I>&lt;Add Department&gt;</I></B>. You can add multiple
  2.1523 +departments to an organization but you do not have to add any.<BR>
  2.1524 +<BR>
  2.1525 +This tool will create a separate label name for each organization and for
  2.1526 +each department workload. The policy will be computed so that there is
  2.1527 +no sharing between organizations or departments by default. IBM, IBM.Financing,
  2.1528 +Pepsi, and Pepsi.Payroll will by default not be able to share in this simple
  2.1529 +policy example. You can introduce controlled sharing by refining the policy,
  2.1530 +which is beyond the scope of this help.<BR>
  2.1531 +<BR>
  2.1532 +As an example, define the four organizations PepsiCo, CocaCola, Avis, Hertz.
  2.1533 +Define department workloads Payroll, HumanResources and Financing for Avis
  2.1534 +and CocaCola, and PepsiCo.<BR>
  2.1535 +</FONT>
  2.1536 +<H2><FONT color="#000000" face="Palatino Linotype">Step 2</FONT></H2>
  2.1537 +<FONT face="Palatino Linotype">In this second step, we enter those workload types that should not run
  2.1538 +simultaneously on the same hardware platform. There might be multiple reasons
  2.1539 +for this, e.g., imperfect resource control.<BR>
  2.1540 +<BR>
  2.1541 +As an example, we will create a policy that guarantees that PepsiCo workloads
  2.1542 +and CocaCola workloads never run simultaneously on the same platform: <BR>
  2.1543 +<BR>
  2.1544 +1. Select the PepsiCo organization on the left panel by left-clicking it..<BR>
  2.1545 +<BR>
  2.1546 +2. Press the &lt;Ctrl&gt;-Key and then select CocaCola organization by
  2.1547 +left-clicking it while keeping the &lt;Ctrl&gt;-Key pressed..<BR>
  2.1548 +<BR>
  2.1549 +3. Click the <B><I>&lt;Create run-time exclusion rule from selection&gt;</I></B>
  2.1550 +button and enter a name for this Run-time Exclusion rule (e.g., RER1). The name is
  2.1551 +for your reference only. It has no impact on the policy. On the right panel, a run-time
  2.1552 +exclusion rule with the chosen name appears. <BR>
  2.1553 +<BR>
  2.1554 +The interpretation of the rule is as follows: If a domain labeled PepsiCo
  2.1555 +is running, then another domain labeled CocaCola cannot start on the same
  2.1556 +system and the other way round. This also holds for departments of PepsiCo
  2.1557 +and CocaCola (organizations dominate their departments). If PepsiCo or
  2.1558 +PepsiCo.Payroll etc. are running, then a domain with label CocaCola or
  2.1559 +CocaCola.Payroll etc. cannot start. If you want to restrict concurrency
  2.1560 +between specific subtypes, then you must create a Run-time Exclusion rule
  2.1561 +that specifies the department workload types. To exclude only CocaCola.Payroll
  2.1562 +and PepsiCo.Payroll from running simultaneously the Run-time Exclusion
  2.1563 +rule must be formed using Coca.Cola.Payroll and PepsiCo.Payroll, not their
  2.1564 +organizations. Consequently it does not make sense to add both an organization
  2.1565 +and any of its departments to the same Run-time Exclusion rule because
  2.1566 +any department is already covered by its organization (this tool will not
  2.1567 +allow it).<BR>
  2.1568 +<BR>
  2.1569 +You can create multiple Run-time Exclusion rules, all of which will be
  2.1570 +enforced simultaneously by the hypervisor. You do not need to define any
  2.1571 +Run-time Exclusion rule if you do not find it necessary. You can add or
  2.1572 +delete workload types from Run-time Exclusion rules using the <B><I>&lt;Add&gt;</I></B>
  2.1573 +and <I><B>&lt;Del&gt;</B></I> buttons associated with the rule. The <I><B>&lt;Add&gt;</B></I>
  2.1574 +button adds the workload types selected in the left panel to the Run-time
  2.1575 +Exclusion rule. The <I><B>&lt;Del&gt;</B></I> button deletes the workload types selected
  2.1576 +in the associated Run-time Exclusion rule from the rule. <BR>
  2.1577 +</FONT>
  2.1578 +<H2><FONT color="#000000" face="Palatino Linotype">Step 3</FONT></H2>
  2.1579 +<FONT face="Palatino Linotype">Now that we have defined the workloads and Run-time Exclusion rules, we
  2.1580 +can save the workload definition for later reference or refinement. Select
  2.1581 +the <I><B>File-&gt;Save Workload
  2.1582 +Definition as..</B></I> menu entry and choose a file name.<BR>
  2.1583 +<BR>
  2.1584 +Please use the <B><I>File-&gt;Save as Xen ACM Security Policy..</I></B> menu entry and choose a policy
  2.1585 +name to create a Xen Workload Protection
  2.1586 +security policy from the current workload definition. To simplify the succeeding
  2.1587 +steps, please use a name of the form &quot;example.chwall_ste.NAME&quot;
  2.1588 +where you merely replace &quot;NAME&quot; with a policy name of your choice.
  2.1589 +Save the policy under the name proposed by the tool in the proposed directory
  2.1590 +if you are using this tool in your Xen environment. Otherwise, you need
  2.1591 +to copy the resulting file into your Xen environment to the directory
  2.1592 +&quot;/etc/xen/acm-security/policies/example/chwall_ste/&quot;.<BR>
  2.1593 +<BR>
  2.1594 +This tool creates policies for the Xen Chinese Wall and Simple Type Enforcement
  2.1595 +policy. The Xen access control policy in general is more expressive and
  2.1596 +this tool only uses a small subset of the possible configurations. <B><BR>
  2.1597 +<BR>
  2.1598 +Where to go from here.</B> <BR>
  2.1599 +<BR>
  2.1600 +Before the new policy can be activated, we need to translate the policy into a representation that
  2.1601 +Xen and the Xen-tools can work with. To this end, in your Xen environment, please issue the command
  2.1602 +<B><I>xm makepolicy example.chwall_ste.NAME</I></B> where NAME must be replaced by the name you chose
  2.1603 +for your policy in step 3 above. Then, we need to make the policy available to the Xen hypervisor. In
  2.1604 +your Xen environment, please issue the command <B><I>xm cfgbootpolicy example.chwall_ste.NAME</I></B>
  2.1605 +to install the policy for the next reboot. If the command cannot find the correct boot title, then you
  2.1606 +can manually install it as described in the xm man page.<BR>
  2.1607 +<BR>
  2.1608 +Finally, reboot your security-enabled Xen environment. Please refer to the xm man page for how to enable
  2.1609 +Xen security. After reboot, you can use <I><B>xm labels type=any</B></I> to list all the created workload l
  2.1610 +abels. Use the <I><B>xm addlabel</B></I> command to assign workload type labels to the associated domains
  2.1611 +and resources.<BR>
  2.1612 +<BR>
  2.1613 +From here, please check the Xen user guide.<BR>
  2.1614 +</FONT></BODY>
  2.1615 +</HTML>
  2.1616 +"""
  2.1617 +
  2.1618 +#=============== main =====
  2.1619 +
  2.1620 +def main():
  2.1621 +    global app
  2.1622 +    app = ezApp(0)
  2.1623 +    if len(sys.argv) in [2]:
  2.1624 +        app.Load(sys.argv[1])
  2.1625 +    app.MainLoop()
  2.1626 +    print "Goodbye"
  2.1627 +
  2.1628 +if __name__ == '__main__':
  2.1629 +    main()
  2.1630 +
  2.1631 +#==== end of file