mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Allow EC2 to list images based on owner
This commit is contained in:
parent
9137d3d15d
commit
ddfaffa090
@ -418,6 +418,36 @@ configuration file:
|
||||
rename_on_destroy: True
|
||||
|
||||
|
||||
Listing Images
|
||||
==============
|
||||
Normally, images can be queried on a cloud provider by passing the
|
||||
``--list-images`` argument to Salt Cloud. This still holds true for EC2:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-cloud --list-images my-ec2-config
|
||||
|
||||
However, the full list of images on EC2 is extremely large, and querying all of
|
||||
the available images may cause Salt Cloud to behave as if frozen. Therefore,
|
||||
the default behavior of this option may be modified, by adding an ``owner``
|
||||
argument to the provider configuration:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
owner: aws-marketplace
|
||||
|
||||
The possible values for this setting are ``amazon``, ``aws-marketplace``,
|
||||
``self``, ``<AWS account ID>`` or ``all``. The default setting is ``amazon``.
|
||||
|
||||
It is also possible to perform this query using different settings without
|
||||
modifying the configuration files. To do this, call the ``avail_images``
|
||||
function directly:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt-cloud -f avail_images my-ec2-config owner=aws-marketplace
|
||||
|
||||
|
||||
EC2 Images
|
||||
==========
|
||||
The following are lists of available AMI images, generally sorted by OS. These
|
||||
|
@ -530,12 +530,25 @@ def avail_sizes():
|
||||
return sizes
|
||||
|
||||
|
||||
def avail_images():
|
||||
def avail_images(kwargs=None, call=None):
|
||||
'''
|
||||
Return a dict of all available VM images on the cloud provider.
|
||||
'''
|
||||
if type(kwargs) is not dict:
|
||||
kwargs = {}
|
||||
|
||||
if 'owner' in kwargs:
|
||||
owner = kwargs['owner']
|
||||
else:
|
||||
provider = get_configured_provider()
|
||||
|
||||
owner = config.get_cloud_config_value(
|
||||
'owner', provider, __opts__, default='amazon'
|
||||
)
|
||||
|
||||
ret = {}
|
||||
params = {'Action': 'DescribeImages'}
|
||||
params = {'Action': 'DescribeImages',
|
||||
'Owner': owner}
|
||||
images = query(params)
|
||||
for image in images:
|
||||
ret[image['imageId']] = image
|
||||
|
Loading…
Reference in New Issue
Block a user