mirror of
https://github.com/ansible/awx.git
synced 2026-05-20 23:37:39 -02:30
model and task support for launching openstack inventory updates
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2014 AnsibleWorks, Inc.
|
# Copyright (c) 2014 AnsibleWorks, Inc.
|
||||||
# All Rights Reserved.
|
# All Rights Reserved.
|
||||||
|
|
||||||
CLOUD_PROVIDERS = ('azure', 'ec2', 'gce', 'rax', 'vmware')
|
CLOUD_PROVIDERS = ('azure', 'ec2', 'gce', 'rax', 'vmware', 'openstack')
|
||||||
SCHEDULEABLE_PROVIDERS = CLOUD_PROVIDERS + ('custom',)
|
SCHEDULEABLE_PROVIDERS = CLOUD_PROVIDERS + ('custom',)
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ PERMISSION_TYPE_CHOICES = [
|
|||||||
(PERM_JOBTEMPLATE_CREATE, _('Create a Job Template')),
|
(PERM_JOBTEMPLATE_CREATE, _('Create a Job Template')),
|
||||||
]
|
]
|
||||||
|
|
||||||
CLOUD_INVENTORY_SOURCES = ['ec2', 'rax', 'vmware', 'gce', 'azure', 'custom']
|
CLOUD_INVENTORY_SOURCES = ['ec2', 'rax', 'vmware', 'gce', 'azure', 'openstack', 'custom']
|
||||||
|
|
||||||
|
|
||||||
class VarsDictProperty(object):
|
class VarsDictProperty(object):
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
|
|||||||
('vmware', _('VMware vCenter')),
|
('vmware', _('VMware vCenter')),
|
||||||
('gce', _('Google Compute Engine')),
|
('gce', _('Google Compute Engine')),
|
||||||
('azure', _('Microsoft Azure')),
|
('azure', _('Microsoft Azure')),
|
||||||
|
('openstack', _('Openstack')),
|
||||||
]
|
]
|
||||||
|
|
||||||
BECOME_METHOD_CHOICES = [
|
BECOME_METHOD_CHOICES = [
|
||||||
|
|||||||
@@ -740,6 +740,7 @@ class InventorySourceOptions(BaseModel):
|
|||||||
('gce', _('Google Compute Engine')),
|
('gce', _('Google Compute Engine')),
|
||||||
('azure', _('Microsoft Azure')),
|
('azure', _('Microsoft Azure')),
|
||||||
('vmware', _('VMware vCenter')),
|
('vmware', _('VMware vCenter')),
|
||||||
|
('openstack', _('Openstack')),
|
||||||
('custom', _('Custom Script')),
|
('custom', _('Custom Script')),
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -963,6 +964,11 @@ class InventorySourceOptions(BaseModel):
|
|||||||
"""
|
"""
|
||||||
return [('all', 'All')]
|
return [('all', 'All')]
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def get_openstack_region_choices(self):
|
||||||
|
"""I don't think openstack has regions"""
|
||||||
|
return [('all', 'All')]
|
||||||
|
|
||||||
def clean_credential(self):
|
def clean_credential(self):
|
||||||
if not self.source:
|
if not self.source:
|
||||||
return None
|
return None
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import urlparse
|
|||||||
import uuid
|
import uuid
|
||||||
from distutils.version import LooseVersion as Version
|
from distutils.version import LooseVersion as Version
|
||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
|
import yaml
|
||||||
|
|
||||||
# Pexpect
|
# Pexpect
|
||||||
import pexpect
|
import pexpect
|
||||||
@@ -931,6 +932,15 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
credential = inventory_update.credential
|
credential = inventory_update.credential
|
||||||
return decrypt_field(credential, 'ssh_key_data')
|
return decrypt_field(credential, 'ssh_key_data')
|
||||||
|
|
||||||
|
if inventory_update.source == 'openstack':
|
||||||
|
credential = inventory_update.credential
|
||||||
|
openstack_auth = dict(auth_url=credential.host,
|
||||||
|
username=credential.username,
|
||||||
|
password=decrypt_field(credential, "password"),
|
||||||
|
project_name=credential.project)
|
||||||
|
openstack_data = {"clouds": {"devstack": {"auth": openstack_auth}}}
|
||||||
|
return yaml.safe_dump(openstack_data, default_flow_style=False, allow_unicode=True)
|
||||||
|
|
||||||
cp = ConfigParser.ConfigParser()
|
cp = ConfigParser.ConfigParser()
|
||||||
# Build custom ec2.ini for ec2 inventory script to use.
|
# Build custom ec2.ini for ec2 inventory script to use.
|
||||||
if inventory_update.source == 'ec2':
|
if inventory_update.source == 'ec2':
|
||||||
@@ -1051,6 +1061,8 @@ class RunInventoryUpdate(BaseTask):
|
|||||||
env['GCE_EMAIL'] = passwords.get('source_username', '')
|
env['GCE_EMAIL'] = passwords.get('source_username', '')
|
||||||
env['GCE_PROJECT'] = passwords.get('source_project', '')
|
env['GCE_PROJECT'] = passwords.get('source_project', '')
|
||||||
env['GCE_PEM_FILE_PATH'] = kwargs['private_data_file']
|
env['GCE_PEM_FILE_PATH'] = kwargs['private_data_file']
|
||||||
|
elif inventory_update.source == 'openstack':
|
||||||
|
env['OPENSTACK_CONFIG_FILE'] = kwargs.get('private_data_file', '')
|
||||||
elif inventory_update.source == 'file':
|
elif inventory_update.source == 'file':
|
||||||
# FIXME: Parse source_env to dict, update env.
|
# FIXME: Parse source_env to dict, update env.
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -522,6 +522,15 @@ AZURE_HOST_FILTER = r'^.+$'
|
|||||||
AZURE_EXCLUDE_EMPTY_GROUPS = True
|
AZURE_EXCLUDE_EMPTY_GROUPS = True
|
||||||
AZURE_INSTANCE_ID_VAR = None
|
AZURE_INSTANCE_ID_VAR = None
|
||||||
|
|
||||||
|
# ---------------------
|
||||||
|
# ----- OpenStack -----
|
||||||
|
# ---------------------
|
||||||
|
OPENSTACK_ENABLED_VAR = 'status'
|
||||||
|
OPENSTACK_ENABLED_VALUE = 'ACTIVE'
|
||||||
|
OPENSTACK_GROUP_FILTER = r'^.+$'
|
||||||
|
OPENSTACK_HOST_FILTER = r'^.+$'
|
||||||
|
OPENSTACK_EXCLUDE_EMPTY_GROUPS = True
|
||||||
|
OPENSTACK_INSTANCE_ID_VAR = None
|
||||||
|
|
||||||
# ---------------------
|
# ---------------------
|
||||||
# -- Activity Stream --
|
# -- Activity Stream --
|
||||||
|
|||||||
Reference in New Issue
Block a user