Run sudo_chown() and sudo_chmod() on remote_path. If owner or mode is None, their corresponding function is not called.
sudo mkdir -p <remote_path> followed by :func:`sudo_chattr`(remote_path, **chattr_kw).
Upload all files and directories in local_dir to remote_dir. Directories are created with sudo_mkdir_p() and files are uploaded with sudo_upload_file(). chattr_kw is forwarded in both cases.
Use sudo to upload a file from local_path to remote_path and run sudo_chattr() with the given chattr_kw as arguments.
Create a tempfile containing string_to_upload, and use sudo_upload_file() to upload the tempfile. Removes the tempfile when the upload is complete or if it fails.
Parameters: |
|
---|
Ubuntu utilities.
Bases: exceptions.Exception
Raised when we fail to connect to a region.
Bases: exceptions.Exception
Raises when wait_for_state() times out.
Bases: object
Wraps a boto.ec2.instance.Instance with convenience functions.
Variables: | instance – The boto.ec2.instance.Instance. |
---|---|
Parameters: | instance – A boto.ec2.instance.Instance object. |
Add self to fabric.api.env.ec2instances[self.get_ssh_uri()], and register the key-pair for the instance in fabric.api.env.key_filename.
Connect to AWS and get the EC2 instance with the given instance ID.
Parameters: | instanceid_with_optional_region – Parsed with parse_instanceid() to find the region and name. |
---|---|
Raises: |
|
Returns: | A Ec2InstanceWrapper contaning the requested instance. |
Connect to AWS and get the EC2 instance with the given Name-tag.
Parameters: | instancename_with_optional_region – Parsed with parse_instancename() to find the region and name. |
---|---|
Raises: |
|
Returns: | A Ec2InstanceWrapper contaning the requested instance. |
Connect to AWS and get the EC2 instance with the given tag:value pairs.
Parameters: | region – optional. |
---|---|
Raises: |
|
Returns: | A list of :class:`Ec2InstanceWrapper`s containing the matching instances. |
Use get_by_tagvalue() to find instances by tags, but raise LookupError if not exactly one instance is found.
If an instance has been registered in fabric.api.env using add_instance_to_env(), this method can be used to get the instance identified by fabric.api.env.host_string.
Get the SSH indentify filename (.pem-file) for the instance. Searches awsfab_settings.KEYPAIR_PATH for "<instance.key_name>.pem".
Raises LookupError: | |
---|---|
If the key is not found. |
Bases: object
Launch instances configured in awsfab_settings.EC2_LAUNCH_CONFIGS.
Example:
launcher = Ec2LaunchInstance(extra_tags={'Name': 'mytest'})
launcher.confirm()
instance = launcher.run_instance()
Note that this class is optimized for the following use case:
- Create one or more instances (initialize one or more Ec2LaunchInstance).
- Confirm using confirm() or confirm_many().
- Launch each instance using meth:Ec2LaunchInstance.run_instance or Ec2LaunchInstance.run_many_instances().
- Use Ec2LaunchInstance.wait_for_running_state_many() to wait for all instances to launch.
- Do something with the running instances.
Example of launching many instances:
a = Ec2LaunchInstance(extra_tags={‘Name’: ‘a’}) b = Ec2LaunchInstance(extra_tags={‘Name’: ‘b’}) Ec2LaunchInstance.confirm_many([a, b]) Ec2LaunchInstance.run_many_instances([a, b]) # Note: that we can start doing stuff with a and b that does not # require the instances to be running, such as setting tags. Ec2LaunchInstance.wait_for_running_state_many([a, b])
Initialize the launcher. Runs create_config_ask_if_none().
Parameters: |
|
---|
Use prettyprint() to show the user their choices, and ask for confirmation. Runs fabric.api.abort() if the user does not confirm the choices.
Loop through Use prettyprint() to show the user their choices, and ask for confirmation. Runs fabric.api.abort() if the user does not confirm the choices.
Set kw and conf using configname. Prompt the user for a configname if bool(configname) is False.
Merge tags from the awsfab_settings.EC2_LAUNCH_CONFIGS config, and the extra_tags parameter for __init__, and return the resulting dict.
Run/launch the configured instance, and add the tags to the instance (get_all_tags()).
Returns: | The launched instance. |
---|
Loop through launchers and run run_instance().
Parameters: |
|
---|
Loop through launchers and run wait_for_running_state().
Parameters: |
|
---|
A config dict from awsfab_settings.EC2_LAUNCH_CONFIGS.
See the docs for the __init__ parameter.
See the docs for the __init__ parameter.
The instance launced by run_instance(). None when run_instance() has not been invoked.
Keyword arguments for run_instances().
rsync local_dir into remote_dir on the current EC2 instance (the one returned by Ec2InstanceWrapper.get_from_host_string()).
Parameters: | sync_content – Normally the function automatically makes sure local_dir is not suffixed with /, which makes rsync copy local_dir into remote_dir. With sync_content=True, the content of local_dir is synced into remote_dir instead. |
---|
Parse instance id with an optional region-name prefixed. Region name is specified by prefixing the instanceid with <regionname>:.
Returns: | (region, instanceid) where region defaults to awsfab_settings.DEFAULT_REGION if not prefixed to the id. |
---|
Just like parse_instanceid(), however this is for instance names. We keep them as separate functions in case they diverge in the future.
Returns: | (region, instanceid) where region defaults to awsfab_settings.DEFAULT_REGION if not prefixed to the name. |
---|
Print attributes of an ec2 instance.
Parameters: |
|
---|
Shortcut for wait_for_state(instanceid, 'running', **kwargs).
Poll the instance with instanceid until its state_name matches the desired state_name.
The first poll is performed without any delay, and the rest of the polls are performed according to sleep_intervals.
Parameters: |
|
---|