starcluster.node.Node

Package starcluster :: Module node :: Class Node |
[hide private]
[frames] | no frames]

# Class Node

source code

This class represents a single compute node in a StarCluster.

It contains all useful metadata for the node such as the internal/external hostnames, ips, etc as well as a paramiko ssh object for executing commands, creating/modifying files on the node.

'instance' arg must be an instance of boto.ec2.instance.Instance

'key_location' arg is a string that contains the full path to the private key corresponding to the keypair used to launch this node

'alias' keyword arg optionally names the node. If no alias is provided, the alias is retrieved from the node's user_data based on the node's launch index

'user' keyword optionally specifies user to ssh as (defaults to root)

Instance Methods | [hide private]
__init__(self, instance, key_location, alias=None, user=`'``root``'`) x.__init__(...) initializes x; see x.__class__.__doc__ for signature | source code
__repr__(self) repr(x) | source code
_get_user_data(self, tries=5) | source code
_remove_all_tags(self) | source code
add_tag(self, key, value=None) | source code
remove_tag(self, key, value=None) | source code
add_user_to_group(self, user, group) Add user (if exists) to group (if exists) | source code
get_group_map(self, key_by_gid=False) Returns dictionary where keys are remote group names and values are grp.struct_grp objects from the standard grp module | source code
get_user_map(self, key_by_uid=False) Returns dictionary where keys are remote usernames and values are pwd.struct_passwd objects from the standard pwd module | source code
getgrgid(self, gid) Remote version of the getgrgid method in the standard grp module | source code
getgrnam(self, groupname) Remote version of the getgrnam method in the standard grp module | source code
getpwuid(self, uid) Remote version of the getpwuid method in the standard pwd module | source code
getpwnam(self, username) Remote version of the getpwnam method in the standard pwd module | source code
add_user(self, name, uid=None, gid=None, shell=`'``bash``'`) Add a user to the remote system. | source code
generate_key_for_user(self, username, ignore_existing=False, auth_new_key=False, auth_conn_key=False) Generates an id_rsa/id_rsa.pub keypair combo for a user on the remote machine. | source code
add_to_known_hosts(self, username, nodes, add_self=True) Populate user's known_hosts file with pub keys from hosts in nodes list | source code
remove_from_known_hosts(self, username, nodes) Remove all network names for nodes from username's known_hosts file on this Node | source code
enable_passwordless_ssh(self, username, nodes) Configure passwordless ssh for user between this Node and nodes | source code
copy_remote_file_to_node(self, remote_file, node, dest=None) | source code
copy_remote_file_to_nodes(self, remote_file, nodes, dest=None) Copies a remote file from this Node instance to another Node instance without passwordless ssh between the two. | source code
remove_user(self, name) Remove a user from the remote system | source code
export_fs_to_nodes(self, nodes, export_paths) Export each path in export_paths to each node in nodes via NFS | source code
stop_exporting_fs_to_nodes(self, nodes) Removes nodes from this node's /etc/exportfs | source code
start_nfs_server(self) | source code
mount_nfs_shares(self, server_node, remote_paths) Mount each path in remote_paths from the remote server_node | source code
get_mount_map(self) | source code
mount_device(self, device, path) Mount device to path | source code
add_to_etc_hosts(self, nodes) Adds all names for node in nodes arg to this node's /etc/hosts file | source code
remove_from_etc_hosts(self, nodes) Remove all network names for node in nodes arg from this node's /etc/hosts file | source code
set_hostname(self, hostname=None) Set this node's hostname to self.alias | source code
detach_external_volumes(self) Detaches all volumes returned by self.attached_vols | source code
delete_root_volume(self) Detach and destroy EBS root volume (EBS-backed node only) | source code
get_spot_request(self) | source code
is_master(self) | source code
is_instance_store(self) | source code
is_ebs_backed(self) | source code
is_cluster_compute(self) | source code
is_gpu_compute(self) | source code
is_cluster_type(self) | source code
is_spot(self) | source code
is_stoppable(self) | source code
is_stopped(self) | source code
start(self) Starts EBS-backed instance and puts it in the 'running' state. | source code
stop(self) Shutdown EBS-backed instance and put it in the 'stopped' state. | source code
terminate(self) Shutdown and destroy this instance. | source code
shutdown(self) Shutdown this instance. | source code
reboot(self) Reboot this instance. | source code
is_ssh_up(self) | source code
is_up(self) | source code
update(self) | source code
shell(self, user=None) Attempts to launch an interactive shell by first trying the system's ssh client. | source code
get_hosts_entry(self) Returns /etc/hosts entry for this node | source code
__del__(self) | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties | [hide private]
| alias Fetches the node's alias stored in a tag from either the instance or the instance's parent spot request.
| tags
| groups
| cluster_groups
| num_processors
| memory
| ip_address
| public_dns_name
| private_ip_address
| private_dns_name
| private_dns_name_short
| id
| block_device_mapping
| dns_name
| state
| launch_time
| local_launch_time
| uptime
| ami_launch_index
| key_name
| arch
| kernel
| ramdisk
| instance_type
| image_id
| placement
| root_device_name
| root_device_type
| network_names Returns all network names for this node in a dictionary
| attached_vols Returns a dictionary of all attached volumes minus the root device in the case of EBS backed instances
| spot_id
| ssh
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, instance, key_location, alias=None, user=`'``root``'`) (Constructor) | source code
x.__init__(...) initializes x; see x.__class__.__doc__ for signature Overrides: object.__init__ (inherited documentation)

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### get_group_map(self, key_by_gid=False) | source code
Returns dictionary where keys are remote group names and values are grp.struct_grp objects from the standard grp module key_by_gid=True will use the integer gid as the returned dictionary's keys instead of the group's name

### get_user_map(self, key_by_uid=False) | source code
Returns dictionary where keys are remote usernames and values are pwd.struct_passwd objects from the standard pwd module key_by_uid=True will use the integer uid as the returned dictionary's keys instead of the user's login name

### getgrgid(self, gid) | source code
Remote version of the getgrgid method in the standard grp module returns a grp.struct_group

### getgrnam(self, groupname) | source code
Remote version of the getgrnam method in the standard grp module returns a grp.struct_group

### getpwuid(self, uid) | source code
Remote version of the getpwuid method in the standard pwd module returns a pwd.struct_passwd

### getpwnam(self, username) | source code
Remote version of the getpwnam method in the standard pwd module returns a pwd.struct_passwd

### add_user(self, name, uid=None, gid=None, shell=`'``bash``'`) | source code
Add a user to the remote system. name - the username of the user being added uid - optional user id to use when creating new user gid - optional group id to use when creating new user shell - optional shell assign to new user (default: bash)

### generate_key_for_user(self, username, ignore_existing=False, auth_new_key=False, auth_conn_key=False) | source code
Generates an id_rsa/id_rsa.pub keypair combo for a user on the remote machine. ignore_existing - if False, any existing key combos will be used rather than generating a new RSA key auth_new_key - if True, add the newly generated public key to the remote user's authorized_keys file auth_conn_key - if True, add the public key used to establish this ssh connection to the remote user's authorized_keys

### add_to_known_hosts(self, username, nodes, add_self=True) | source code
Populate user's known_hosts file with pub keys from hosts in nodes list username - name of the user to add to known hosts for nodes - the nodes to add to the user's known hosts file add_self - add this Node to known_hosts in addition to nodes NOTE: this node's hostname will also be added to the known_hosts file

### copy_remote_file_to_nodes(self, remote_file, nodes, dest=None) | source code
Copies a remote file from this Node instance to another Node instance without passwordless ssh between the two. dest - path to store the data in on the node (defaults to remote_file)

### export_fs_to_nodes(self, nodes, export_paths) | source code
Export each path in export_paths to each node in nodes via NFS nodes - list of nodes to export each path to export_paths - list of paths on this remote host to export to each node Example: # export /home and /opt/sge6 to each node in nodes $ node.start_nfs_server() $ node.export_fs_to_nodes( nodes=[node1,node2], export_paths=['/home', '/opt/sge6']

### stop_exporting_fs_to_nodes(self, nodes) | source code
Removes nodes from this node's /etc/exportfs nodes - list of nodes to stop Example: $ node.remove_export_fs_to_nodes(nodes=[node1,node2])

### mount_nfs_shares(self, server_node, remote_paths) | source code
Mount each path in remote_paths from the remote server_node server_node - remote server node that is sharing the remote_paths remote_paths - list of remote paths to mount from server_node

### set_hostname(self, hostname=None) | source code
Set this node's hostname to self.alias hostname - optional hostname to set (defaults to self.alias)

### start(self) | source code
Starts EBS-backed instance and puts it in the 'running' state. Only works if this node is EBS-backed, raises exception.InvalidOperation otherwise.

### stop(self) | source code
Shutdown EBS-backed instance and put it in the 'stopped' state. Only works if this node is EBS-backed, raises exception.InvalidOperation otherwise. NOTE: The EBS root device will *not* be deleted and the instance can be 'started' later on.

### terminate(self) | source code
Shutdown and destroy this instance. For EBS-backed nodes, this will also destroy the node's EBS root device. Puts this node into a 'terminated' state.

### shutdown(self) | source code
Shutdown this instance. This method will terminate traditional instance-store instances and stop EBS-backed instances (ie not destroy EBS root dev)

### shell(self, user=None) | source code
Attempts to launch an interactive shell by first trying the system's ssh client. If the system does not have the ssh command it falls back to a pure-python ssh shell.

Property Details | [hide private]

### alias Fetches the node's alias stored in a tag from either the instance or the instance's parent spot request. If no alias tag is found an exception is raised. Get Method: unreachable.alias(self) - Fetches the node's alias stored in a tag from either the instance or the instance's parent spot request.

### tags Get Method: unreachable.tags(self)

### groups Get Method: unreachable.groups(self)

### cluster_groups Get Method: unreachable.cluster_groups(self)

### num_processors Get Method: unreachable.num_processors(self)

### memory Get Method: unreachable.memory(self)

### ip_address Get Method: unreachable.ip_address(self)

### public_dns_name Get Method: unreachable.public_dns_name(self)

### private_ip_address Get Method: unreachable.private_ip_address(self)

### private_dns_name Get Method: unreachable.private_dns_name(self)

### private_dns_name_short Get Method: unreachable.private_dns_name_short(self)

### id Get Method: unreachable.id(self)

### block_device_mapping Get Method: unreachable.block_device_mapping(self)

### dns_name Get Method: unreachable.dns_name(self)

### state Get Method: unreachable.state(self)

### launch_time Get Method: unreachable.launch_time(self)

### local_launch_time Get Method: unreachable.local_launch_time(self)

### uptime Get Method: unreachable.uptime(self)

### ami_launch_index Get Method: unreachable.ami_launch_index(self)

### key_name Get Method: unreachable.key_name(self)

### arch Get Method: unreachable.arch(self)

### kernel Get Method: unreachable.kernel(self)

### ramdisk Get Method: unreachable.ramdisk(self)

### instance_type Get Method: unreachable.instance_type(self)

### image_id Get Method: unreachable.image_id(self)

### placement Get Method: unreachable.placement(self)

### root_device_name Get Method: unreachable.root_device_name(self)

### root_device_type Get Method: unreachable.root_device_type(self)

### network_names Returns all network names for this node in a dictionary Get Method: unreachable.network_names(self) - Returns all network names for this node in a dictionary

### attached_vols Returns a dictionary of all attached volumes minus the root device in the case of EBS backed instances Get Method: unreachable.attached_vols(self) - Returns a dictionary of all attached volumes minus the root device in the case of EBS backed instances

### spot_id Get Method: unreachable.spot_id(self)

### ssh Get Method: unreachable.ssh(self)