Merge branch 'master' into fix-credential_id

Conflicts:
	awx/api/views.py
This commit is contained in:
Chris Meyers
2015-04-27 14:57:53 -04:00
17 changed files with 257 additions and 158 deletions

View File

@@ -365,7 +365,7 @@ class SubListCreateAPIView(SubListAPIView, ListCreateAPIView):
data[parent_key] = self.kwargs['pk'] data[parent_key] = self.kwargs['pk']
# attempt to deserialize the object # attempt to deserialize the object
serializer = self.serializer_class(data=data) serializer = self.get_serializer(data=data)
if not serializer.is_valid(): if not serializer.is_valid():
return Response(serializer.errors, return Response(serializer.errors,
status=status.HTTP_400_BAD_REQUEST) status=status.HTTP_400_BAD_REQUEST)
@@ -377,7 +377,7 @@ class SubListCreateAPIView(SubListAPIView, ListCreateAPIView):
# save the object through the serializer, reload and returned the saved # save the object through the serializer, reload and returned the saved
# object deserialized # object deserialized
obj = serializer.save() obj = serializer.save()
serializer = self.serializer_class(obj) serializer = self.get_serializer(instance=obj)
headers = {'Location': obj.get_absolute_url()} headers = {'Location': obj.get_absolute_url()}
return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers) return Response(serializer.data, status=status.HTTP_201_CREATED, headers=headers)

View File

@@ -1295,6 +1295,16 @@ class CredentialSerializer(BaseSerializer):
for field in Credential.PASSWORD_FIELDS: for field in Credential.PASSWORD_FIELDS:
if unicode(attrs.get(field, '')).startswith('$encrypted$'): if unicode(attrs.get(field, '')).startswith('$encrypted$'):
attrs.pop(field, None) attrs.pop(field, None)
# If creating a credential from a view that automatically sets the
# parent_key (user or team), set the other value to None.
view = self.context.get('view', None)
parent_key = getattr(view, 'parent_key', None)
if parent_key == 'user':
attrs['team'] = None
if parent_key == 'team':
attrs['user'] = None
instance = super(CredentialSerializer, self).restore_object(attrs, instance) instance = super(CredentialSerializer, self).restore_object(attrs, instance)
return instance return instance

View File

@@ -4,12 +4,12 @@
# Python # Python
import re import re
from dateutil.relativedelta import relativedelta from dateutil.relativedelta import relativedelta
from datetime import datetime
from optparse import make_option from optparse import make_option
# Django # Django
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand, CommandError
from django.db import transaction from django.db import transaction
from django.utils.timezone import now
# AWX # AWX
from awx.fact.models.fact import * # noqa from awx.fact.models.fact import * # noqa
@@ -30,20 +30,32 @@ class CleanupFacts(object):
# pivot -= granularity # pivot -= granularity
# group by host # group by host
def cleanup(self, older_than_abs, granularity): def cleanup(self, older_than_abs, granularity):
flag_delete_all = False
fact_oldest = FactVersion.objects.all().order_by('timestamp').first() fact_oldest = FactVersion.objects.all().order_by('timestamp').first()
if not fact_oldest: if not fact_oldest:
return 0 return 0
# Special case, granularity=0x where x is d, w, or y
# The intent is to delete all facts < older_than_abs
if granularity == relativedelta():
flag_delete_all = True
total = 0 total = 0
date_pivot = older_than_abs date_pivot = older_than_abs
while date_pivot > fact_oldest.timestamp: while date_pivot > fact_oldest.timestamp:
date_pivot_next = date_pivot - granularity date_pivot_next = date_pivot - granularity
kv = { kv = {
'timestamp__lte': date_pivot, 'timestamp__lte': date_pivot
'timestamp__gt': date_pivot_next,
} }
if not flag_delete_all:
kv['timestamp__gt'] = date_pivot_next
version_objs = FactVersion.objects.filter(**kv).order_by('-timestamp') version_objs = FactVersion.objects.filter(**kv).order_by('-timestamp')
if flag_delete_all:
total = version_objs.delete()
break
# Transform array -> {host_id} = [<fact_version>, <fact_version>, ...] # Transform array -> {host_id} = [<fact_version>, <fact_version>, ...]
# TODO: If this set gets large then we can use mongo to transform the data set for us. # TODO: If this set gets large then we can use mongo to transform the data set for us.
host_ids = {} host_ids = {}
@@ -66,13 +78,14 @@ class CleanupFacts(object):
total += count total += count
date_pivot = date_pivot_next date_pivot = date_pivot_next
return total return total
''' '''
older_than and granularity are of type relativedelta older_than and granularity are of type relativedelta
''' '''
def run(self, older_than, granularity): def run(self, older_than, granularity):
t = datetime.now() t = now()
deleted_count = self.cleanup(t - older_than, granularity) deleted_count = self.cleanup(t - older_than, granularity)
print("Deleted %d facts." % deleted_count) print("Deleted %d facts." % deleted_count)

View File

@@ -379,6 +379,23 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique):
# If update_fields has been specified, add our field names to it, # If update_fields has been specified, add our field names to it,
# if hit hasn't been specified, then we're just doing a normal save. # if hit hasn't been specified, then we're just doing a normal save.
update_fields = kwargs.get('update_fields', []) update_fields = kwargs.get('update_fields', [])
# If updating a credential, make sure that we only allow user OR team
# to be set, and clear out the other field based on which one has
# changed.
if self.pk:
cred_before = Credential.objects.get(pk=self.pk)
if self.user and self.team:
# If the user changed, remove the previously assigned team.
if cred_before.user != self.user:
self.team = None
if 'team' not in update_fields:
update_fields.append('team')
# If the team changed, remove the previously assigned user.
elif cred_before.team != self.team:
self.user = None
if 'user' not in update_fields:
update_fields.append('user')
# Set cloud flag based on credential kind.
cloud = self.kind in CLOUD_PROVIDERS + ('aws',) cloud = self.kind in CLOUD_PROVIDERS + ('aws',)
if self.cloud != cloud: if self.cloud != cloud:
self.cloud = cloud self.cloud = cloud

View File

@@ -945,6 +945,7 @@ class SystemJobOptions(BaseModel):
('cleanup_jobs', _('Remove jobs older than a certain number of days')), ('cleanup_jobs', _('Remove jobs older than a certain number of days')),
('cleanup_activitystream', _('Remove activity stream entries older than a certain number of days')), ('cleanup_activitystream', _('Remove activity stream entries older than a certain number of days')),
('cleanup_deleted', _('Purge previously deleted items from the database')), ('cleanup_deleted', _('Purge previously deleted items from the database')),
('cleanup_facts', _('Purge and/or reduce the granularity of system tracking data')),
] ]
class Meta: class Meta:

View File

@@ -1354,10 +1354,15 @@ class RunSystemJob(BaseTask):
args = ['awx-manage', system_job.job_type] args = ['awx-manage', system_job.job_type]
try: try:
json_vars = json.loads(system_job.extra_vars) json_vars = json.loads(system_job.extra_vars)
if 'days' in json_vars: if 'days' in json_vars and system_job.job_type != 'cleanup_facts':
args.extend(['--days', str(json_vars['days'])]) args.extend(['--days', str(json_vars.get('days', 60))])
if system_job.job_type == 'cleanup_jobs': if system_job.job_type == 'cleanup_jobs':
args.extend(['--jobs', '--project-updates', '--inventory-updates', '--management-jobs']) args.extend(['--jobs', '--project-updates', '--inventory-updates', '--management-jobs'])
if system_job.job_type == 'cleanup_facts':
if 'older_than' in json_vars:
args.extend(['--older_than', str(json_vars['older_than'])])
if 'granularity' in json_vars:
args.extend(['--granularity', str(json_vars['granularity'])])
# Keeping this around in case we want to break this out # Keeping this around in case we want to break this out
# if 'jobs' in json_vars and json_vars['jobs']: # if 'jobs' in json_vars and json_vars['jobs']:
# args.extend(['--jobs']) # args.extend(['--jobs'])

View File

@@ -28,6 +28,12 @@ class CleanupFactsCommandFunctionalTest(BaseCommandMixin, BaseTest, MongoDBRequi
result, stdout, stderr = self.run_command('cleanup_facts', granularity='1w',older_than='5d') result, stdout, stderr = self.run_command('cleanup_facts', granularity='1w',older_than='5d')
self.assertEqual(stdout, 'Deleted 0 facts.\n') self.assertEqual(stdout, 'Deleted 0 facts.\n')
def test_invoke_all_deleted(self):
self.create_hosts_and_facts(datetime(year=2015, day=2, month=1, microsecond=0), 10, 20)
result, stdout, stderr = self.run_command('cleanup_facts', granularity='0d', older_than='0d')
self.assertEqual(stdout, 'Deleted 200 facts.\n')
def test_invoke_params_required(self): def test_invoke_params_required(self):
result, stdout, stderr = self.run_command('cleanup_facts') result, stdout, stderr = self.run_command('cleanup_facts')
self.assertIsInstance(result, CommandError) self.assertIsInstance(result, CommandError)

View File

@@ -486,8 +486,11 @@ class ProjectsTest(BaseTransactionTest):
# can add credentials to a user (if user or org admin or super user) # can add credentials to a user (if user or org admin or super user)
self.post(other_creds, data=new_credentials, expect=401) self.post(other_creds, data=new_credentials, expect=401)
self.post(other_creds, data=new_credentials, expect=401, auth=self.get_invalid_credentials()) self.post(other_creds, data=new_credentials, expect=401, auth=self.get_invalid_credentials())
new_credentials['team'] = team.pk
result = self.post(other_creds, data=new_credentials, expect=201, auth=self.get_super_credentials()) result = self.post(other_creds, data=new_credentials, expect=201, auth=self.get_super_credentials())
cred_user = result['id'] cred_user = result['id']
self.assertEqual(result['team'], None)
del new_credentials['team']
new_credentials['name'] = 'credential2' new_credentials['name'] = 'credential2'
self.post(other_creds, data=new_credentials, expect=201, auth=self.get_normal_credentials()) self.post(other_creds, data=new_credentials, expect=201, auth=self.get_normal_credentials())
new_credentials['name'] = 'credential3' new_credentials['name'] = 'credential3'
@@ -497,9 +500,12 @@ class ProjectsTest(BaseTransactionTest):
# can add credentials to a team # can add credentials to a team
new_credentials['name'] = 'credential' new_credentials['name'] = 'credential'
new_credentials['user'] = other.pk
self.post(team_creds, data=new_credentials, expect=401) self.post(team_creds, data=new_credentials, expect=401)
self.post(team_creds, data=new_credentials, expect=401, auth=self.get_invalid_credentials()) self.post(team_creds, data=new_credentials, expect=401, auth=self.get_invalid_credentials())
self.post(team_creds, data=new_credentials, expect=201, auth=self.get_super_credentials()) result = self.post(team_creds, data=new_credentials, expect=201, auth=self.get_super_credentials())
self.assertEqual(result['user'], None)
del new_credentials['user']
new_credentials['name'] = 'credential2' new_credentials['name'] = 'credential2'
result = self.post(team_creds, data=new_credentials, expect=201, auth=self.get_normal_credentials()) result = self.post(team_creds, data=new_credentials, expect=201, auth=self.get_normal_credentials())
new_credentials['name'] = 'credential3' new_credentials['name'] = 'credential3'
@@ -611,6 +617,25 @@ class ProjectsTest(BaseTransactionTest):
cred_put_t = self.put(edit_creds2, data=d_cred_team, expect=200, auth=self.get_normal_credentials()) cred_put_t = self.put(edit_creds2, data=d_cred_team, expect=200, auth=self.get_normal_credentials())
self.put(edit_creds2, data=d_cred_team, expect=403, auth=self.get_other_credentials()) self.put(edit_creds2, data=d_cred_team, expect=403, auth=self.get_other_credentials())
# Reassign credential between team and user.
with self.current_user(self.super_django_user):
self.post(team_creds, data=dict(id=cred_user.pk), expect=204)
response = self.get(edit_creds1)
self.assertEqual(response['team'], team.pk)
self.assertEqual(response['user'], None)
self.post(other_creds, data=dict(id=cred_user.pk), expect=204)
response = self.get(edit_creds1)
self.assertEqual(response['team'], None)
self.assertEqual(response['user'], other.pk)
self.post(other_creds, data=dict(id=cred_team.pk), expect=204)
response = self.get(edit_creds2)
self.assertEqual(response['team'], None)
self.assertEqual(response['user'], other.pk)
self.post(team_creds, data=dict(id=cred_team.pk), expect=204)
response = self.get(edit_creds2)
self.assertEqual(response['team'], team.pk)
self.assertEqual(response['user'], None)
cred_put_t['disassociate'] = 1 cred_put_t['disassociate'] = 1
team_url = reverse('api:team_credentials_list', args=(cred_put_t['team'],)) team_url = reverse('api:team_credentials_list', args=(cred_put_t['team'],))
self.post(team_url, data=cred_put_t, expect=204, auth=self.get_normal_credentials()) self.post(team_url, data=cred_put_t, expect=204, auth=self.get_normal_credentials())

View File

@@ -36,6 +36,7 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
$scope.id = id; $scope.id = id;
$scope.argsPopOver = "<p>These arguments are used with the" + $scope.argsPopOver = "<p>These arguments are used with the" +
" specified module.</p>"; " specified module.</p>";
// fix arguments help popover based on the module selected // fix arguments help popover based on the module selected
$scope.moduleChange = function () { $scope.moduleChange = function () {
// NOTE: for selenium testing link - // NOTE: for selenium testing link -
@@ -64,20 +65,13 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
$scope.providedHostPatterns = $scope.limit; $scope.providedHostPatterns = $scope.limit;
delete $rootScope.hostPatterns; delete $rootScope.hostPatterns;
if ($scope.removeLookUpInitialize) { LookUpInit({
$scope.removeLookUpInitialize(); scope: $scope,
} form: form,
$scope.removeLookUpInitialize = $scope.$on('lookUpInitialize', function () { current_item: (!Empty($scope.credential_id)) ? $scope.credential_id : null,
LookUpInit({ list: CredentialList,
scope: $scope, field: 'credential',
form: form, input_type: 'radio'
current_item: (!Empty($scope.credential_id)) ? $scope.credential_id : null,
list: CredentialList,
field: 'credential',
input_type: 'radio'
});
Wait('stop'); // END: form population
}); });
if ($scope.removeChoicesReady) { if ($scope.removeChoicesReady) {
@@ -87,9 +81,10 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
choicesReadyCount++; choicesReadyCount++;
if (choicesReadyCount === 2) { if (choicesReadyCount === 2) {
// this sets the default option as specified by the controller. // this sets the default options for the selects as specified by the controller.
$scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default]; $scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default];
$scope.$emit('lookUpInitialize'); $("#forks-number").spinner("value", $scope.forks_field.default);
Wait('stop'); // END: form population
} }
}); });
@@ -212,23 +207,6 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
credential: $scope.credential, credential: $scope.credential,
callback: 'ContinueCred' callback: 'ContinueCred'
}); });
// // Launch the adhoc job
// Rest.setUrl(url);
// Rest.post(data)
// .success(function (data) {
// Wait('stop');
// $location.path("/ad_hoc_commands/" + data.id);
// })
// .error(function (data, status) {
// ProcessErrors($scope, data, status, form, { hdr: 'Error!',
// msg: 'Failed to launch adhoc command. POST returned status: ' +
// status });
// // TODO: still need to implement popping up a password prompt
// // if the credential requires it. The way that the current end-
// // point works is that I find out if I need to ask for a
// // password from POST, thus I get an error response.
// });
}; };
// Remove all data input into the form // Remove all data input into the form
@@ -239,6 +217,8 @@ export function AdhocCtrl($scope, $rootScope, $location, $routeParams,
} }
$scope.limit = $scope.providedHostPatterns; $scope.limit = $scope.providedHostPatterns;
KindChange({ scope: $scope, form: form, reset: false }); KindChange({ scope: $scope, form: form, reset: false });
$scope.verbosity = $scope.adhoc_verbosity_options[$scope.verbosity_field.default];
$("#forks-number").spinner("value", $scope.forks_field.default);
}; };
} }

View File

@@ -82,14 +82,15 @@ export default
} }
}, },
become_enabled: { become_enabled: {
label: 'Enable Become for Credential', label: 'Enable Privilege Escalation',
type: 'checkbox', type: 'checkbox',
editRequired: false addRequired: false,
// awPopOver: '<p>If checked, user will be become the user ' + editRequird: false,
// 'specified by the credential.</p>', column: 2,
// dataPlacement: 'right', awPopOver: "<p>If enabled, run this playbook as an administrator. This is the equivalent of passing the<code> --become</code> option to the <code> ansible</code> command. </p>",
// dataTitle: 'Enable Become for Credential', dataPlacement: 'right',
// dataContainer: 'body' dataTitle: 'Become Privilege Escalation',
dataContainer: "body"
}, },
verbosity: { verbosity: {
label: 'Verbosity', label: 'Verbosity',
@@ -98,14 +99,33 @@ export default
ngOptions: 'verbosity.label for verbosity in ' + ngOptions: 'verbosity.label for verbosity in ' +
'adhoc_verbosity_options ' + 'adhoc_verbosity_options ' +
'track by verbosity.value', 'track by verbosity.value',
"default": 1,
editRequired: true, editRequired: true,
awPopOver:'<p>These are the verbosity levels for standard ' + awPopOver:'<p>These are the verbosity levels for standard ' +
'out of the command run that are supported.', 'out of the command run that are supported.',
dataTitle: 'Module', dataTitle: 'Module',
dataPlacement: 'right', dataPlacement: 'right',
dataContainer: 'body' dataContainer: 'body',
} "default": 1
},
forks: {
label: 'Forks',
id: 'forks-number',
type: 'number',
integer: true,
min: 0,
spinner: true,
"default": 0,
addRequired: false,
editRequired: false,
'class': "input-small",
column: 1,
awPopOver: '<p>The number of parallel or simultaneous processes to use while executing the command. 0 signifies ' +
'the default value from the <a id="ansible_forks_docs" href=\"http://docs.ansible.com/intro_configuration.html#the-ansible-configuration-file\" ' +
' target=\"_blank\">ansible configuration file</a>.</p>',
dataTitle: 'Forks',
dataPlacement: 'right',
dataContainer: "body"
},
}, },
buttons: { buttons: {

View File

@@ -176,7 +176,7 @@ export default
'class': "input-small", 'class': "input-small",
column: 1, column: 1,
awPopOver: '<p>The number of parallel or simultaneous processes to use while executing the playbook. 0 signifies ' + awPopOver: '<p>The number of parallel or simultaneous processes to use while executing the playbook. 0 signifies ' +
'the default value from the <a href=\"http://docs.ansible.com/intro_configuration.html#the-ansible-configuration-file\" ' + 'the default value from the <a id="ansible_forks_docs" href=\"http://docs.ansible.com/intro_configuration.html#the-ansible-configuration-file\" ' +
' target=\"_blank\">ansible configuration file</a>.</p>', ' target=\"_blank\">ansible configuration file</a>.</p>',
dataTitle: 'Forks', dataTitle: 'Forks',
dataPlacement: 'right', dataPlacement: 'right',

View File

@@ -165,7 +165,9 @@ export default
}, },
inventory_variables: { inventory_variables: {
label: 'Source Variables', //"{{vars_label}}" , label: 'Source Variables', //"{{vars_label}}" ,
ngShow: "source && (source.value == 'vmware')",
ngShow: "source && (source.value == 'vmware' || " +
"source.value == 'openstack')",
type: 'textarea', type: 'textarea',
addRequired: false, addRequired: false,
editRequird: false, editRequird: false,

View File

@@ -1,5 +1,5 @@
/********************************************* /*********************************************
* Copyright (c) 2014 AnsibleWorks, Inc. * Copyright (c) 2015 AnsibleWorks, Inc.
* *
* GroupsHelper * GroupsHelper
* *
@@ -232,102 +232,117 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
]) ])
/**
*
* TODO: Document
*
*/
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList' ,
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList) {
return function (params) {
var scope = params.scope,
form = params.form,
kind, url, callback, invUrl;
.factory('SourceChange', ['GetBasePath', 'CredentialList', 'LookUpInit', 'Empty', 'Wait', 'ParseTypeChange', 'CustomInventoryList', 'CreateSelect2', if (!Empty(scope.source)) {
function (GetBasePath, CredentialList, LookUpInit, Empty, Wait, ParseTypeChange, CustomInventoryList, CreateSelect2) { if (scope.source.value === 'file') {
return function (params) { scope.sourcePathRequired = true;
} else {
var scope = params.scope, scope.sourcePathRequired = false;
form = params.form, // reset fields
kind, url, callback, invUrl; scope.source_path = '';
scope[form.name + '_form'].source_path.$setValidity('required', true);
}
if (!Empty(scope.source)) { if (scope.source.value === 'rax') {
if (scope.source.value === 'file') { scope.source_region_choices = scope.rax_regions;
scope.sourcePathRequired = true; //$('#s2id_group_source_regions').select2('data', []);
} else { $('#s2id_source_source_regions').select2('data', [{
scope.sourcePathRequired = false; id: 'all',
// reset fields text: 'All'
scope.source_path = ''; }]);
scope[form.name + '_form'].source_path.$setValidity('required', true); $('#source_form').addClass('squeeze');
} } else if (scope.source.value === 'ec2') {
if (scope.source.value === 'rax') { scope.source_region_choices = scope.ec2_regions;
scope.source_region_choices = scope.rax_regions; $('#s2id_source_source_regions').select2('data', [{
$('#source_form').addClass('squeeze'); id: 'all',
CreateSelect2({ text: 'All'
element: '#source_source_regions' }]);
}); scope.group_by_choices = scope.ec2_group_by;
} $('#s2id_group_by').select2('data', []);
else if (scope.source.value === 'ec2') { $('#source_form').addClass('squeeze');
scope.source_region_choices = scope.ec2_regions; } else if (scope.source.value === 'gce') {
scope.group_by_choices = scope.ec2_group_by; scope.source_region_choices = scope.gce_regions;
$('#source_form').addClass('squeeze'); //$('#s2id_group_source_regions').select2('data', []);
CreateSelect2({ $('#s2id_source_source_regions').select2('data', [{
element: '#source_source_regions' id: 'all',
}); text: 'All'
CreateSelect2({ }]);
element: '#source_group_by' $('#source_form').addClass('squeeze');
}); } else if (scope.source.value === 'azure') {
scope.source_region_choices = scope.azure_regions;
} //$('#s2id_group_source_regions').select2('data', []);
else if (scope.source.value === 'gce') { $('#s2id_source_source_regions').select2('data', [{
scope.source_region_choices = scope.gce_regions; id: 'all',
$('#source_form').addClass('squeeze'); text: 'All'
CreateSelect2({ }]);
element: '#source_source_regions' $('#source_form').addClass('squeeze');
}); }
if(scope.source.value==="custom"){
} else if (scope.source.value === 'azure') { // need to filter the possible custom scripts by the organization defined for the current inventory
scope.source_region_choices = scope.azure_regions; invUrl = GetBasePath('inventory_scripts') + '?organization='+scope.$parent.inventory.organization;
$('#source_form').addClass('squeeze'); LookUpInit({
CreateSelect2({ url: invUrl,
element: '#source_source_regions' scope: scope,
}); form: form,
} hdr: "Select Custom Inventory",
if(scope.source.value==="custom"){ list: CustomInventoryList,
// need to filter the possible custom scripts by the organization defined for the current inventory field: 'source_script',
invUrl = GetBasePath('inventory_scripts') + '?organization='+scope.$parent.inventory.organization; input_type: 'radio'
LookUpInit({ });
url: invUrl, scope.extra_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
scope: scope, ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName,
form: form, field_id: 'source_extra_vars', onReady: callback });
hdr: "Select Custom Inventory", }
list: CustomInventoryList, if(scope.source.value==="vmware" ||
field: 'source_script', scope.source.value==="openstack"){
input_type: 'radio' scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
}); ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName,
scope.extra_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars; field_id: 'source_inventory_variables', onReady: callback });
ParseTypeChange({ scope: scope, variable: 'extra_vars', parse_variable: form.fields.extra_vars.parseTypeName, }
field_id: 'source_extra_vars', onReady: callback }); if (scope.source.value === 'rax' ||
} scope.source.value === 'ec2' ||
if(scope.source.value==="vmware"){ scope.source.value==='gce' ||
scope.inventory_variables = (Empty(scope.source_vars)) ? "---" : scope.source_vars; scope.source.value === 'azure' ||
ParseTypeChange({ scope: scope, variable: 'inventory_variables', parse_variable: form.fields.inventory_variables.parseTypeName, scope.source.value === 'vmware' ||
field_id: 'source_inventory_variables', onReady: callback }); scope.source.value === 'openstack') {
} if (scope.source.value === 'ec2') {
if (scope.source.value === 'rax' || scope.source.value === 'ec2'|| scope.source.value==='gce' || scope.source.value === 'azure' || scope.source.value === 'vmware') { kind = 'aws';
kind = (scope.source.value === 'rax') ? 'rax' : (scope.source.value==='gce') ? 'gce' : (scope.source.value==='azure') ? 'azure' : (scope.source.value === 'vmware') ? 'vmware' : 'aws' ; } else {
url = GetBasePath('credentials') + '?cloud=true&kind=' + kind; kind = scope.source.value;
LookUpInit({ }
url: url, url = GetBasePath('credentials') + '?cloud=true&kind=' + kind;
scope: scope, LookUpInit({
form: form, url: url,
list: CredentialList, scope: scope,
field: 'credential', form: form,
input_type: "radio" list: CredentialList,
}); field: 'credential',
if ($('#group_tabs .active a').text() === 'Source' && (scope.source.value === 'ec2' )) { input_type: "radio"
callback = function(){ Wait('stop'); }; });
Wait('start'); if ($('#group_tabs .active a').text() === 'Source' &&
scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars; (scope.source.value === 'ec2' )) {
ParseTypeChange({ scope: scope, variable: 'source_vars', parse_variable: form.fields.source_vars.parseTypeName, callback = function(){ Wait('stop'); };
field_id: 'source_source_vars', onReady: callback }); Wait('start');
} scope.source_vars = (Empty(scope.source_vars)) ? "---" : scope.source_vars;
} ParseTypeChange({ scope: scope, variable: 'source_vars',
} parse_variable: form.fields.source_vars.parseTypeName,
}; field_id: 'source_source_vars', onReady: callback });
} }
}
}
};
}
]) ])
/** /**
@@ -903,7 +918,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
Wait('start'); Wait('start');
ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName, ParseTypeChange({ scope: sources_scope, variable: 'source_vars', parse_variable: SourceForm.fields.source_vars.parseTypeName,
field_id: 'source_source_vars', onReady: waitStop }); field_id: 'source_source_vars', onReady: waitStop });
} else if (sources_scope.source && (sources_scope.source.value === 'vmware')) { } else if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
sources_scope.source.value === 'openstack')) {
Wait('start'); Wait('start');
ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName, ParseTypeChange({ scope: sources_scope, variable: 'inventory_variables', parse_variable: SourceForm.fields.inventory_variables.parseTypeName,
field_id: 'source_inventory_variables', onReady: waitStop }); field_id: 'source_inventory_variables', onReady: waitStop });
@@ -1282,7 +1298,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', listGenerator.name
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true); data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.extra_vars, true);
} }
if (sources_scope.source && (sources_scope.source.value === 'vmware')) { if (sources_scope.source && (sources_scope.source.value === 'vmware' ||
sources_scope.source.value === 'openstack')) {
data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true); data.source_vars = ToJSON(sources_scope.envParseType, sources_scope.inventory_variables, true);
} }

View File

@@ -710,9 +710,8 @@ function($compile, Rest, GetBasePath, TextareaResize,CreateDialog, GenerateForm,
if(data.vault_password === "ASK"){ if(data.vault_password === "ASK"){
passwords.push("vault_password"); passwords.push("vault_password");
} }
scope.$emit(callback, passwords);
} }
scope.$emit(callback, passwords);
}) })
.error(function (data, status) { .error(function (data, status) {
ProcessErrors(scope, data, status, null, { hdr: 'Error!', ProcessErrors(scope, data, status, null, { hdr: 'Error!',

View File

@@ -78,6 +78,9 @@ export default
},{ },{
name: "Microsoft Azure", name: "Microsoft Azure",
value: "azure" value: "azure"
},{
name: "Openstack",
value: "openstack"
}], }],
sourceModel: 'inventory_source', sourceModel: 'inventory_source',
sourceField: 'source', sourceField: 'source',
@@ -86,7 +89,7 @@ export default
has_external_source: { has_external_source: {
label: 'Has external source?', label: 'Has external source?',
searchType: 'in', searchType: 'in',
searchValue: 'ec2,rax,vmware,azure,gce', searchValue: 'ec2,rax,vmware,azure,gce,openstack',
searchOnly: true, searchOnly: true,
sourceModel: 'inventory_source', sourceModel: 'inventory_source',
sourceField: 'source' sourceField: 'source'

View File

@@ -47,6 +47,9 @@ export default
},{ },{
name: "Microsoft Azure", name: "Microsoft Azure",
value: "azure" value: "azure"
},{
name: "Openstack",
value: "openstack"
}], }],
sourceModel: 'inventory_source', sourceModel: 'inventory_source',
sourceField: 'source', sourceField: 'source',
@@ -55,7 +58,7 @@ export default
has_external_source: { has_external_source: {
label: 'Has external source?', label: 'Has external source?',
searchType: 'in', searchType: 'in',
searchValue: 'ec2,rax,vmware,azure,gce', searchValue: 'ec2,rax,vmware,azure,gce,openstack',
searchOnly: true, searchOnly: true,
sourceModel: 'inventory_source', sourceModel: 'inventory_source',
sourceField: 'source' sourceField: 'source'

View File

@@ -1505,8 +1505,6 @@ input[type="checkbox"].checkbox-no-label {
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
} }
#groups_table .actions .cancel { padding-right: 2px; }
.node-toggle, .node-no-toggle { .node-toggle, .node-no-toggle {
/* also used on job evetns */ /* also used on job evetns */
float: none; float: none;