mirror of
https://github.com/ansible/awx.git
synced 2024-11-01 08:21:15 +03:00
Prevent passing "all" to GCE_ZONE
This commit is contained in:
parent
2fae1d22f9
commit
148af54af7
@ -1847,7 +1847,7 @@ 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'] = cloud_credential
|
env['GCE_PEM_FILE_PATH'] = cloud_credential
|
||||||
env['GCE_ZONE'] = inventory_update.source_regions
|
env['GCE_ZONE'] = inventory_update.source_regions if inventory_update.source_regions != 'all' else ''
|
||||||
elif inventory_update.source == 'openstack':
|
elif inventory_update.source == 'openstack':
|
||||||
env['OS_CLIENT_CONFIG_FILE'] = cloud_credential
|
env['OS_CLIENT_CONFIG_FILE'] = cloud_credential
|
||||||
elif inventory_update.source == 'satellite6':
|
elif inventory_update.source == 'satellite6':
|
||||||
|
@ -1274,6 +1274,7 @@ class TestInventoryUpdateCredentials(TestJobExecution):
|
|||||||
def test_gce_source(self):
|
def test_gce_source(self):
|
||||||
gce = CredentialType.defaults['gce']()
|
gce = CredentialType.defaults['gce']()
|
||||||
self.instance.source = 'gce'
|
self.instance.source = 'gce'
|
||||||
|
self.instance.source_regions = 'all'
|
||||||
self.instance.credential = Credential(
|
self.instance.credential = Credential(
|
||||||
pk=1,
|
pk=1,
|
||||||
credential_type=gce,
|
credential_type=gce,
|
||||||
@ -1286,11 +1287,13 @@ class TestInventoryUpdateCredentials(TestJobExecution):
|
|||||||
self.instance.credential.inputs['ssh_key_data'] = encrypt_field(
|
self.instance.credential.inputs['ssh_key_data'] = encrypt_field(
|
||||||
self.instance.credential, 'ssh_key_data'
|
self.instance.credential, 'ssh_key_data'
|
||||||
)
|
)
|
||||||
|
expected_gce_zone = ''
|
||||||
|
|
||||||
def run_pexpect_side_effect(*args, **kwargs):
|
def run_pexpect_side_effect(*args, **kwargs):
|
||||||
args, cwd, env, stdout = args
|
args, cwd, env, stdout = args
|
||||||
assert env['GCE_EMAIL'] == 'bob'
|
assert env['GCE_EMAIL'] == 'bob'
|
||||||
assert env['GCE_PROJECT'] == 'some-project'
|
assert env['GCE_PROJECT'] == 'some-project'
|
||||||
|
assert env['GCE_ZONE'] == expected_gce_zone
|
||||||
ssh_key_data = env['GCE_PEM_FILE_PATH']
|
ssh_key_data = env['GCE_PEM_FILE_PATH']
|
||||||
assert open(ssh_key_data, 'rb').read() == self.EXAMPLE_PRIVATE_KEY
|
assert open(ssh_key_data, 'rb').read() == self.EXAMPLE_PRIVATE_KEY
|
||||||
return ['successful', 0]
|
return ['successful', 0]
|
||||||
@ -1298,6 +1301,10 @@ class TestInventoryUpdateCredentials(TestJobExecution):
|
|||||||
self.run_pexpect.side_effect = run_pexpect_side_effect
|
self.run_pexpect.side_effect = run_pexpect_side_effect
|
||||||
self.task.run(self.pk)
|
self.task.run(self.pk)
|
||||||
|
|
||||||
|
self.instance.source_regions = 'us-east-4'
|
||||||
|
expected_gce_zone = 'us-east-4'
|
||||||
|
self.task.run(self.pk)
|
||||||
|
|
||||||
def test_openstack_source(self):
|
def test_openstack_source(self):
|
||||||
openstack = CredentialType.defaults['openstack']()
|
openstack = CredentialType.defaults['openstack']()
|
||||||
self.instance.source = 'openstack'
|
self.instance.source = 'openstack'
|
||||||
|
Loading…
Reference in New Issue
Block a user