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
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_name)
Convert the unique ID to the ID needed on the target nodes.
source code
 
SetDiskID(self, disk, node_name)
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, nodes, instance)
Allocate a drbd minor.
source code
 
_UnlockedReleaseDRBDMinors(self, instance)
Release temporary drbd minors allocated for a given instance.
source code
 
ReleaseDRBDMinors(self, instance)
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 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
GetHostKey(self)
Return the rsa 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
 
_SetInstanceStatus(self, instance_name, status)
Set the instance's status to a given value.
source code
 
MarkInstanceUp(self, instance_name)
Mark the instance status to up in the config.
source code
 
MarkInstanceOffline(self, instance_name)
Mark the instance status to down in the config.
source code
 
RemoveInstance(self, instance_name)
Remove the instance from the configuration.
source code
 
RenameInstance(self, old_name, new_name)
Rename an instance.
source code
 
MarkInstanceDown(self, instance_name)
Mark the status of an instance to down in the configuration.
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, instance_name)
Returns information about an instance.
source code
objects.Instance
GetInstanceInfo(self, instance_name)
Returns information about an instance.
source code
frozenset
GetInstanceNodeGroups(self, instance_name, primary_only=False)
Returns set of node group UUIDs for instance's nodes.
source code
frozenset
GetInstanceNetworks(self, instance_name)
Returns set of network UUIDs for instance's nics.
source code
list
GetMultiInstanceInfo(self, instances)
Get the configuration of multiple instances.
source code
dict
GetAllInstancesInfo(self)
Get the configuration of all instances.
source code
 
GetInstancesInfoByFilter(self, filter_fn)
Get instance configuration with a filter.
source code
 
AddNode(self, node, ec_id)
Add a node to the configuration.
source code
 
RemoveNode(self, node_name)
Remove a node from the configuration.
source code
 
ExpandNodeName(self, short_name)
Attempt to expand an incomplete node name.
source code
objects.Node
_UnlockedGetNodeInfo(self, node_name)
Get the configuration of a node, as stored in the config.
source code
objects.Node
GetNodeInfo(self, node_name)
Get the configuration of a node, as stored in the config.
source code
(list, list)
GetNodeInstances(self, node_name)
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
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, nodes)
Get the configuration of multiple nodes.
source code
dict
GetAllNodesInfo(self)
Get the configuration of all nodes.
source code
 
_UnlockedGetAllNodesInfo(self)
Gets configuration of all nodes.
source code
frozenset
GetNodeGroupsFromNodes(self, nodes)
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, exceptions)
Try to grow the candidate pool to the desired size.
source code
 
_UnlockedAddNodeToGroup(self, node_name, 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
_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)
Get the netparams (mode, link) of a network.
source code
 
GetGroupNetParams(self, net_uuid, node)
Locking wrapper of _UnlockedGetGroupNetParams()
source code
(string, dict) or (None, None)
CheckIPInNodeGroup(self, ip, node)
Check IP uniqueness in nodegroup.
source code
Static Methods [hide private]
 
IsCluster()
Check if the cluster is configured.
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_name)

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_name)

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_name: dict of minor: instance_name; 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_name: dict of minor: instance_name; the returned dict will have all the nodes in it (even if with an empty list).
Decorators:
  • @locking.ssynchronized(_config_lock)

AllocateDRBDMinor(self, nodes, instance)

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:
  • instance (string) - the instance for which we allocate minors
Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedReleaseDRBDMinors(self, instance)

source code 

Release temporary drbd minors allocated for a given instance.

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

ReleaseDRBDMinors(self, instance)

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:
  • instance (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 hostname of the master node for this cluster.

Returns:
Master 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)

GetHostKey(self)

source code 

Return the rsa hostkey from the config.

Returns: string
the rsa 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

MarkInstanceUp(self, instance_name)

source code 

Mark the instance status to up in the config.

Decorators:
  • @locking.ssynchronized(_config_lock)

MarkInstanceOffline(self, instance_name)

source code 

Mark the instance status to down in the config.

Decorators:
  • @locking.ssynchronized(_config_lock)

RemoveInstance(self, instance_name)

source code 

Remove the instance from the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock)

RenameInstance(self, old_name, 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, instance_name)

source code 

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

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.example.com', 'instance1.example.com']
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

_UnlockedGetInstanceInfo(self, instance_name)

source code 

Returns information about an instance.

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

GetInstanceInfo(self, instance_name)

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:
  • instance_name - name of the instance, e.g. instance1.example.com
Returns: objects.Instance
the instance object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetInstanceNodeGroups(self, instance_name, 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, instance_name)

source code 

Returns set of network UUIDs for instance's nics.

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

GetMultiInstanceInfo(self, instances)

source code 

Get the configuration of multiple instances.

Parameters:
  • instances - 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)

AddNode(self, node, ec_id)

source code 

Add a node to the configuration.

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

RemoveNode(self, node_name)

source code 

Remove a node from the configuration.

Decorators:
  • @locking.ssynchronized(_config_lock)

_UnlockedGetNodeInfo(self, node_name)

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_name - the node name, e.g. node1.example.com
Returns: objects.Node
the node object

GetNodeInfo(self, node_name)

source code 

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

This is just a locked wrapper over _UnlockedGetNodeInfo.

Parameters:
  • node_name - the node name, e.g. node1.example.com
Returns: objects.Node
the node object
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)

GetNodeInstances(self, node_name)

source code 

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

Parameters:
  • node_name - the node name, e.g. node1.example.com
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 names in node group
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, nodes)

source code 

Get the configuration of multiple nodes.

Parameters:
  • nodes - list of node names
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)

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)

_UnlockedGetAllNodesInfo(self)

source code 

Gets configuration of all nodes.

Note: See GetAllNodesInfo

GetNodeGroupsFromNodes(self, nodes)

source code 

Returns groups for a list of nodes.

Parameters:
  • nodes (list of string) - List of node names
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, exceptions)

source code 

Try to grow the candidate pool to the desired size.

Parameters:
  • exceptions (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.

_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)

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 (string) - node name
Returns: dict or None
netparams

GetGroupNetParams(self, net_uuid, node)

source code 

Locking wrapper of _UnlockedGetGroupNetParams()

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

CheckIPInNodeGroup(self, ip, node)

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 (string) - node name
Returns: (string, dict) or (None, None)
(network name, netparams)
Decorators:
  • @locking.ssynchronized(_config_lock, shared= 1)