module documentation

Functions to bootstrap a new cluster.

Function FinalizeClusterDestroy Execute the last steps of cluster destroy
Function GenerateClusterCrypto Updates the cluster certificates, keys and secrets.
Function GenerateHmacKey Writes a new HMAC key.
Function GetMaster Returns the current master node.
Function InitCluster Initialise the cluster.
Function InitConfig Create the initial cluster configuration.
Function MajorityHealthy Check if the majority of nodes is healthy
Function MasterFailover Failover the master node.
Function SetupNodeDaemon Add a node to the cluster.
Function _GatherMasterVotes Check the agreement on who is the master.
Function _InitCheckDrbdHelper Checks the DRBD usermode helper.
Function _InitCheckEnabledDiskTemplates Checks the sanity of the enabled disk templates.
Function _InitFileStorageDir Initialize if needed the file storage.
Function _InitGanetiServerSetup Setup the necessary configuration for the initial node daemon.
Function _PrepareFileBasedStorage Checks if a file-base storage type is enabled and inits the dir.
Function _PrepareFileStorage Checks if file storage is enabled and inits the dir.
Function _PrepareGlusterStorage Checks if gluster storage is enabled and inits the dir.
Function _PrepareSharedFileStorage Checks if shared file storage is enabled and inits the dir.
Function _RestrictIpolicyToEnabledDiskTemplates Restricts the ipolicy's disk templates to the enabled ones.
Function _WaitForMasterDaemon Wait for master daemon to become responsive.
Function _WaitForNodeDaemon Wait for node daemon to become responsive.
Function _WaitForSshDaemon Wait for SSH daemon to become responsive.
Constant _DAEMON_READY_TIMEOUT Undocumented
Constant _INITCONF_ECID Undocumented
def FinalizeClusterDestroy(master_uuid):

Execute the last steps of cluster destroy

This function shuts down all the daemons, completing the destroy begun in cmdlib.LUDestroyOpcode.

def GenerateClusterCrypto(new_cluster_cert, new_rapi_cert, new_spice_cert, new_confd_hmac_key, new_cds, new_client_cert, master_name, rapi_cert_pem=None, spice_cert_pem=None, spice_cacert_pem=None, cds=None, nodecert_file=pathutils.NODED_CERT_FILE, clientcert_file=pathutils.NODED_CLIENT_CERT_FILE, rapicert_file=pathutils.RAPI_CERT_FILE, spicecert_file=pathutils.SPICE_CERT_FILE, spicecacert_file=pathutils.SPICE_CACERT_FILE, hmackey_file=pathutils.CONFD_HMAC_KEY, cds_file=pathutils.CLUSTER_DOMAIN_SECRET_FILE):

Updates the cluster certificates, keys and secrets.

Parameters
new_cluster_cert:boolWhether to generate a new cluster certificate
new_rapi_cert:boolWhether to generate a new RAPI certificate
new_spice_cert:boolWhether to generate a new SPICE certificate
new_confd_hmac_key:boolWhether to generate a new HMAC key
new_cds:boolWhether to generate a new cluster domain secret
new_client_cert:boolWhether to generate a new client certificate
master_name:stringFQDN of the master node
rapi_cert_pem:stringNew RAPI certificate in PEM format
spice_cert_pem:stringNew SPICE certificate in PEM format
spice_cacert_pem:stringCertificate of the CA that signed the SPICE certificate, in PEM format
cds:stringNew cluster domain secret
nodecert_file:stringoptional override of the node cert file path
clientcert_fileUndocumented
rapicert_file:stringoptional override of the rapi cert file path
spicecert_file:stringoptional override of the spice cert file path
spicecacert_file:stringoptional override of the spice CA cert file path
hmackey_file:stringoptional override of the hmac key file path
cds_fileUndocumented
def GenerateHmacKey(file_name):

Writes a new HMAC key.

Parameters
file_name:strPath to output file
def GetMaster():

Returns the current master node.

This is a separate function in bootstrap since it's needed by gnt-cluster, and instead of importing directly ssconf, it's better to abstract it in bootstrap, where we do use ssconf in other functions too.

def InitCluster(cluster_name, mac_prefix, master_netmask, master_netdev, file_storage_dir, shared_file_storage_dir, gluster_storage_dir, candidate_pool_size, ssh_key_type, ssh_key_bits, secondary_ip=None, vg_name=None, beparams=None, nicparams=None, ndparams=None, hvparams=None, diskparams=None, enabled_hypervisors=None, modify_etc_hosts=True, modify_ssh_setup=True, maintain_node_health=False, drbd_helper=None, uid_pool=None, default_iallocator=None, default_iallocator_params=None, primary_ip_version=None, ipolicy=None, prealloc_wipe_disks=False, use_external_mip_script=False, hv_state=None, disk_state=None, enabled_disk_templates=None, install_image=None, zeroing_image=None, compression_tools=None, enabled_user_shutdown=False):

Initialise the cluster.

Parameters
cluster_nameUndocumented
mac_prefixUndocumented
master_netmaskUndocumented
master_netdevUndocumented
file_storage_dirUndocumented
shared_file_storage_dirUndocumented
gluster_storage_dirUndocumented
candidate_pool_size:intmaster candidate pool size
ssh_key_typeUndocumented
ssh_key_bitsUndocumented
secondary_ipUndocumented
vg_nameUndocumented
beparamsUndocumented
nicparamsUndocumented
ndparamsUndocumented
hvparamsUndocumented
diskparamsUndocumented
enabled_hypervisorsUndocumented
modify_etc_hostsUndocumented
modify_ssh_setupUndocumented
maintain_node_healthUndocumented
drbd_helperUndocumented
uid_poolUndocumented
default_iallocatorUndocumented
default_iallocator_paramsUndocumented
primary_ip_versionUndocumented
ipolicyUndocumented
prealloc_wipe_disksUndocumented
use_external_mip_scriptUndocumented
hv_stateUndocumented
disk_stateUndocumented
enabled_disk_templates:list of stringlist of disk_templates to be used in this cluster
install_imageUndocumented
zeroing_imageUndocumented
compression_toolsUndocumented
enabled_user_shutdown:boolwhether user shutdown is enabled cluster wide
def InitConfig(version, cluster_config, master_node_config, cfg_file=pathutils.CLUSTER_CONF_FILE):

Create the initial cluster configuration.

It will contain the current node, which will also be the master node, and no instances.

Parameters
version:intconfiguration version
cluster_config:objects.Clustercluster configuration
master_node_config:objects.Nodemaster node configuration
cfg_file:stringconfiguration file path
def MajorityHealthy(ignore_offline_nodes=False):

Check if the majority of nodes is healthy

Gather master votes from all nodes known to this node; return True if a strict majority of nodes is reachable and has some opinion on which node is master. Note that this will not guarantee any node to win an election but it ensures that a standard master-failover is still possible.

Returns
tuple of (boolean, [str]); the first is if a majority of nodes are healthy, the second is a list of the node names that are not considered healthy.
def MasterFailover(no_voting=False):

Failover the master node.

This checks that we are not already the master, and will cause the current master to cease being master, and the non-master to become new master.

Note: The call to MasterFailover from lib/client/gnt_cluster.py checks that a majority of nodes are healthy and responding before calling this. If this function is called from somewhere else, the caller should also verify that a majority of nodes are healthy.

Parameters
no_voting:booleanforce the operation without remote nodes agreement (dangerous)
Returns
the pair of an exit code and warnings to display
def SetupNodeDaemon(opts, cluster_name, node, ssh_port):

Add a node to the cluster.

This function must be called before the actual opcode, and will ssh to the remote node, copy the needed files, and start ganeti-noded, allowing the master to do the rest via normal rpc calls.

Parameters
optsUndocumented
cluster_namethe cluster name
nodethe name of the new node
ssh_portthe SSH port of the new node
def _GatherMasterVotes(node_names):

Check the agreement on who is the master.

This function will return a list of (node, number of votes), ordered by the number of votes.

Note that the sum of votes is the number of nodes this machine knows, whereas the number of entries in the list could be different (if some nodes vote for another master).

Parameters
node_names:listthe list of nodes to query for master info
Returns
listlist of (node, votes)
def _InitCheckDrbdHelper(drbd_helper, drbd_enabled):

Checks the DRBD usermode helper.

Parameters
drbd_helper:stringname of the DRBD usermode helper that the system should use
drbd_enabledUndocumented
def _InitCheckEnabledDiskTemplates(enabled_disk_templates):

Checks the sanity of the enabled disk templates.

def _InitFileStorageDir(file_storage_dir):

Initialize if needed the file storage.

Parameters
file_storage_dirthe user-supplied value
Returns
either empty string (if file storage was disabled at build time) or the normalized path to the storage directory
def _InitGanetiServerSetup(master_name, cfg):

Setup the necessary configuration for the initial node daemon.

This creates the nodepass file containing the shared password for the cluster, generates the SSL certificate and starts the node daemon.

Parameters
master_name:strName of the master node
cfg:ConfigWriterthe configuration writer
def _PrepareFileBasedStorage(enabled_disk_templates, file_storage_dir, default_dir, file_disk_template, _storage_path_acceptance_fn, init_fn=_InitFileStorageDir, acceptance_fn=None):

Checks if a file-base storage type is enabled and inits the dir.

Parameters
enabled_disk_templates:list of stringlist of enabled disk templates
file_storage_dir:stringthe file storage directory
default_dir:stringdefault file storage directory when file_storage_dir is 'None'
file_disk_template:stringa disk template whose storage type is 'ST_FILE', 'ST_SHARED_FILE' or 'ST_GLUSTER'
_storage_path_acceptance_fn:functionchecks whether the given file-based storage directory is acceptable
init_fnUndocumented
acceptance_fnUndocumented
Returns
stringthe name of the actual file storage directory
See Also
cluster.CheckFileBasedStoragePathVsEnabledDiskTemplates for details
def _PrepareFileStorage(enabled_disk_templates, file_storage_dir, init_fn=_InitFileStorageDir, acceptance_fn=None):

Checks if file storage is enabled and inits the dir.

See Also
_PrepareFileBasedStorage
def _PrepareGlusterStorage(enabled_disk_templates, file_storage_dir, init_fn=_InitFileStorageDir, acceptance_fn=None):

Checks if gluster storage is enabled and inits the dir.

See Also
_PrepareFileBasedStorage
def _PrepareSharedFileStorage(enabled_disk_templates, file_storage_dir, init_fn=_InitFileStorageDir, acceptance_fn=None):

Checks if shared file storage is enabled and inits the dir.

See Also
_PrepareFileBasedStorage
def _RestrictIpolicyToEnabledDiskTemplates(ipolicy, enabled_disk_templates):

Restricts the ipolicy's disk templates to the enabled ones.

This function clears the ipolicy's list of allowed disk templates from the ones that are not enabled by the cluster.

Parameters
ipolicy:dictthe instance policy
enabled_disk_templates:list of stringthe list of cluster-wide enabled disk templates
def _WaitForMasterDaemon():

Wait for master daemon to become responsive.

def _WaitForNodeDaemon(node_name):

Wait for node daemon to become responsive.

def _WaitForSshDaemon(hostname, port):

Wait for SSH daemon to become responsive.

_DAEMON_READY_TIMEOUT: float =

Undocumented

Value
10.0
_INITCONF_ECID: str =

Undocumented

Value
'initconfig-ecid'