mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
In progress: Adding GCE to inventory source.
This commit is contained in:
parent
4c887c5614
commit
c6f7c1d2da
@ -736,6 +736,7 @@ class InventorySourceOptions(BaseModel):
|
||||
('file', _('Local File, Directory or Script')),
|
||||
('rax', _('Rackspace Cloud Servers')),
|
||||
('ec2', _('Amazon EC2')),
|
||||
('gce', _('Google Compute Engine')),
|
||||
]
|
||||
|
||||
class Meta:
|
||||
@ -826,13 +827,15 @@ class InventorySourceOptions(BaseModel):
|
||||
return None
|
||||
cred = self.credential
|
||||
if cred:
|
||||
if self.source == 'ec2' and cred.kind != 'aws':
|
||||
raise ValidationError('Credential kind must be "aws" for an '
|
||||
'"ec2" source')
|
||||
if self.source == 'rax' and cred.kind != 'rax':
|
||||
raise ValidationError('Credential kind must be "rax" for a '
|
||||
'"rax" source')
|
||||
elif self.source in ('ec2', 'rax'):
|
||||
# If a credential was provided, it's important that it matches
|
||||
# the actual inventory source being used (Amazon requires Amazon
|
||||
# credentials; Rackspace requires Rackspace credentials; etc...)
|
||||
if self.source.replace('ec2', 'awx') != cred.kind:
|
||||
raise ValidationError(
|
||||
'Cloud-based inventory sources (such as %s) require '
|
||||
'credentials for the matching cloud service.' % self.source
|
||||
)
|
||||
elif self.source in ('ec2', 'rax', 'gce'):
|
||||
raise ValidationError('Credential is required for a cloud source')
|
||||
return cred
|
||||
|
||||
|
@ -47,7 +47,7 @@ angular.module('SourceFormDefinition', [])
|
||||
source_regions: {
|
||||
label: 'Regions',
|
||||
type: 'text',
|
||||
ngShow: "source && (source.value == 'rax' || source.value == 'ec2')",
|
||||
ngShow: "source && (source.value == 'rax' || source.value == 'ec2' || source.value == 'gce')",
|
||||
addRequired: false,
|
||||
editRequired: false,
|
||||
awMultiselect: 'source_region_choices',
|
||||
@ -155,4 +155,4 @@ angular.module('SourceFormDefinition', [])
|
||||
|
||||
related: { }
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -1027,6 +1027,15 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
|
||||
callback: 'choicesReadyGroup'
|
||||
});
|
||||
|
||||
GetChoices({
|
||||
scope: sources_scope,
|
||||
url: GetBasePath('inventory_sources'),
|
||||
field: 'source_regions',
|
||||
variable: 'gce_regions',
|
||||
choice_name: 'gce_region_choices',
|
||||
callback: 'choicesReadyGroup'
|
||||
});
|
||||
|
||||
Wait('start');
|
||||
|
||||
if (parent_scope.removeAddTreeRefreshed) {
|
||||
@ -1864,4 +1873,4 @@ function($compile, SchedulerInit, Rest, Wait, SetSchedulesInnerDialogSize, Sched
|
||||
|
||||
};
|
||||
}
|
||||
]);
|
||||
]);
|
||||
|
Loading…
Reference in New Issue
Block a user