Package virtualization :: Module get_config_value
[hide private]
[frames] | no frames]

Source Code for Module virtualization.get_config_value

 1  # 
 2  # Copyright (c) 2008--2013 Red Hat, Inc. 
 3  # 
 4  # This software is licensed to you under the GNU General Public License, 
 5  # version 2 (GPLv2). There is NO WARRANTY for this software, express or 
 6  # implied, including the implied warranties of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 
 8  # along with this software; if not, see 
 9  # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. 
10  # 
11  # Red Hat trademarks are not licensed under GPLv2. No permission is 
12  # granted to use or replicate Red Hat trademarks that are incorporated 
13  # in this software or its documentation. 
14  # 
15   
16  import sys 
17  from virtualization.domain_config import DomainConfig 
18   
19  fieldname = sys.argv[1] 
20  filename = sys.argv[2] 
21  dc = DomainConfig('/usr/share/rhn/virt/auto', filename) 
22   
23  fields = { 
24              'name'          :   DomainConfig.NAME, 
25              'uuid'          :   DomainConfig.UUID, 
26              'memory'        :   DomainConfig.MEMORY, 
27              'vcpu'          :   DomainConfig.VCPU, 
28              'root_device'   :   DomainConfig.ROOT_DEVICE, 
29              'cmdline'       :   DomainConfig.COMMAND_LINE, 
30              'os_kernel'     :   DomainConfig.KERNEL_PATH, 
31              'os_initrd'     :   DomainConfig.RAMDISK_PATH, 
32              'disk_source'   :   DomainConfig.DISK_IMAGE_PATH 
33           } 
34   
35  if fieldname not in fields: 
36      sys.stdout.write("Unknown configuration element %s \n" % fieldname) 
37      sys.exit(1) 
38   
39  result = dc.getConfigItem(fields[fieldname]) 
40  if fieldname == "uuid": 
41      result = result.replace("-", "") 
42   
43  print(result) 
44