@@ -45,9 +45,12 @@ class LibvirtConfigObject(object):
45
45
def __init__ (self , ** kwargs ):
46
46
super (LibvirtConfigObject , self ).__init__ ()
47
47
48
- self .root_name = kwargs .get ("root_name" )
49
- self .ns_prefix = kwargs .get ('ns_prefix' )
50
- self .ns_uri = kwargs .get ('ns_uri' )
48
+ self .root_name = kwargs .pop ("root_name" )
49
+ self .ns_prefix = kwargs .pop ("ns_prefix" , None )
50
+ self .ns_uri = kwargs .pop ("ns_uri" , None )
51
+
52
+ # handle programmer error
53
+ assert not kwargs
51
54
52
55
def _new_node (self , node_name , ** kwargs ):
53
56
if self .ns_uri is None :
@@ -1532,7 +1535,8 @@ def parse_dom(self, xmldoc):
1532
1535
1533
1536
class LibvirtConfigGuestDiskEncryptionSecret (LibvirtConfigObject ):
1534
1537
def __init__ (self , ** kwargs ):
1535
- super (LibvirtConfigGuestDiskEncryptionSecret , self ).__init__ (** kwargs )
1538
+ super (LibvirtConfigGuestDiskEncryptionSecret , self ).__init__ (
1539
+ root_name = 'diskencryptionsecret' , ** kwargs )
1536
1540
self .type = None
1537
1541
self .uuid = None
1538
1542
@@ -1552,7 +1556,8 @@ class LibvirtConfigGuestDiskEncryption(LibvirtConfigObject):
1552
1556
"""
1553
1557
1554
1558
def __init__ (self , ** kwargs ):
1555
- super (LibvirtConfigGuestDiskEncryption , self ).__init__ (** kwargs )
1559
+ super (LibvirtConfigGuestDiskEncryption , self ).__init__ (
1560
+ root_name = 'diskencryption' , ** kwargs )
1556
1561
self .format = None
1557
1562
self .secret = None
1558
1563
@@ -1575,7 +1580,8 @@ def format_dom(self):
1575
1580
class LibvirtConfigGuestDiskMirror (LibvirtConfigObject ):
1576
1581
1577
1582
def __init__ (self , ** kwargs ):
1578
- super (LibvirtConfigGuestDiskMirror , self ).__init__ (** kwargs )
1583
+ super (LibvirtConfigGuestDiskMirror , self ).__init__ (
1584
+ root_name = 'diskmirror' , ** kwargs )
1579
1585
self .ready = None
1580
1586
1581
1587
def parse_dom (self , xmldoc ):
@@ -1585,6 +1591,8 @@ def parse_dom(self, xmldoc):
1585
1591
class LibvirtConfigGuestIDMap (LibvirtConfigObject ):
1586
1592
1587
1593
def __init__ (self , ** kwargs ):
1594
+ if 'root_name' not in kwargs :
1595
+ kwargs ['root_name' ] = 'id'
1588
1596
super (LibvirtConfigGuestIDMap , self ).__init__ (** kwargs )
1589
1597
self .start = 0
1590
1598
self .target = 0
@@ -2168,13 +2176,14 @@ def __init__(self, **kwargs):
2168
2176
2169
2177
class LibvirtConfigGuestHostdev (LibvirtConfigGuestDevice ):
2170
2178
def __init__ (self , ** kwargs ):
2171
- super (LibvirtConfigGuestHostdev , self ).\
2172
- __init__ (root_name = "hostdev" , ** kwargs )
2173
- self .mode = kwargs .get ('mode' )
2174
- self .type = kwargs .get ('type' )
2179
+ super (LibvirtConfigGuestHostdev , self ).__init__ (
2180
+ root_name = "hostdev" , ** kwargs ,
2181
+ )
2182
+ self .mode = None
2183
+ self .type = None
2175
2184
# managed attribute is only used by PCI devices but mediated devices
2176
2185
# need to say managed=no
2177
- self .managed = kwargs . get ( 'managed' , ' yes' )
2186
+ self .managed = " yes"
2178
2187
2179
2188
def format_dom (self ):
2180
2189
dev = super (LibvirtConfigGuestHostdev , self ).format_dom ()
@@ -2194,8 +2203,11 @@ def parse_dom(self, xmldoc):
2194
2203
class LibvirtConfigGuestHostdevPCI (LibvirtConfigGuestHostdev ):
2195
2204
def __init__ (self , ** kwargs ):
2196
2205
super (LibvirtConfigGuestHostdevPCI , self ).\
2197
- __init__ (mode = 'subsystem' , type = 'pci' ,
2198
- ** kwargs )
2206
+ __init__ (** kwargs )
2207
+
2208
+ self .mode = 'subsystem'
2209
+ self .type = 'pci'
2210
+
2199
2211
# These are returned from libvirt as hexadecimal strings with 0x prefix
2200
2212
# even if they have a different meaningful range: domain 16 bit,
2201
2213
# bus 8 bit, slot 5 bit, and function 3 bit
@@ -2252,10 +2264,14 @@ def parse_dom(self, xmldoc):
2252
2264
2253
2265
class LibvirtConfigGuestHostdevMDEV (LibvirtConfigGuestHostdev ):
2254
2266
def __init__ (self , ** kwargs ):
2255
- super (LibvirtConfigGuestHostdevMDEV , self ).__init__ (
2256
- mode = 'subsystem' , type = 'mdev' , managed = 'no' , ** kwargs )
2267
+ super (LibvirtConfigGuestHostdevMDEV , self ).__init__ (** kwargs )
2268
+
2269
+ self .mode = 'subsystem'
2270
+ self .type = 'mdev'
2271
+ self .managed = 'no'
2272
+
2257
2273
# model attribute is only supported by mediated devices
2258
- self .model = kwargs . get ( 'model' , ' vfio-pci')
2274
+ self .model = ' vfio-pci'
2259
2275
self .uuid = None
2260
2276
2261
2277
def format_dom (self ):
@@ -3585,11 +3601,11 @@ def __init__(self, **kwargs):
3585
3601
3586
3602
self .model = "nvdimm"
3587
3603
self .access = "shared"
3588
- self .source_path = kwargs . get ( "devpath" , "" )
3589
- self .align_size = kwargs . get ( "align_kb" , 0 )
3604
+ self .source_path = ""
3605
+ self .align_size = 0
3590
3606
self .pmem = True
3591
3607
3592
- self .target_size = kwargs . get ( "size_kb" , 0 )
3608
+ self .target_size = 0
3593
3609
self .target_node = 0
3594
3610
self .label_size = 2 * units .Ki
3595
3611
0 commit comments