Package ganeti :: Module config :: Class ConfigWriter
[hide private]
[frames] | no frames]

Class ConfigWriter

source code

The interface to the cluster configuration.

Instance Methods [hide private]
 
__init__(self, cfg_file=None, offline=False, _getents=runtime.GetEnts, accept_foreign=False) source code
 
_GetRpc(self, address_list)
Returns RPC runner for configuration.
source code
 
SetContext(self, context)
Sets Ganeti context.
source code
 
GetNdParams(self, node)
Get the node params populated with cluster defaults.
source code
 
GetInstanceDiskParams(self, instance)
Get the disk params populated with inherit chain.
source code
 
GetGroupDiskParams(self, group)
Get the disk params populated with inherit chain.
source code
 
_UnlockedGetGroupDiskParams(self, group)
Get the disk params populated with inherit chain down to node-group.
source code
 
_UnlockedGetNetworkMACPrefix(self, net_uuid)
Return the network mac prefix if it exists or the cluster level default.
source code
 
_GenerateOneMAC(self, prefix=None)
Return a function that randomly generates a MAC suffic and appends it to the given prefix.
source code
 
GenerateMAC(self, net_uuid, ec_id)
Generate a MAC for an instance.
source code
 
ReserveMAC(self, mac, ec_id)
Reserve a MAC for an instance.
source code
 
_UnlockedCommitTemporaryIps(self, ec_id)
Commit all reserved IP address to their respective pools
source code
 
_UnlockedCommitIp(self, action, net_uuid, address)
Commit a reserved IP address to an IP pool.
source code
 
_UnlockedReleaseIp(self, net_uuid, address, ec_id)
Give a specific IP address back to an IP pool.
source code
 
ReleaseIp(self, net_uuid, address, ec_id)
Give a specified IP address back to an IP pool.
source code
 
GenerateIp(self, net_uuid, ec_id)
Find a free IPv4 address for an instance.
source code
 
_UnlockedReserveIp(self, net_uuid, address, ec_id)
Reserve a given IPv4 address for use by an instance.
source code
 
ReserveIp(self, net_uuid, address, ec_id)
Reserve a given IPv4 address for use by an instance.
source code
 
ReserveLV(self, lv_name, ec_id)
Reserve an VG/LV pair for an instance.
source code
 
GenerateDRBDSecret(self, ec_id)
Generate a DRBD secret.
source code
 
_AllLVs(self)
Compute the list of all LVs.
source code
 
_AllDisks(self)
Compute the list of all Disks (recursively, including children).
source code
 
_AllNICs(self)
Compute the list of all NICs.
source code
set
_AllIDs(self, include_temporary)
Compute the list of all UUIDs and names we have.
source code
string
_GenerateUniqueID(self, ec_id)
Generate an unique UUID.
source code
 
GenerateUniqueID(self, ec_id)
Generate an unique ID.
source code
list
_AllMACs(self)
Return all MACs present in the config.
source code
list
_AllDRBDSecrets(self)
Return all DRBD secrets present in the config.
source code
list
_CheckDiskIDs(self, disk, l_ids, p_ids)
Compute duplicate disk IDs
source code
list
_UnlockedVerifyConfig(self)
Verify function.
source code
list
VerifyConfig(self)
Verify function.
source code
 
_UnlockedSetDiskID(self, disk, node_uuid)
Convert the unique ID to the ID needed on the target nodes.
source code
 
SetDiskID(self, disk, node_uuid)
Convert the unique ID to the ID needed on the target nodes.
source code
 
AddTcpUdpPort(self, port)
Adds a new port to the available port pool.
source code
 
GetPortList(self)
Returns a copy of the current port list.
source code
 
AllocatePort(self)
Allocate a port.
source code
(dict, list)
_UnlockedComputeDRBDMap(self)
Compute the used DRBD minor/nodes.
source code
 
ComputeDRBDMap(self)
Compute the used DRBD minor/nodes.
source code
 
AllocateDRBDMinor(self, node_uuids, inst_uuid)
Allocate a drbd minor.
source code
 
_UnlockedReleaseDRBDMinors(self, inst_uuid)
Release temporary drbd minors allocated for a given instance.
source code
 
ReleaseDRBDMinors(self, inst_uuid)
Release temporary drbd minors allocated for a given instance.
source code
 
GetConfigVersion(self)
Get the configuration version.
source code
 
GetClusterName(self)
Get cluster name.
source code
 
GetMasterNode(self)
Get the UUID of the master node for this cluster.
source code
 
GetMasterNodeName(self)
Get the hostname of the master node for this cluster.
source code
 
GetMasterIP(self)
Get the IP of the master node for this cluster.
source code
 
GetMasterNetdev(self)
Get the master network device for this cluster.
source code
 
GetMasterNetmask(self)
Get the netmask of the master node for this cluster.
source code
 
GetUseExternalMipScript(self)
Get flag representing whether to use the external master IP setup script.
source code
 
GetFileStorageDir(self)
Get the file storage dir for this cluster.
source code
 
GetSharedFileStorageDir(self)
Get the shared file storage dir for this cluster.
source code
 
GetHypervisorType(self)
Get the hypervisor type for this cluster.
source code
string
GetRsaHostKey(self)
Return the rsa hostkey from the config.
source code
string
GetDsaHostKey(self)
Return the dsa hostkey from the config.
source code
 
GetDefaultIAllocator(self)
Get the default instance allocator for this cluster.
source code
 
GetPrimaryIPFamily(self)
Get cluster primary ip family.
source code
object.MasterNetworkParameters
GetMasterNetworkParameters(self)
Get network parameters of the master node.
source code
 
AddNodeGroup(self, group, ec_id, check_uuid=True)
Add a node group to the configuration.
source code
 
_UnlockedAddNodeGroup(self, group, ec_id, check_uuid)
Add a node group to the configuration.
source code
 
RemoveNodeGroup(self, group_uuid)
Remove a node group from the configuration.
source code
string
_UnlockedLookupNodeGroup(self, target)
Lookup a node group's UUID.
source code
string
LookupNodeGroup(self, target)
Lookup a node group's UUID.
source code
objects.NodeGroup or None
_UnlockedGetNodeGroup(self, uuid)
Lookup a node group.
source code
objects.NodeGroup or None
GetNodeGroup(self, uuid)
Lookup a node group.
source code
 
GetAllNodeGroupsInfo(self)
Get the configuration of all node groups.
source code
 
GetNodeGroupList(self)
Get a list of node groups.
source code
 
GetNodeGroupMembersByNodes(self, nodes)
Get nodes which are member in the same nodegroups as the given nodes.
source code
list
GetMultiNodeGroupInfo(self, group_uuids)
Get the configuration of multiple node groups.
source code
 
AddInstance(self, instance, ec_id)
Add an instance to the config.
source code
 
_EnsureUUID(self, item, ec_id)
Ensures a given object has a valid UUID.
source code
 
_CheckUniqueUUID(self, item, include_temporary)
Checks that the UUID of the given object is unique.
source code
 
_SetInstanceStatus(self, inst_uuid, status, disks_active)
Set the instance's status to a given value.
source code
 
MarkInstanceUp(self, inst_uuid)
Mark the instance status to up in the config.
source code
 
MarkInstanceOffline(self, inst_uuid)
Mark the instance status to down in the config.
source code
 
RemoveInstance(self, inst_uuid)
Remove the instance from the configuration.
source code
 
RenameInstance(self, inst_uuid, new_name)
Rename an instance.
source code
 
MarkInstanceDown(self, inst_uuid)
Mark the status of an instance to down in the configuration.
source code
 
MarkInstanceDisksActive(self, inst_uuid)
Mark the status of instance disks active.
source code
 
MarkInstanceDisksInactive(self, inst_uuid)
Mark the status of instance disks inactive.
source code
 
_UnlockedGetInstanceList(self)
Get the list of instances.
source code
 
GetInstanceList(self)
Get the list of instances.
source code
 
ExpandInstanceName(self, short_name)
Attempt to expand an incomplete instance name.
source code
 
_UnlockedGetInstanceInfo(self, inst_uuid)
Returns information about an instance.
source code
objects.Instance
GetInstanceInfo(self, inst_uuid)
Returns information about an instance.
source code
frozenset
GetInstanceNodeGroups(self, inst_uuid, primary_only=False)
Returns set of node group UUIDs for instance's nodes.
source code
frozenset
GetInstanceNetworks(self, inst_uuid)
Returns set of network UUIDs for instance's nics.
source code
list
GetMultiInstanceInfo(self, inst_uuids)
Get the configuration of multiple instances.
source code
list
GetMultiInstanceInfoByName(self, inst_names)
Get the configuration of multiple instances.
source code
dict
GetAllInstancesInfo(self)
Get the configuration of all instances.
source code
 
_UnlockedGetAllInstancesInfo(self) source code
 
GetInstancesInfoByFilter(self, filter_fn)
Get instance configuration with a filter.
source code
 
GetInstanceInfoByName(self, inst_name)
Get the objects.Instance object for a named instance.
source code
 
_UnlockedGetInstanceInfoByName(self, inst_name) source code
 
_UnlockedGetInstanceName(self, inst_uuid) source code
string
GetInstanceName(self, inst_uuid)
Gets the instance name for the passed instance.
source code
list of strings
GetInstanceNames(self, inst_uuids)
Gets the instance names for the passed list of nodes.
source code
 
_UnlockedGetInstanceNames(self, inst_uuids) source code
 
AddNode(self, node, ec_id)
Add a node to the configuration.
source code
 
RemoveNode(self, node_uuid)
Remove a node from the configuration.
source code
 
ExpandNodeName(self, short_name)
Attempt to expand an incomplete node name into a node UUID.
source code
objects.Node
_UnlockedGetNodeInfo(self, node_uuid)
Get the configuration of a node, as stored in the config.
source code
objects.Node
GetNodeInfo(self, node_uuid)
Get the configuration of a node, as stored in the config.
source code
(list, list)
GetNodeInstances(self, node_uuid)
Get the instances of a node, as stored in the config.
source code
frozenset
GetNodeGroupInstances(self, uuid, primary_only=False)
Get the instances of a node group.
source code
 
_UnlockedGetHvparamsString(self, hvname)
Return the string representation of the list of hyervisor parameters of the given hypervisor.
source code
string
GetHvparamsString(self, hvname)
Return the hypervisor parameters of the given hypervisor.
source code
list
_UnlockedGetNodeList(self)
Return the list of nodes which are in the configuration.
source code
 
GetNodeList(self)
Return the list of nodes which are in the configuration.
source code
 
_UnlockedGetOnlineNodeList(self)
Return the list of nodes which are online.
source code
 
GetOnlineNodeList(self)
Return the list of nodes which are online.
source code
 
GetVmCapableNodeList(self)
Return the list of nodes which are not vm capable.
source code
 
GetNonVmCapableNodeList(self)
Return the list of nodes which are not vm capable.
source code
list
GetMultiNodeInfo(self, node_uuids)
Get the configuration of multiple nodes.
source code
 
_UnlockedGetAllNodesInfo(self)
Gets configuration of all nodes.
source code
dict
GetAllNodesInfo(self)
Get the configuration of all nodes.
source code
 
_UnlockedGetNodeInfoByName(self, node_name) source code
 
GetNodeInfoByName(self, node_name)
Get the objects.Node object for a named node.
source code
 
_UnlockedGetNodeName(self, node_spec) source code
string
GetNodeName(self, node_spec)
Gets the node name for the passed node.
source code
 
_UnlockedGetNodeNames(self, node_specs) source code
list of strings
GetNodeNames(self, node_specs)
Gets the node names for the passed list of nodes.
source code
frozenset
GetNodeGroupsFromNodes(self, node_uuids)
Returns groups for a list of nodes.
source code
tuple
_UnlockedGetMasterCandidateStats(self, exceptions=None)
Get the number of current and maximum desired and possible candidates.
source code
tuple
GetMasterCandidateStats(self, exceptions=None)
Get the number of current and maximum possible candidates.
source code
list
MaintainCandidatePool(self, exception_node_uuids)
Try to grow the candidate pool to the desired size.
source code
 
_UnlockedAddNodeToGroup(self, node_uuid, nodegroup_uuid)
Add a given node to the specified group.
source code
 
_UnlockedRemoveNodeFromGroup(self, node)
Remove a given node from its group.
source code
 
AssignGroupNodes(self, mods)
Changes the group of a number of nodes.
source code
 
_BumpSerialNo(self)
Bump up the serial number of the config.
source code
 
_AllUUIDObjects(self)
Returns all objects with uuid attributes.
source code
 
_OpenConfig(self, accept_foreign)
Read the config data from disk.
source code
 
_UpgradeConfig(self)
Run any upgrade steps.
source code
 
_DistributeConfig(self, feedback_fn)
Distribute the configuration to the other nodes.
source code
 
_WriteConfig(self, destination=None, feedback_fn=None)
Write the configuration data to persistent storage.
source code
dict of strings
_GetAllHvparamsStrings(self, hypervisors)
Get the hvparams of all given hypervisors from the config.
source code
dict
_UnlockedGetSsconfValues(self)
Return the values needed by ssconf.
source code
 
GetSsconfValues(self)
Wrapper using lock around _UnlockedGetSsconf().
source code
 
GetVGName(self)
Return the volume group name.
source code
 
SetVGName(self, vg_name)
Set the volume group name.
source code
 
GetDRBDHelper(self)
Return DRBD usermode helper.
source code
 
SetDRBDHelper(self, drbd_helper)
Set DRBD usermode helper.
source code
 
GetMACPrefix(self)
Return the mac prefix.
source code
objects.Cluster
GetClusterInfo(self)
Returns information about the cluster
source code
 
HasAnyDiskOfType(self, dev_type)
Check if in there is at disk of the given type in the configuration.
source code
 
Update(self, target, feedback_fn, ec_id=None)
Notify function to be called after updates.
source code
 
DropECReservations(self, ec_id)
Drop per-execution-context reservations
source code
 
GetAllNetworksInfo(self)
Get configuration info of all the networks.
source code
 
_UnlockedGetNetworkList(self)
Get the list of networks.
source code
 
GetNetworkList(self)
Get the list of networks.
source code
 
GetNetworkNames(self)
Get a list of network names
source code
 
_UnlockedGetNetwork(self, uuid)
Returns information about a network.
source code
objects.Network
GetNetwork(self, uuid)
Returns information about a network.
source code
 
AddNetwork(self, net, ec_id, check_uuid=True)
Add a network to the configuration.
source code
 
_UnlockedAddNetwork(self, net, ec_id, check_uuid)
Add a network to the configuration.
source code
string
_UnlockedLookupNetwork(self, target)
Lookup a network's UUID.
source code
string
LookupNetwork(self, target)
Lookup a network's UUID.
source code
 
RemoveNetwork(self, network_uuid)
Remove a network from the configuration.
source code
dict or None
_UnlockedGetGroupNetParams(self, net_uuid, node_uuid)
Get the netparams (mode, link) of a network.
source code
 
GetGroupNetParams(self, net_uuid, node_uuid)
Locking wrapper of _UnlockedGetGroupNetParams()
source code
(string, dict) or (None, None)
CheckIPInNodeGroup(self, ip, node_uuid)
Check IP uniqueness in nodegroup.
source code
Static Methods [hide private]
 
IsCluster()
Check if the cluster is configured.
source code
same as ssconf_values
_ExtendByAllHvparamsStrings(ssconf_values, all_hvparams)
Extends the ssconf_values dictionary by hvparams.
source code
Instance Variables [hide private]
  _all_rms
a list of all temporary reservation managers
  _temporary_lvs
reservation manager for temporary LVs
Method Details [hide private]

GetNdParams(self, node)

source code 

Get the node params populated with cluster defaults.

Parameters:
  • node (objects.Node) - The node we want to know the params for
Returns:
A dict with the filled in node params
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceDiskParams(self, instance)

source code 

Get the disk params populated with inherit chain.

Parameters:
Returns:
A dict with the filled in disk params
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetGroupDiskParams(self, group)

source code 

Get the disk params populated with inherit chain.

Parameters:
Returns:
A dict with the filled in disk params
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetGroupDiskParams(self, group)

source code 

Get the disk params populated with inherit chain down to node-group.

Parameters:
Returns:
A dict with the filled in disk params

_GenerateOneMAC(self, prefix=None)

source code 

Return a function that randomly generates a MAC suffic and appends it to the given prefix. If prefix is not given get the cluster level default.

GenerateMAC(self, net_uuid, ec_id)

source code 

Generate a MAC for an instance.

This should check the current instances for duplicates.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

ReserveMAC(self, mac, ec_id)

source code 

Reserve a MAC for an instance.

This only checks instances managed by this cluster, it does not check for potential collisions elsewhere.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedCommitIp(self, action, net_uuid, address)

source code 

Commit a reserved IP address to an IP pool.

The IP address is taken from the network's IP pool and marked as reserved.

_UnlockedReleaseIp(self, net_uuid, address, ec_id)

source code 

Give a specific IP address back to an IP pool.

The IP address is returned to the IP pool designated by pool_id and marked as reserved.

ReleaseIp(self, net_uuid, address, ec_id)

source code 

Give a specified IP address back to an IP pool.

This is just a wrapper around _UnlockedReleaseIp.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GenerateIp(self, net_uuid, ec_id)

source code 

Find a free IPv4 address for an instance.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

ReserveIp(self, net_uuid, address, ec_id)

source code 

Reserve a given IPv4 address for use by an instance.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

ReserveLV(self, lv_name, ec_id)

source code 

Reserve an VG/LV pair for an instance.

Parameters:
  • lv_name (string) - the logical volume name to reserve
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GenerateDRBDSecret(self, ec_id)

source code 

Generate a DRBD secret.

This checks the current disks for duplicates.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_AllIDs(self, include_temporary)

source code 

Compute the list of all UUIDs and names we have.

Parameters:
  • include_temporary (boolean) - whether to include the _temporary_ids set
Returns: set
a set of IDs

_GenerateUniqueID(self, ec_id)

source code 

Generate an unique UUID.

This checks the current node, instances and disk names for duplicates.

Returns: string
the unique id

GenerateUniqueID(self, ec_id)

source code 

Generate an unique ID.

This is just a wrapper over the unlocked version.

Parameters:
  • ec_id (string) - unique id for the job to reserve the id to
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_AllMACs(self)

source code 

Return all MACs present in the config.

Returns: list
the list of all MACs

_AllDRBDSecrets(self)

source code 

Return all DRBD secrets present in the config.

Returns: list
the list of all DRBD secrets

_CheckDiskIDs(self, disk, l_ids, p_ids)

source code 

Compute duplicate disk IDs

Parameters:
  • disk (objects.Disk) - the disk at which to start searching
  • l_ids (list) - list of current logical ids
  • p_ids (list) - list of current physical ids
Returns: list
a list of error messages

_UnlockedVerifyConfig(self)

source code 

Verify function.

Returns: list
a list of error messages; a non-empty list signifies configuration errors

VerifyConfig(self)

source code 

Verify function.

This is just a wrapper over _UnlockedVerifyConfig.

Returns: list
a list of error messages; a non-empty list signifies configuration errors
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedSetDiskID(self, disk, node_uuid)

source code 

Convert the unique ID to the ID needed on the target nodes.

This is used only for drbd, which needs ip/port configuration.

The routine descends down and updates its children also, because this helps when the only the top device is passed to the remote node.

This function is for internal use, when the config lock is already held.

SetDiskID(self, disk, node_uuid)

source code 

Convert the unique ID to the ID needed on the target nodes.

This is used only for drbd, which needs ip/port configuration.

The routine descends down and updates its children also, because this helps when the only the top device is passed to the remote node.

Decorators:
  • @locking.ssynchronized(_config_lock)

AddTcpUdpPort(self, port)

source code 

Adds a new port to the available port pool.

Decorators:
  • @locking.ssynchronized(_config_lock)

Warning: this method does not "flush" the configuration (via _WriteConfig); callers should do that themselves once the configuration is stable

GetPortList(self)

source code 

Returns a copy of the current port list.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

AllocatePort(self)

source code 

Allocate a port.

The port will be taken from the available port pool or from the default port range (and in this case we increase highest_used_port).

Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedComputeDRBDMap(self)

source code 

Compute the used DRBD minor/nodes.

Returns: (dict, list)
dictionary of node_uuid: dict of minor: instance_uuid; the returned dict will have all the nodes in it (even if with an empty list), and a list of duplicates; if the duplicates list is not empty, the configuration is corrupted and its caller should raise an exception

ComputeDRBDMap(self)

source code 

Compute the used DRBD minor/nodes.

This is just a wrapper over _UnlockedComputeDRBDMap.

Returns:
dictionary of node_uuid: dict of minor: instance_uuid; the returned dict will have all the nodes in it (even if with an empty list).
Decorators:
  • @locking.ssynchronized(_config_lock)

AllocateDRBDMinor(self, node_uuids, inst_uuid)

source code 

Allocate a drbd minor.

The free minor will be automatically computed from the existing devices. A node can be given multiple times in order to allocate multiple minors. The result is the list of minors, in the same order as the passed nodes.

Parameters:
  • inst_uuid (string) - the instance for which we allocate minors
Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedReleaseDRBDMinors(self, inst_uuid)

source code 

Release temporary drbd minors allocated for a given instance.

Parameters:
  • inst_uuid (string) - the instance for which temporary minors should be released

ReleaseDRBDMinors(self, inst_uuid)

source code 

Release temporary drbd minors allocated for a given instance.

This should be called on the error paths, on the success paths it's automatically called by the ConfigWriter add and update functions.

This function is just a wrapper over _UnlockedReleaseDRBDMinors.

Parameters:
  • inst_uuid (string) - the instance for which temporary minors should be released
Decorators:
  • @locking.ssynchronized(_config_lock)

GetConfigVersion(self)

source code 

Get the configuration version.

Returns:
Config version
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetClusterName(self)

source code 

Get cluster name.

Returns:
Cluster name
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterNode(self)

source code 

Get the UUID of the master node for this cluster.

Returns:
Master node UUID
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterNodeName(self)

source code 

Get the hostname of the master node for this cluster.

Returns:
Master node hostname
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterIP(self)

source code 

Get the IP of the master node for this cluster.

Returns:
Master IP
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterNetdev(self)

source code 

Get the master network device for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterNetmask(self)

source code 

Get the netmask of the master node for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetUseExternalMipScript(self)

source code 

Get flag representing whether to use the external master IP setup script.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetFileStorageDir(self)

source code 

Get the file storage dir for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetSharedFileStorageDir(self)

source code 

Get the shared file storage dir for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetHypervisorType(self)

source code 

Get the hypervisor type for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetRsaHostKey(self)

source code 

Return the rsa hostkey from the config.

Returns: string
the rsa hostkey
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetDsaHostKey(self)

source code 

Return the dsa hostkey from the config.

Returns: string
the dsa hostkey
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetDefaultIAllocator(self)

source code 

Get the default instance allocator for this cluster.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetPrimaryIPFamily(self)

source code 

Get cluster primary ip family.

Returns:
primary ip family
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMasterNetworkParameters(self)

source code 

Get network parameters of the master node.

Returns: object.MasterNetworkParameters
network parameters of the master node
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

AddNodeGroup(self, group, ec_id, check_uuid=True)

source code 

Add a node group to the configuration.

This method calls group.UpgradeConfig() to fill any missing attributes according to their default values.

Parameters:
  • group (objects.NodeGroup) - the NodeGroup object to add
  • ec_id (string) - unique id for the job to use when creating a missing UUID
  • check_uuid (bool) - add an UUID to the group if it doesn't have one or, if it does, ensure that it does not exist in the configuration already
Decorators:
  • @locking.ssynchronized(_config_lock)

RemoveNodeGroup(self, group_uuid)

source code 

Remove a node group from the configuration.

Parameters:
  • group_uuid (string) - the UUID of the node group to remove
Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedLookupNodeGroup(self, target)

source code 

Lookup a node group's UUID.

Parameters:
  • target (string or None) - group name or UUID or None to look for the default
Returns: string
nodegroup UUID
Raises:

LookupNodeGroup(self, target)

source code 

Lookup a node group's UUID.

This function is just a wrapper over _UnlockedLookupNodeGroup.

Parameters:
  • target (string or None) - group name or UUID or None to look for the default
Returns: string
nodegroup UUID
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetNodeGroup(self, uuid)

source code 

Lookup a node group.

Parameters:
  • uuid (string) - group UUID
Returns: objects.NodeGroup or None
nodegroup object, or None if not found

GetNodeGroup(self, uuid)

source code 

Lookup a node group.

Parameters:
  • uuid (string) - group UUID
Returns: objects.NodeGroup or None
nodegroup object, or None if not found
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetAllNodeGroupsInfo(self)

source code 

Get the configuration of all node groups.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeGroupList(self)

source code 

Get a list of node groups.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeGroupMembersByNodes(self, nodes)

source code 

Get nodes which are member in the same nodegroups as the given nodes.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMultiNodeGroupInfo(self, group_uuids)

source code 

Get the configuration of multiple node groups.

Parameters:
  • group_uuids - List of node group UUIDs
Returns: list
List of tuples of (group_uuid, group_info)
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

AddInstance(self, instance, ec_id)

source code 

Add an instance to the config.

This should be used after creating a new instance.

Parameters:
Decorators:
  • @locking.ssynchronized(_config_lock)

_EnsureUUID(self, item, ec_id)

source code 

Ensures a given object has a valid UUID.

Parameters:
  • item - the instance or node to be checked
  • ec_id - the execution context id for the uuid reservation

_CheckUniqueUUID(self, item, include_temporary)

source code 

Checks that the UUID of the given object is unique.

Parameters:
  • item - the instance or node to be checked
  • include_temporary - whether temporarily generated UUID's should be included in the check. If the UUID of the item to be checked is a temporarily generated one, this has to be False.

MarkInstanceUp(self, inst_uuid)

source code 

Mark the instance status to up in the config.

This also sets the instance disks active flag.

Decorators:
  • @locking.ssynchronized(_config_lock)

MarkInstanceOffline(self, inst_uuid)

source code 

Mark the instance status to down in the config.

This also clears the instance disks active flag.

Decorators:
  • @locking.ssynchronized(_config_lock)

RemoveInstance(self, inst_uuid)

source code 

Remove the instance from the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock)

RenameInstance(self, inst_uuid, new_name)

source code 

Rename an instance.

This needs to be done in ConfigWriter and not by RemoveInstance combined with AddInstance as only we can guarantee an atomic rename.

Decorators:
  • @locking.ssynchronized(_config_lock)

MarkInstanceDown(self, inst_uuid)

source code 

Mark the status of an instance to down in the configuration.

This does not touch the instance disks active flag, as shut down instances can still have active disks.

Decorators:
  • @locking.ssynchronized(_config_lock)

MarkInstanceDisksActive(self, inst_uuid)

source code 

Mark the status of instance disks active.

Decorators:
  • @locking.ssynchronized(_config_lock)

MarkInstanceDisksInactive(self, inst_uuid)

source code 

Mark the status of instance disks inactive.

Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedGetInstanceList(self)

source code 

Get the list of instances.

This function is for internal use, when the config lock is already held.

GetInstanceList(self)

source code 

Get the list of instances.

Returns:
array of instances, ex. ['instance2-uuid', 'instance1-uuid']
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetInstanceInfo(self, inst_uuid)

source code 

Returns information about an instance.

This function is for internal use, when the config lock is already held.

GetInstanceInfo(self, inst_uuid)

source code 

Returns information about an instance.

It takes the information from the configuration file. Other information of an instance are taken from the live systems.

Parameters:
  • inst_uuid - UUID of the instance
Returns: objects.Instance
the instance object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceNodeGroups(self, inst_uuid, primary_only=False)

source code 

Returns set of node group UUIDs for instance's nodes.

Returns: frozenset
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceNetworks(self, inst_uuid)

source code 

Returns set of network UUIDs for instance's nics.

Returns: frozenset
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMultiInstanceInfo(self, inst_uuids)

source code 

Get the configuration of multiple instances.

Parameters:
  • inst_uuids - list of instance UUIDs
Returns: list
list of tuples (instance UUID, instance_info), where instance_info is what would GetInstanceInfo return for the node, while keeping the original order
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMultiInstanceInfoByName(self, inst_names)

source code 

Get the configuration of multiple instances.

Parameters:
  • inst_names - list of instance names
Returns: list
list of tuples (instance, instance_info), where instance_info is what would GetInstanceInfo return for the node, while keeping the original order
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetAllInstancesInfo(self)

source code 

Get the configuration of all instances.

Returns: dict
dict of (instance, instance_info), where instance_info is what would GetInstanceInfo return for the node
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstancesInfoByFilter(self, filter_fn)

source code 

Get instance configuration with a filter.

Parameters:
  • filter_fn (callable) - Filter function receiving instance object as parameter, returning boolean. Important: this function is called while the configuration locks is held. It must not do any complex work or call functions potentially leading to a deadlock. Ideally it doesn't call any other functions and just compares instance attributes.
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceInfoByName(self, inst_name)

source code 

Get the objects.Instance object for a named instance.

Parameters:
  • inst_name (string) - name of the instance to get information for
Returns:
the corresponding objects.Instance instance or None if no information is available
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceName(self, inst_uuid)

source code 

Gets the instance name for the passed instance.

Parameters:
  • inst_uuid (string) - instance UUID to get name for
Returns: string
instance name
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceNames(self, inst_uuids)

source code 

Gets the instance names for the passed list of nodes.

Parameters:
  • inst_uuids (list of strings) - list of instance UUIDs to get names for
Returns: list of strings
list of instance names
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

AddNode(self, node, ec_id)

source code 

Add a node to the configuration.

Parameters:
Decorators:
  • @locking.ssynchronized(_config_lock)

RemoveNode(self, node_uuid)

source code 

Remove a node from the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedGetNodeInfo(self, node_uuid)

source code 

Get the configuration of a node, as stored in the config.

This function is for internal use, when the config lock is already held.

Parameters:
  • node_uuid - the node UUID
Returns: objects.Node
the node object

GetNodeInfo(self, node_uuid)

source code 

Get the configuration of a node, as stored in the config.

This is just a locked wrapper over _UnlockedGetNodeInfo.

Parameters:
  • node_uuid - the node UUID
Returns: objects.Node
the node object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeInstances(self, node_uuid)

source code 

Get the instances of a node, as stored in the config.

Parameters:
  • node_uuid - the node UUID
Returns: (list, list)
a tuple with two lists: the primary and the secondary instances
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeGroupInstances(self, uuid, primary_only=False)

source code 

Get the instances of a node group.

Parameters:
  • uuid - Node group UUID
  • primary_only - Whether to only consider primary nodes
Returns: frozenset
List of instance UUIDs in node group
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetHvparamsString(self, hvname)

source code 

Return the string representation of the list of hyervisor parameters of the given hypervisor.

See Also: GetHvparams

GetHvparamsString(self, hvname)

source code 

Return the hypervisor parameters of the given hypervisor.

Parameters:
  • hvname (string) - name of a hypervisor
Returns: string
string containing key-value-pairs, one pair on each line; format: KEY=VALUE
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetNodeList(self)

source code 

Return the list of nodes which are in the configuration.

This function is for internal use, when the config lock is already held.

Returns: list

GetNodeList(self)

source code 

Return the list of nodes which are in the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetOnlineNodeList(self)

source code 

Return the list of nodes which are online.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetVmCapableNodeList(self)

source code 

Return the list of nodes which are not vm capable.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNonVmCapableNodeList(self)

source code 

Return the list of nodes which are not vm capable.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetMultiNodeInfo(self, node_uuids)

source code 

Get the configuration of multiple nodes.

Parameters:
  • node_uuids - list of node UUIDs
Returns: list
list of tuples of (node, node_info), where node_info is what would GetNodeInfo return for the node, in the original order
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetAllNodesInfo(self)

source code 

Gets configuration of all nodes.

Note: See GetAllNodesInfo

GetAllNodesInfo(self)

source code 

Get the configuration of all nodes.

Returns: dict
dict of (node, node_info), where node_info is what would GetNodeInfo return for the node
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeInfoByName(self, node_name)

source code 

Get the objects.Node object for a named node.

Parameters:
  • node_name (string) - name of the node to get information for
Returns:
the corresponding objects.Node instance or None if no information is available
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeName(self, node_spec)

source code 

Gets the node name for the passed node.

Parameters:
  • node_spec (either node UUID or a objects.Node object) - node to get names for
Returns: string
node name
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeNames(self, node_specs)

source code 

Gets the node names for the passed list of nodes.

Parameters:
  • node_specs (list of either node UUIDs or objects.Node objects) - list of nodes to get names for
Returns: list of strings
list of node names
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeGroupsFromNodes(self, node_uuids)

source code 

Returns groups for a list of nodes.

Parameters:
  • node_uuids (list of string) - List of node UUIDs
Returns: frozenset
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetMasterCandidateStats(self, exceptions=None)

source code 

Get the number of current and maximum desired and possible candidates.

Parameters:
  • exceptions (list) - if passed, list of nodes that should be ignored
Returns: tuple
tuple of (current, desired and possible, possible)

GetMasterCandidateStats(self, exceptions=None)

source code 

Get the number of current and maximum possible candidates.

This is just a wrapper over _UnlockedGetMasterCandidateStats.

Parameters:
  • exceptions (list) - if passed, list of nodes that should be ignored
Returns: tuple
tuple of (current, max)
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

MaintainCandidatePool(self, exception_node_uuids)

source code 

Try to grow the candidate pool to the desired size.

Parameters:
  • exception_node_uuids (list) - if passed, list of nodes that should be ignored
Returns: list
list with the adjusted nodes (objects.Node instances)
Decorators:
  • @locking.ssynchronized(_config_lock)

AssignGroupNodes(self, mods)

source code 

Changes the group of a number of nodes.

Parameters:
  • mods (list of tuples; (node name, new group UUID)) - Node membership modifications
Decorators:
  • @locking.ssynchronized(_config_lock)

_UpgradeConfig(self)

source code 

Run any upgrade steps.

This method performs both in-object upgrades and also update some data elements that need uniqueness across the whole configuration or interact with other objects.

Warning: this function will call _WriteConfig(), but also DropECReservations so it needs to be called only from a "safe" place (the constructor). If one wanted to call it with the lock held, a DropECReservationUnlocked would need to be created first, to avoid causing deadlock.

_DistributeConfig(self, feedback_fn)

source code 

Distribute the configuration to the other nodes.

Currently, this only copies the configuration file. In the future, it could be used to encapsulate the 2/3-phase update mechanism.

_GetAllHvparamsStrings(self, hypervisors)

source code 

Get the hvparams of all given hypervisors from the config.

Parameters:
  • hypervisors (list of string) - list of hypervisor names
Returns: dict of strings
dictionary mapping the hypervisor name to a string representation of the hypervisor's hvparams

_ExtendByAllHvparamsStrings(ssconf_values, all_hvparams)
Static Method

source code 

Extends the ssconf_values dictionary by hvparams.

Parameters:
  • ssconf_values (dict of strings) - dictionary mapping ssconf_keys to strings representing the content of ssconf files
  • all_hvparams (dict of strings) - dictionary mapping hypervisor names to a string representation of their hvparams
Returns: same as ssconf_values
the ssconf_values dictionary extended by hvparams

_UnlockedGetSsconfValues(self)

source code 

Return the values needed by ssconf.

Returns: dict
a dictionary with keys the ssconf names and values their associated value

GetSsconfValues(self)

source code 

Wrapper using lock around _UnlockedGetSsconf().

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetVGName(self)

source code 

Return the volume group name.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

SetVGName(self, vg_name)

source code 

Set the volume group name.

Decorators:
  • @locking.ssynchronized(_config_lock)

GetDRBDHelper(self)

source code 

Return DRBD usermode helper.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

SetDRBDHelper(self, drbd_helper)

source code 

Set DRBD usermode helper.

Decorators:
  • @locking.ssynchronized(_config_lock)

GetMACPrefix(self)

source code 

Return the mac prefix.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetClusterInfo(self)

source code 

Returns information about the cluster

Returns: objects.Cluster
the cluster object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

HasAnyDiskOfType(self, dev_type)

source code 

Check if in there is at disk of the given type in the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

Update(self, target, feedback_fn, ec_id=None)

source code 

Notify function to be called after updates.

This function must be called when an object (as returned by GetInstanceInfo, GetNodeInfo, GetCluster) has been updated and the caller wants the modifications saved to the backing store. Note that all modified objects will be saved, but the target argument is the one the caller wants to ensure that it's saved.

Parameters:
Decorators:
  • @locking.ssynchronized(_config_lock)

DropECReservations(self, ec_id)

source code 

Drop per-execution-context reservations

Decorators:
  • @locking.ssynchronized(_config_lock)

GetAllNetworksInfo(self)

source code 

Get configuration info of all the networks.

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetNetworkList(self)

source code 

Get the list of networks.

This function is for internal use, when the config lock is already held.

GetNetworkList(self)

source code 

Get the list of networks.

Returns:
array of networks, ex. ["main", "vlan100", "200]
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNetworkNames(self)

source code 

Get a list of network names

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetNetwork(self, uuid)

source code 

Returns information about a network.

This function is for internal use, when the config lock is already held.

GetNetwork(self, uuid)

source code 

Returns information about a network.

It takes the information from the configuration file.

Parameters:
  • uuid - UUID of the network
Returns: objects.Network
the network object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

AddNetwork(self, net, ec_id, check_uuid=True)

source code 

Add a network to the configuration.

Parameters:
  • net (objects.Network) - the Network object to add
  • ec_id (string) - unique id for the job to use when creating a missing UUID
Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedLookupNetwork(self, target)

source code 

Lookup a network's UUID.

Parameters:
  • target (string) - network name or UUID
Returns: string
network UUID
Raises:

LookupNetwork(self, target)

source code 

Lookup a network's UUID.

This function is just a wrapper over _UnlockedLookupNetwork.

Parameters:
  • target (string) - network name or UUID
Returns: string
network UUID
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

RemoveNetwork(self, network_uuid)

source code 

Remove a network from the configuration.

Parameters:
  • network_uuid (string) - the UUID of the network to remove
Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedGetGroupNetParams(self, net_uuid, node_uuid)

source code 

Get the netparams (mode, link) of a network.

Get a network's netparams for a given node.

Parameters:
  • net_uuid (string) - network uuid
  • node_uuid (string) - node UUID
Returns: dict or None
netparams

GetGroupNetParams(self, net_uuid, node_uuid)

source code 

Locking wrapper of _UnlockedGetGroupNetParams()

Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

CheckIPInNodeGroup(self, ip, node_uuid)

source code 

Check IP uniqueness in nodegroup.

Check networks that are connected in the node's node group if ip is contained in any of them. Used when creating/adding a NIC to ensure uniqueness among nodegroups.

Parameters:
  • ip (string) - ip address
  • node_uuid (string) - node UUID
Returns: (string, dict) or (None, None)
(network name, netparams)
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)