Adding sql client to common (#44825)

This commit is contained in:
Zim Kalinowski 2018-08-30 12:44:36 +08:00 committed by Yunge Zhu
parent b0cee34ca1
commit 78eb4724a0
4 changed files with 30 additions and 31 deletions

View file

@ -165,7 +165,6 @@ class AzureRMServers(AzureRMModuleBase):
self.parameters = dict()
self.results = dict(changed=False)
self.mgmt_client = None
self.state = None
self.to_do = Actions.NoAction
@ -195,9 +194,6 @@ class AzureRMServers(AzureRMModuleBase):
response = None
results = dict()
self.mgmt_client = self.get_mgmt_svc_client(SqlManagementClient,
base_url=self._cloud_environment.endpoints.resource_manager)
resource_group = self.get_resource_group(self.resource_group)
if "location" not in self.parameters:
@ -268,9 +264,9 @@ class AzureRMServers(AzureRMModuleBase):
self.log("Creating / Updating the SQL Server instance {0}".format(self.name))
try:
response = self.mgmt_client.servers.create_or_update(self.resource_group,
self.name,
self.parameters)
response = self.sql_client.servers.create_or_update(self.resource_group,
self.name,
self.parameters)
if isinstance(response, AzureOperationPoller):
response = self.get_poller_result(response)
@ -287,8 +283,8 @@ class AzureRMServers(AzureRMModuleBase):
'''
self.log("Deleting the SQL Server instance {0}".format(self.name))
try:
response = self.mgmt_client.servers.delete(self.resource_group,
self.name)
response = self.sql_client.servers.delete(self.resource_group,
self.name)
except CloudError as e:
self.log('Error attempting to delete the SQL Server instance.')
self.fail("Error deleting the SQL Server instance: {0}".format(str(e)))
@ -304,8 +300,8 @@ class AzureRMServers(AzureRMModuleBase):
self.log("Checking if the SQL Server instance {0} is present".format(self.name))
found = False
try:
response = self.mgmt_client.servers.get(self.resource_group,
self.name)
response = self.sql_client.servers.get(self.resource_group,
self.name)
found = True
self.log("Response : {0}".format(response))
self.log("SQL Server instance : {0} found".format(response.name))