virtinst: Drop doc= for properties

This data never gets to the user and largely is just duplicating
libvirt docs. It's redundant
This commit is contained in:
Cole Robinson 2018-02-22 20:44:09 -05:00
parent e70eb82db1
commit 3079426c82
6 changed files with 87 additions and 130 deletions

View File

@ -104,7 +104,7 @@ class TestClone(unittest.TestCase):
utils.diff_compare(cloneobj.clone_xml, outfile)
if clone_disks_file:
xml_clone_disks = ""
for i in cloneobj.get_clone_disks():
for i in cloneobj.clone_disks:
xml_clone_disks += i.get_vol_install().get_xml_config()
utils.diff_compare(xml_clone_disks, clone_disks_file)

View File

@ -77,16 +77,19 @@ class Cloner(object):
self.clone_uuid = util.generate_uuid(conn)
# Getter/Setter methods
##############
# Properties #
##############
# Original guest name
def get_original_guest(self):
return self._original_guest
def set_original_guest(self, original_guest):
if self._lookup_vm(original_guest):
self._original_guest = original_guest
original_guest = property(get_original_guest, set_original_guest,
doc="Original guest name.")
original_guest = property(get_original_guest, set_original_guest)
# XML of the original guest
def set_original_xml(self, val):
if not isinstance(val, str):
raise ValueError(_("Original xml must be a string."))
@ -95,9 +98,9 @@ class Cloner(object):
parsexml=self._original_xml).name
def get_original_xml(self):
return self._original_xml
original_xml = property(get_original_xml, set_original_xml,
doc="XML of the original guest.")
original_xml = property(get_original_xml, set_original_xml)
# Name to use for the new guest clone
def get_clone_name(self):
return self._clone_name
def set_clone_name(self, name):
@ -109,16 +112,16 @@ class Cloner(object):
raise ValueError(_("Invalid name for new guest: %s") % e)
self._clone_name = name
clone_name = property(get_clone_name, set_clone_name,
doc="Name to use for the new guest clone.")
clone_name = property(get_clone_name, set_clone_name)
# UUID to use for the new guest clone
def set_clone_uuid(self, uuid):
self._clone_uuid = uuid
def get_clone_uuid(self):
return self._clone_uuid
clone_uuid = property(get_clone_uuid, set_clone_uuid,
doc="UUID to use for the new guest clone")
clone_uuid = property(get_clone_uuid, set_clone_uuid)
# Paths to use for the new disk locations
def set_clone_paths(self, paths):
disklist = []
for path in util.listify(paths):
@ -147,15 +150,14 @@ class Cloner(object):
self._clone_disks = disklist
def get_clone_paths(self):
return [d.path for d in self.clone_disks]
clone_paths = property(get_clone_paths, set_clone_paths,
doc="Paths to use for the new disk locations.")
clone_paths = property(get_clone_paths, set_clone_paths)
def get_clone_disks(self):
# VirtualDisk instances for the new disk paths
@property
def clone_disks(self):
return self._clone_disks
clone_disks = property(get_clone_disks,
doc="VirtualDisk instances for the new"
" disk paths")
# MAC address for the new guest clone
def set_clone_macs(self, mac):
maclist = util.listify(mac)
for m in maclist:
@ -166,45 +168,43 @@ class Cloner(object):
self._clone_macs = maclist
def get_clone_macs(self):
return self._clone_macs
clone_macs = property(get_clone_macs, set_clone_macs,
doc="MAC address for the new guest clone.")
clone_macs = property(get_clone_macs, set_clone_macs)
def get_original_disks(self):
# VirtualDisk instances of the original disks being cloned
@property
def original_disks(self):
return self._original_disks
original_disks = property(get_original_disks,
doc="VirtualDisk instances of the "
"original disks being cloned.")
# Generated XML for the guest clone
def get_clone_xml(self):
return self._clone_xml
def set_clone_xml(self, clone_xml):
self._clone_xml = clone_xml
clone_xml = property(get_clone_xml, set_clone_xml,
doc="Generated XML for the guest clone.")
clone_xml = property(get_clone_xml, set_clone_xml)
# Whether to attempt sparse allocation during cloning
def get_clone_sparse(self):
return self._clone_sparse
def set_clone_sparse(self, flg):
self._clone_sparse = flg
clone_sparse = property(get_clone_sparse, set_clone_sparse,
doc="Whether to attempt sparse allocation during "
"cloning.")
clone_sparse = property(get_clone_sparse, set_clone_sparse)
# If true, preserve ALL original disk devices
def get_preserve(self):
return self._preserve
def set_preserve(self, flg):
self._preserve = flg
preserve = property(get_preserve, set_preserve,
doc="If true, preserve ALL original disk devices.")
preserve = property(get_preserve, set_preserve)
def get_preserve_dest_disks(self):
# If true, preserve ALL disk devices for the NEW guest.
# This means no storage cloning.
# This is a convenience access for not Cloner.preserve
@property
def preserve_dest_disks(self):
return not self.preserve
preserve_dest_disks = property(get_preserve_dest_disks,
doc="If true, preserve ALL disk devices for the "
"NEW guest. This means no storage cloning. "
"This is a convenience access for "
"(not Cloner.preserve)")
# List of disk targets that we force cloning despite
# Cloner's recommendation
def set_force_target(self, dev):
if isinstance(dev, list):
self._force_target = dev[:]
@ -212,10 +212,10 @@ class Cloner(object):
self._force_target.append(dev)
def get_force_target(self):
return self._force_target
force_target = property(get_force_target, set_force_target,
doc="List of disk targets that we force cloning "
"despite Cloner's recommendation.")
force_target = property(get_force_target, set_force_target)
# List of disk targets that we skip cloning despite Cloner's
# recommendation. This takes precedence over force_target.")
def set_skip_target(self, dev):
if isinstance(dev, list):
self._skip_target = dev[:]
@ -223,45 +223,45 @@ class Cloner(object):
self._skip_target.append(dev)
def get_skip_target(self):
return self._skip_target
skip_target = property(get_skip_target, set_skip_target,
doc="List of disk targets that we skip cloning "
"despite Cloner's recommendation. This "
"takes precedence over force_target.")
skip_target = property(get_skip_target, set_skip_target)
# List of policy rules for determining which vm disks to clone.
# See CLONE_POLICY_*
def set_clone_policy(self, policy_list):
if not isinstance(policy_list, list):
raise ValueError(_("Cloning policy must be a list of rules."))
self._clone_policy = policy_list
def get_clone_policy(self):
return self._clone_policy
clone_policy = property(get_clone_policy, set_clone_policy,
doc="List of policy rules for determining which "
"vm disks to clone. See CLONE_POLICY_*")
clone_policy = property(get_clone_policy, set_clone_policy)
# Allow cloning a running VM. If enabled, domain state is not
# checked before cloning.
def get_clone_running(self):
return self._clone_running
def set_clone_running(self, val):
self._clone_running = bool(val)
clone_running = property(get_clone_running, set_clone_running,
doc="Allow cloning a running VM. If enabled, "
"domain state is not checked before "
"cloning.")
clone_running = property(get_clone_running, set_clone_running)
# If enabled, don't check for clone name collision, simply undefine
# any conflicting guest.
def _get_replace(self):
return self._replace
def _set_replace(self, val):
self._replace = bool(val)
replace = property(_get_replace, _set_replace,
doc="If enabled, don't check for clone name collision, "
"simply undefine any conflicting guest.")
replace = property(_get_replace, _set_replace)
# If true, use COW lightweight copy
def _get_reflink(self):
return self._reflink
def _set_reflink(self, reflink):
self._reflink = reflink
reflink = property(_get_reflink, _set_reflink,
doc="If true, use COW lightweight copy")
reflink = property(_get_reflink, _set_reflink)
# Functional methods
######################
# Functional methods #
######################
def setup_original(self):
"""

View File

@ -194,12 +194,9 @@ class _VirtualCharDevice(VirtualDevice):
"_source_path", "source_channel",
"target_type", "target_name"]
type = XMLProperty("./@type",
doc=_("Method used to expose character device in the host."))
type = XMLProperty("./@type")
_tty = XMLProperty("./@tty")
_source_path = XMLProperty("./source/@path",
doc=_("Host input path to attach to the guest."))
_source_path = XMLProperty("./source/@path")
def _get_source_path(self):
source = self._source_path
@ -210,8 +207,7 @@ class _VirtualCharDevice(VirtualDevice):
self._source_path = val
source_path = property(_get_source_path, _set_source_path)
source_channel = XMLProperty("./source/@channel",
doc=_("Source channel name."))
source_channel = XMLProperty("./source/@channel")
source_master = XMLProperty("./source/@master")
source_slave = XMLProperty("./source/@slave")
@ -231,10 +227,8 @@ class _VirtualCharDevice(VirtualDevice):
self._has_mode_connect = self.MODE_CONNECT
return val
source_host = XMLProperty("./source[@mode='connect']/@host",
doc=_("Host address to connect to."),
set_converter=_set_source_validate)
source_port = XMLProperty("./source[@mode='connect']/@service",
doc=_("Host port to connect to."),
set_converter=_set_source_validate,
is_int=True)
@ -244,10 +238,8 @@ class _VirtualCharDevice(VirtualDevice):
self._has_mode_bind = self.MODE_BIND
return val
bind_host = XMLProperty("./source[@mode='bind']/@host",
doc=_("Host address to bind to."),
set_converter=_set_bind_validate)
bind_port = XMLProperty("./source[@mode='bind']/@service",
doc=_("Host port to bind to."),
set_converter=_set_bind_validate,
is_int=True)
@ -261,7 +253,6 @@ class _VirtualCharDevice(VirtualDevice):
return None
return self.PROTOCOL_RAW
protocol = XMLProperty("./protocol/@type",
doc=_("Format used when sending data."),
default_cb=_get_default_protocol)
def _get_default_target_type(self):
@ -269,21 +260,17 @@ class _VirtualCharDevice(VirtualDevice):
return self.CHANNEL_TARGET_VIRTIO
return None
target_type = XMLProperty("./target/@type",
doc=_("Channel type as exposed in the guest."),
default_cb=_get_default_target_type)
target_address = XMLProperty("./target/@address",
doc=_("Guest forward channel address in the guest."))
target_address = XMLProperty("./target/@address")
target_port = XMLProperty("./target/@port", is_int=True,
doc=_("Guest forward channel port in the guest."))
target_port = XMLProperty("./target/@port", is_int=True)
def _default_target_name(self):
if self.type == self.TYPE_SPICEVMC:
return self.CHANNEL_NAME_SPICE
return None
target_name = XMLProperty("./target/@name",
doc=_("Sysfs name of virtio port in the guest"),
default_cb=_default_target_name)
log_file = XMLProperty("./log/@file")

View File

@ -55,11 +55,10 @@ class InterfaceProtocol(XMLBuilder):
_XML_PROP_ORDER = ["autoconf", "dhcp", "dhcp_peerdns", "ips", "gateway"]
family = XMLProperty("./@family")
dhcp = XMLProperty("./dhcp", is_bool=True, doc=_("Whether to enable DHCP"))
dhcp = XMLProperty("./dhcp", is_bool=True)
dhcp_peerdns = XMLProperty("./dhcp/@peerdns", is_yesno=True)
gateway = XMLProperty("./route/@gateway", doc=_("Network gateway address"))
autoconf = XMLProperty("./autoconf", is_bool=True,
doc=_("Whether to enable IPv6 autoconfiguration"))
gateway = XMLProperty("./route/@gateway")
autoconf = XMLProperty("./autoconf", is_bool=True)
#####################
@ -173,64 +172,44 @@ class Interface(XMLBuilder):
##################
type = XMLProperty("./@type")
mtu = XMLProperty("./mtu/@size", is_int=True,
doc=_("Maximum transmit size in bytes"))
start_mode = XMLProperty("./start/@mode",
doc=_("When the interface will be auto-started."))
mtu = XMLProperty("./mtu/@size", is_int=True)
start_mode = XMLProperty("./start/@mode")
name = XMLProperty("./@name", validate_cb=_validate_name,
doc=_("Name for the interface object."))
name = XMLProperty("./@name", validate_cb=_validate_name)
macaddr = XMLProperty("./mac/@address", validate_cb=_validate_mac,
doc=_("Interface MAC address"))
macaddr = XMLProperty("./mac/@address", validate_cb=_validate_mac)
#################
# Bridge params #
#################
stp = XMLProperty("./bridge/@stp", is_onoff=True,
doc=_("Whether STP is enabled on the bridge"))
delay = XMLProperty("./bridge/@delay",
doc=_("Delay in seconds before forwarding begins when "
"joining a network."))
stp = XMLProperty("./bridge/@stp", is_onoff=True)
delay = XMLProperty("./bridge/@delay")
###############
# Bond params #
###############
bond_mode = XMLProperty("./bond/@mode",
doc=_("Mode of operation of the bonding device"))
bond_mode = XMLProperty("./bond/@mode")
arp_interval = XMLProperty("./bond/arpmon/@interval", is_int=True,
doc=_("ARP monitoring interval in "
"milliseconds"))
arp_target = XMLProperty("./bond/arpmon/@target",
doc=_("IP target used in ARP monitoring packets"))
arp_validate_mode = XMLProperty("./bond/arpmon/@validate",
doc=_("ARP monitor validation mode"))
arp_interval = XMLProperty("./bond/arpmon/@interval", is_int=True)
arp_target = XMLProperty("./bond/arpmon/@target")
arp_validate_mode = XMLProperty("./bond/arpmon/@validate")
mii_carrier_mode = XMLProperty("./bond/miimon/@carrier",
doc=_("MII monitoring method."))
mii_frequency = XMLProperty("./bond/miimon/@freq", is_int=True,
doc=_("MII monitoring interval in "
"milliseconds"))
mii_updelay = XMLProperty("./bond/miimon/@updelay", is_int=True,
doc=_("Time in milliseconds to wait before "
"enabling a slave after link recovery "))
mii_downdelay = XMLProperty("./bond/miimon/@downdelay", is_int=True,
doc=_("Time in milliseconds to wait before "
"disabling a slave after link failure"))
mii_carrier_mode = XMLProperty("./bond/miimon/@carrier")
mii_frequency = XMLProperty("./bond/miimon/@freq", is_int=True)
mii_updelay = XMLProperty("./bond/miimon/@updelay", is_int=True)
mii_downdelay = XMLProperty("./bond/miimon/@downdelay", is_int=True)
###############
# VLAN params #
###############
tag = XMLProperty("./vlan/@tag", is_int=True,
doc=_("VLAN device tag number"))
parent_interface = XMLProperty("./vlan/interface/@name",
doc=_("Parent interface to create VLAN on"))
tag = XMLProperty("./vlan/@tag", is_int=True)
parent_interface = XMLProperty("./vlan/interface/@name")
##################

View File

@ -69,8 +69,7 @@ class _StorageObject(XMLBuilder):
# Properties #
##############
name = XMLProperty("./name", validate_cb=_validate_name,
doc=_("Name for the storage object."))
name = XMLProperty("./name", validate_cb=_validate_name)
permissions = XMLChildProperty(_StoragePermissions,
relative_xpath="./target",
is_single=True)
@ -397,8 +396,7 @@ class StoragePool(_StorageObject):
_source_adapter = XMLProperty("./source/adapter/@name")
_source_device = XMLProperty("./source/device/@path")
type = XMLProperty("./@type",
doc=_("Storage device type the pool will represent."))
type = XMLProperty("./@type")
uuid = XMLProperty("./uuid")
capacity = XMLProperty("./capacity", is_int=True)
@ -407,11 +405,9 @@ class StoragePool(_StorageObject):
format = XMLProperty("./source/format/@type",
default_cb=_default_format_cb)
iqn = XMLProperty("./source/initiator/iqn/@name",
doc=_("iSCSI initiator qualified name"))
iqn = XMLProperty("./source/initiator/iqn/@name")
source_name = XMLProperty("./source/name",
default_cb=_default_source_name,
doc=_("Name of the Volume Group"))
default_cb=_default_source_name)
auth_type = XMLProperty("./source/auth/@type")
auth_username = XMLProperty("./source/auth/@username")
@ -628,9 +624,7 @@ class StorageVolume(_StorageObject):
" not supported by this libvirt version."))
self._input_vol = vol
input_vol = property(_get_input_vol, _set_input_vol,
doc=_("virStorageVolume pointer to clone/use as "
"input."))
input_vol = property(_get_input_vol, _set_input_vol)
def _get_reflink(self):
return self._reflink
@ -641,8 +635,7 @@ class StorageVolume(_StorageObject):
" not supported by this libvirt version."))
self._reflink = reflink
reflink = property(_get_reflink, _set_reflink,
doc="flags for VIR_STORAGE_VOL_CREATE_REFLINK")
reflink = property(_get_reflink, _set_reflink)
def sync_input_vol(self, only_format=False):
# Pull parameters from input vol into this class

View File

@ -160,7 +160,7 @@ class XMLChildProperty(property):
class XMLProperty(property):
def __init__(self, xpath, doc=None,
def __init__(self, xpath,
set_converter=None, validate_cb=None,
is_bool=False, is_int=False, is_yesno=False, is_onoff=False,
default_cb=None, default_name=None, do_abspath=False):
@ -176,7 +176,6 @@ class XMLProperty(property):
existing guest XML, we use the xpath value to get/set the value
in the parsed XML document.
:param doc: option doc string for the property
:param xpath: xpath string which maps to the associated property
in a typical XML document
:param name: Just a string to print for debugging, only needed
@ -229,7 +228,6 @@ class XMLProperty(property):
_allprops.append(self)
property.__init__(self, fget=self.getter, fset=self.setter)
self.__doc__ = doc
def __repr__(self):