Package ganeti :: Module bootstrap
[hide private]
[frames] | no frames]

Module bootstrap

source code

Functions to bootstrap a new cluster.

Functions [hide private]
 
_InitSSHSetup()
Setup the SSH configuration for the cluster.
source code
 
GenerateHmacKey(file_name)
Writes a new HMAC key.
source code
 
GenerateClusterCrypto(new_cluster_cert, new_rapi_cert, new_confd_hmac_key, new_cds, rapi_cert_pem=None, cds=None, nodecert_file=constants.NODED_CERT_FILE, rapicert_file=constants.RAPI_CERT_FILE, hmackey_file=constants.CONFD_HMAC_KEY, cds_file=constants.CLUSTER_DOMAIN_SECRET_FILE)
Updates the cluster certificates, keys and secrets.
source code
 
_InitGanetiServerSetup(master_name)
Setup the necessary configuration for the initial node daemon.
source code
 
_WaitForNodeDaemon(node_name)
Wait for node daemon to become responsive.
source code
 
_WaitForMasterDaemon()
Wait for master daemon to become responsive.
source code
 
_InitFileStorage(file_storage_dir)
Initialize if needed the file storage.
source code
 
InitCluster(cluster_name, mac_prefix, master_netdev, file_storage_dir, shared_file_storage_dir, candidate_pool_size, secondary_ip=None, vg_name=None, beparams=None, nicparams=None, ndparams=None, hvparams=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, primary_ip_version=None, prealloc_wipe_disks=False)
Initialise the cluster.
source code
 
InitConfig(version, cluster_config, master_node_config, cfg_file=constants.CLUSTER_CONF_FILE)
Create the initial cluster configuration.
source code
 
FinalizeClusterDestroy(master)
Execute the last steps of cluster destroy
source code
 
SetupNodeDaemon(cluster_name, node, ssh_key_check)
Add a node to the cluster.
source code
 
MasterFailover(no_voting=False)
Failover the master node.
source code
 
GetMaster()
Returns the current master node.
source code
list
GatherMasterVotes(node_list)
Check the agreement on who is the master.
source code
Variables [hide private]
  _INITCONF_ECID = "initconfig-ecid"
  _DAEMON_READY_TIMEOUT = 10.0
After how many seconds daemon must be responsive

Imports: os, re, logging, time, rpc, ssh, utils, errors, config, constants, objects, ssconf, serializer, hypervisor, bdev, netutils, backend, luxi, jstore


Function Details [hide private]

_InitSSHSetup()

source code 

Setup the SSH configuration for the cluster.

This generates a dsa keypair for root, adds the pub key to the permitted hosts and adds the hostkey to its own known hosts.

GenerateHmacKey(file_name)

source code 

Writes a new HMAC key.

Parameters:
  • file_name (str) - Path to output file

GenerateClusterCrypto(new_cluster_cert, new_rapi_cert, new_confd_hmac_key, new_cds, rapi_cert_pem=None, cds=None, nodecert_file=constants.NODED_CERT_FILE, rapicert_file=constants.RAPI_CERT_FILE, hmackey_file=constants.CONFD_HMAC_KEY, cds_file=constants.CLUSTER_DOMAIN_SECRET_FILE)

source code 

Updates the cluster certificates, keys and secrets.

Parameters:
  • new_cluster_cert (bool) - Whether to generate a new cluster certificate
  • new_rapi_cert (bool) - Whether to generate a new RAPI certificate
  • new_confd_hmac_key (bool) - Whether to generate a new HMAC key
  • new_cds (bool) - Whether to generate a new cluster domain secret
  • rapi_cert_pem (string) - New RAPI certificate in PEM format
  • cds (string) - New cluster domain secret
  • nodecert_file (string) - optional override of the node cert file path
  • rapicert_file (string) - optional override of the rapi cert file path
  • hmackey_file (string) - optional override of the hmac key file path

_InitGanetiServerSetup(master_name)

source code 

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 (str) - Name of the master node

_InitFileStorage(file_storage_dir)

source code 

Initialize if needed the file storage.

Parameters:
  • file_storage_dir - the user-supplied value
Returns:
either empty string (if file storage was disabled at build time) or the normalized path to the storage directory

InitCluster(cluster_name, mac_prefix, master_netdev, file_storage_dir, shared_file_storage_dir, candidate_pool_size, secondary_ip=None, vg_name=None, beparams=None, nicparams=None, ndparams=None, hvparams=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, primary_ip_version=None, prealloc_wipe_disks=False)

source code 

Initialise the cluster.

Parameters:
  • candidate_pool_size (int) - master candidate pool size

InitConfig(version, cluster_config, master_node_config, cfg_file=constants.CLUSTER_CONF_FILE)

source code 

Create the initial cluster configuration.

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

Parameters:
  • version (int) - configuration version
  • cluster_config (objects.Cluster) - cluster configuration
  • master_node_config (objects.Node) - master node configuration
  • cfg_file (string) - configuration file path

FinalizeClusterDestroy(master)

source code 

Execute the last steps of cluster destroy

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

SetupNodeDaemon(cluster_name, node, ssh_key_check)

source code 

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:
  • cluster_name - the cluster name
  • node - the name of the new node
  • ssh_key_check - whether to do a strict key check

MasterFailover(no_voting=False)

source code 

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.

Parameters:
  • no_voting (boolean) - force the operation without remote nodes agreement (dangerous)

GetMaster()

source code 

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.

GatherMasterVotes(node_list)

source code 

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. Errors will be denoted by the key 'None'.

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

We remove ourselves from the list since we know that (bugs aside) since we use the same source for configuration information for both backend and boostrap, we'll always vote for ourselves.

Parameters:
  • node_list (list) - the list of nodes to query for master info; the current node will be removed if it is in the list
Returns: list
list of (node, votes)