02_security-acm_dom_start.py
来自「xen 3.2.2 源码」· Python 代码 · 共 65 行
PY
65 行
#!/usr/bin/python# Copyright (C) International Business Machines Corp., 2006# Author: Stefan Berger <stefanb@us.ibm.com>## Simple test that starts two labeled domains; both domains should start## The following xm subcommands are tested:# - dumppolicy# - labelsfrom XmTestLib import *from acm_utils import *import commandsimport ostestlabel1 = "green"testlabel2 = "red"status, output = traceCommand("xm labels")labels = ["SystemManagement", "blue", "red", "green"]for l in labels: if not re.search(l, output): FAIL("Label '%s' not found in current policy!", l)status, output = traceCommand("xm dumppolicy")if status != 0: FAIL("'xm dumppolicy' returned an error code.")lines = ["ssidref 0: 00 00 00 00", "ssidref 1: 01 00 00 00", "ssidref 2: 00 01 00 00", "ssidref 3: 00 00 01 00", "ssidref 4: 00 00 00 01"]for l in lines: if not re.search(l, output): FAIL("Could not find '%s' in output of 'xm dumppolicy'" % l)config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel1)}verbose = Truedomain1 = XmTestDomain(name="domain-%s" % testlabel1, extraConfig=config)try: domain1.start(noConsole=True)except DomainError, e: if verbose: print e.extra FAIL("Unable to start 1st labeled test domain.")config = {"access_control":"policy=%s,label=%s" % (testpolicy,testlabel2)}domain2 = XmTestDomain(name="domain-%s" % testlabel2, extraConfig=config)try: domain2.start(noConsole=True)except DomainError, e: if verbose: print e.extra FAIL("Unable to start 2nd labeled test domain.")domain2.destroy()domain1.destroy()
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?