Skip to content

Commit

Permalink
Revert "Merge dev to local branch (#10)"
Browse files Browse the repository at this point in the history
This reverts commit 1dce8f3.
  • Loading branch information
Fred-sun committed Mar 8, 2022
1 parent 1dce8f3 commit a8b0004
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 129 deletions.
3 changes: 2 additions & 1 deletion plugins/module_utils/azure_rm_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ def __init__(self, auth_source=None, profile=None, subscription_id=None, client_
if self.credentials.get('credentials') is not None:
# AzureCLI credentials
self.azure_credentials = self.credentials['credentials']
self.azure_credential_track2 = self.credentials['credentials']
self.azure_credential_track2 = self.credentials['credential']
elif self.credentials.get('client_id') is not None and \
self.credentials.get('secret') is not None and \
self.credentials.get('tenant') is not None:
Expand Down Expand Up @@ -1619,6 +1619,7 @@ def _get_azure_cli_credentials(self, subscription_id=None, resource=None):

cli_credentials = {
'credentials': credentials,
'credential': credentials,
'subscription_id': subscription_id,
'cloud_environment': cloud_environment
}
Expand Down
7 changes: 0 additions & 7 deletions plugins/modules/azure_rm_keyvaultkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,6 @@ def get_keyvault_client(self):
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")
else:
try:
self.log("Get KeyVaultClient from MSI")
credentials = MSIAuthentication(resource='https://vault.azure.net')
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")

# Create KeyVault Client using KeyVault auth class and auth_callback
def auth_callback(server, resource, scope):
Expand Down
7 changes: 0 additions & 7 deletions plugins/modules/azure_rm_keyvaultkey_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,6 @@ def get_keyvault_client(self):
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")
else:
try:
self.log("Get KeyVaultClient from MSI")
credentials = MSIAuthentication(resource='https://vault.azure.net')
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")

# Create KeyVault Client using KeyVault auth class and auth_callback
def auth_callback(server, resource, scope):
Expand Down
7 changes: 0 additions & 7 deletions plugins/modules/azure_rm_keyvaultsecret.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,6 @@ def get_keyvault_client(self):
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")
else:
try:
self.log("Get KeyVaultClient from MSI")
credentials = MSIAuthentication(resource='https://vault.azure.net')
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")

# Create KeyVault Client using KeyVault auth class and auth_callback
def auth_callback(server, resource, scope):
Expand Down
7 changes: 0 additions & 7 deletions plugins/modules/azure_rm_keyvaultsecret_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,6 @@ def get_keyvault_client(self):
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")
else:
try:
self.log("Get KeyVaultClient from MSI")
credentials = MSIAuthentication(resource='https://vault.azure.net')
return KeyVaultClient(credentials)
except Exception:
self.log("Get KeyVaultClient from service principal")

# Create KeyVault Client using KeyVault auth class and auth_callback
def auth_callback(server, resource, scope):
Expand Down
15 changes: 4 additions & 11 deletions plugins/modules/azure_rm_sqldatabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@
from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase, format_resource_id

try:
import dateutil.parser
from msrestazure.azure_exceptions import CloudError
from msrest.polling import LROPoller
from azure.mgmt.sql import SqlManagementClient
Expand Down Expand Up @@ -309,10 +308,10 @@ def __init__(self):
type='str'
),
source_database_deletion_date=dict(
type='str'
type='datetime'
),
restore_point_in_time=dict(
type='str'
type='datetime'
),
recovery_services_recovery_point_resource_id=dict(
type='str'
Expand Down Expand Up @@ -394,15 +393,9 @@ def exec_module(self, **kwargs):
elif key == "source_database_id":
self.parameters["source_database_id"] = kwargs[key]
elif key == "source_database_deletion_date":
try:
self.parameters["source_database_deletion_date"] = dateutil.parser.parse(kwargs[key])
except dateutil.parser._parser.ParserError:
self.fail("Error parsing date from source_database_deletion_date: {0}".format(kwargs[key]))
self.parameters["source_database_deletion_date"] = kwargs[key]
elif key == "restore_point_in_time":
try:
self.parameters["restore_point_in_time"] = dateutil.parser.parse(kwargs[key])
except dateutil.parser._parser.ParserError:
self.fail("Error parsing date from restore_point_in_time: {0}".format(kwargs[key]))
self.parameters["restore_point_in_time"] = kwargs[key]
elif key == "recovery_services_recovery_point_resource_id":
self.parameters["recovery_services_recovery_point_resource_id"] = kwargs[key]
elif key == "edition":
Expand Down
9 changes: 1 addition & 8 deletions plugins/modules/azure_rm_sqldatabase_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@
returned: always
type: bool
sample: true
earliest_restore_date:
description:
- The earliest restore point available for the SQL Database.
returned: always
type: str
sample: '2021-09-01T00:59:59.000Z'
'''

from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase
Expand Down Expand Up @@ -276,8 +270,7 @@ def format_item(self, item):
'kind': d.get('kind', None),
'collation': d.get('collation', None),
'status': d.get('status', None),
'zone_redundant': d.get('zone_redundant', None),
'earliest_restore_date': d.get('earliest_restore_date', None)
'zone_redundant': d.get('zone_redundant', None)
}
return d

Expand Down
14 changes: 1 addition & 13 deletions plugins/modules/azure_rm_virtualmachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,6 @@
import base64
import random
import re
import time

try:
from azure.core.exceptions import ResourceNotFoundError
Expand Down Expand Up @@ -1110,18 +1109,7 @@ def exec_module(self, **kwargs):
try:
self.log("Fetching virtual machine {0}".format(self.name))
vm = self.compute_client.virtual_machines.get(self.resource_group, self.name, expand='instanceview')
retry_count = 0
while True:
if retry_count == 10:
self.fail("Error {0} has a provisioning state of Updating. Expecting state to be Successed.".format(self.name))

if vm.provisioning_state == 'Updating':
retry_count = retry_count + 1
time.sleep(300)
vm = self.compute_client.virtual_machines.get(self.resource_group, self.name, expand='instanceview')
else:
break

self.check_provisioning_state(vm, self.state)
vm_dict = self.serialize_vm(vm)

if self.state == 'present':
Expand Down
26 changes: 11 additions & 15 deletions tests/integration/targets/azure_rm_containerinstance/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
- name: Set Container Instance Names
set_fact:
rpfx: "{{ resource_group | hash('md5') | truncate(7, True, '') }}{{ 1000 | random }}"

- name: Create sample container instance
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
os_type: linux
ip_address: public
location: eastus
Expand All @@ -32,7 +28,7 @@
- name: Create sample container instance -- same parameters
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
os_type: linux
ip_address: public
location: eastus
Expand All @@ -55,7 +51,7 @@
- name: Create sample container instance -- force update
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
os_type: linux
ip_address: public
location: eastus
Expand All @@ -80,7 +76,7 @@
- name: Create second container instance for testing purposes
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}sec"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
os_type: linux
ip_address: public
dns_name_label: mydnslabel{{ resource_group | hash('md5') | truncate(7, True, '') }}
Expand All @@ -103,7 +99,7 @@
- name: Gather facts for single Container Instance
azure_rm_containerinstance_info:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}sec"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
register: output

- debug:
Expand Down Expand Up @@ -150,7 +146,7 @@
- name: Create sample container instance with volume
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}thi"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}thi"
os_type: linux
ip_address: public
location: eastus
Expand Down Expand Up @@ -189,7 +185,7 @@
- name: Gather facts for Container Instance
azure_rm_containerinstance_info:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}thi"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}thi"
register: output
ignore_errors: True

Expand Down Expand Up @@ -217,7 +213,7 @@
- name: Remove container instance
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}thi"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}thi"
os_type: linux
ip_address: public
location: eastus
Expand Down Expand Up @@ -246,7 +242,7 @@
- name: Remove container instance
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
os_type: linux
ip_address: public
location: eastus
Expand All @@ -270,7 +266,7 @@
- name: Remove container instance
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}sec"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}sec"
os_type: linux
ip_address: public
location: eastus
Expand All @@ -288,7 +284,7 @@
- name: Remove container instance again
azure_rm_containerinstance:
resource_group: "{{ resource_group }}"
name: "aci{{ rpfx }}"
name: "aci{{ resource_group | hash('md5') | truncate(7, True, '') }}"
os_type: linux
ip_address: public
location: eastus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@
azure_rm_cosmosdbaccount:
resource_group: "{{ resource_group_secondary }}"
name: "{{ db2name }}"
location: eastasia
location: westus
kind: global_document_db
geo_rep_locations:
- name: eastasia
- name: southcentralus
failover_priority: 0
- name: westus
- name: eastus2
failover_priority: 1
database_account_offer_type: Standard
is_virtual_network_filter_enabled: yes
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/targets/azure_rm_gallery/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
- name: Create virtual network
azure_rm_virtualnetwork:
resource_group: "{{ resource_group }}"
name: "testVnet{{ rpfx }}"
name: testVnet
address_prefixes: "10.0.0.0/16"

- name: Add subnet
azure_rm_subnet:
resource_group: "{{ resource_group }}"
name: "testSubnet{{ rpfx }}"
name: testSubnet
address_prefix: "10.0.1.0/24"
virtual_network: "testVnet{{ rpfx }}"
virtual_network: testVnet

- name: Create public IP address
azure_rm_publicipaddress:
resource_group: "{{ resource_group }}"
allocation_method: Static
name: "testPublicIP{{ rpfx }}"
name: testPublicIP

- name: Create virtual network inteface cards for VM A and B
azure_rm_networkinterface:
resource_group: "{{ resource_group }}"
name: "vmforimage{{ rpfx }}nic"
virtual_network: "testVnet{{ rpfx }}"
subnet: "testSubnet{{ rpfx }}"
virtual_network: testVnet
subnet: testSubnet

- name: Create VM
azure_rm_virtualmachine:
Expand Down
42 changes: 0 additions & 42 deletions tests/integration/targets/azure_rm_sqlserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,48 +143,6 @@
- output.changed == false
- output.status == 'Online'

# test database point in time restore
- name: Gather facts SQL Database and wait for restore point
azure_rm_sqldatabase_info:
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}
register: output
until: output.databases[0].earliest_restore_date != None
retries: 10
delay: 20
- name: Assert that it can be restored from
assert:
that:
- output.databases[0].id != None
- output.databases[0].earliest_restore_date != None

- name: Create second SQL Database, restoring from the previous Database
azure_rm_sqldatabase:
resource_group: "{{ resource_group }}"
create_mode: point_in_time_restore
restore_point_in_time: "{{ output.databases[0].earliest_restore_date }}"
source_database_id: "{{ output.databases[0].id }}"
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}PITR
register: output
- name: Assert the state has changed
assert:
that:
- output.changed

- name: Delete instance of SQL Database Point in time recovery
azure_rm_sqldatabase:
resource_group: "{{ resource_group }}"
server_name: sqlsrv{{ random_postfix }}
name: database{{ random_postfix }}PITR
state: absent
register: output
- name: Assert the state has changed
assert:
that:
- output.changed

# test database facter:
- name: Create second SQL Database
azure_rm_sqldatabase:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ security_group: "{{ 'sg' ~ uid_short }}"
public_ip_name: "{{ 'ip' ~ uid_short }}"
interface_name: "{{ 'int' ~ uid_short }}"
network: 10.42.0.0/24
subnet: 10.42.0.0/28
subnet: 10.42.0.0/28
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.10.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ plugins/modules/azure_rm_servicebussaspolicy.py validate-modules:doc-required-mi
plugins/modules/azure_rm_snapshot.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_snapshot.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_sqlfirewallrule.py validate-modules:parameter-type-not-in-doc
Expand Down
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ plugins/modules/azure_rm_servicebussaspolicy.py validate-modules:doc-required-mi
plugins/modules/azure_rm_snapshot.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_snapshot.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_sqlfirewallrule.py validate-modules:parameter-type-not-in-doc
Expand Down
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.12.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ plugins/modules/azure_rm_servicebussaspolicy.py validate-modules:doc-required-mi
plugins/modules/azure_rm_snapshot.py validate-modules:doc-required-mismatch
plugins/modules/azure_rm_snapshot.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase.py validate-modules:invalid-ansiblemodule-schema
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-type-not-in-doc
plugins/modules/azure_rm_sqldatabase_info.py validate-modules:parameter-list-no-elements
plugins/modules/azure_rm_sqlfirewallrule.py validate-modules:parameter-type-not-in-doc
Expand Down
Loading

0 comments on commit a8b0004

Please sign in to comment.