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
 
_GenerateSelfSignedSslCert(file_name, validity=(365*5))
Generates a self-signed SSL certificate.
source code
 
_InitGanetiServerSetup()
Setup the necessary configuration for the initial node daemon.
source code
 
InitCluster(cluster_name, mac_prefix, def_bridge, master_netdev, file_storage_dir, candidate_pool_size, secondary_ip=None, vg_name=None, beparams=None, hvparams=None, enabled_hypervisors=None, default_hypervisor=None, modify_etc_hosts=True)
Initialise the cluster.
source code
ssconf.SimpleConfigWriter
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

Imports: os, re, logging, tempfile, rpc, ssh, utils, errors, config, constants, objects, ssconf, hypervisor


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.

_GenerateSelfSignedSslCert(file_name, validity=(365*5))

source code 

Generates a self-signed SSL certificate.

Parameters:
  • file_name (str) - Path to output file
  • validity (int) - Validity for certificate in days

_InitGanetiServerSetup()

source code 

Setup the necessary configuration for the initial node daemon.

This creates the nodepass file containing the shared password for the cluster and also generates the SSL certificate.

InitCluster(cluster_name, mac_prefix, def_bridge, master_netdev, file_storage_dir, candidate_pool_size, secondary_ip=None, vg_name=None, beparams=None, hvparams=None, enabled_hypervisors=None, default_hypervisor=None, modify_etc_hosts=True)

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
Returns: ssconf.SimpleConfigWriter
initialized config instance

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)