1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-22 01:39:58 -05:00

Merge pull request #223 from anusha94/master

changing draas client to vmc_client.draas
This commit is contained in:
Anusha Hegde 2020-05-21 10:45:36 +05:30 committed by GitHub
commit 188ba6b9ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 17 deletions

View File

@ -17,7 +17,6 @@ __author__ = 'VMware, Inc.'
import time import time
from samples.vmc.helpers.sample_cli import parser, optional_args from samples.vmc.helpers.sample_cli import parser, optional_args
from vmware.vapi.vmc.vmc_draas_client import create_vmc_draas_client
from vmware.vapi.vmc.client import create_vmc_client from vmware.vapi.vmc.client import create_vmc_client
@ -45,7 +44,6 @@ class SrmActivationOperations(object):
self.cleanup = args.cleardata self.cleanup = args.cleardata
self.vmc_client = create_vmc_client(refresh_token=args.refresh_token) self.vmc_client = create_vmc_client(refresh_token=args.refresh_token)
self.draas_client = create_vmc_draas_client(refresh_token=args.refresh_token)
def setup(self): def setup(self):
# Check if the organization exists # Check if the organization exists
@ -61,8 +59,8 @@ class SrmActivationOperations(object):
# Activate SRM Addon in a SDDC # Activate SRM Addon in a SDDC
def activate_srm(self): def activate_srm(self):
if self.draas_client.SiteRecovery.get(self.org_id, self.sddc_id).site_recovery_state != "ACTIVATED": if self.vmc_client.draas.SiteRecovery.get(self.org_id, self.sddc_id).site_recovery_state != "ACTIVATED":
srm_activation = self.draas_client.SiteRecovery.post(self.org_id, srm_activation = self.vmc_client.draas.SiteRecovery.post(self.org_id,
self.sddc_id, self.sddc_id,
activate_site_recovery_config=None) activate_site_recovery_config=None)
print("Activation of SRM {} : {}".format(srm_activation.status, print("Activation of SRM {} : {}".format(srm_activation.status,
@ -79,7 +77,7 @@ class SrmActivationOperations(object):
timeout = time.time() + self.max_wait_time timeout = time.time() + self.max_wait_time
while time.time() < timeout: while time.time() < timeout:
time.sleep(self.query_wait_time) time.sleep(self.query_wait_time)
status = self.draas_client.SiteRecovery.get(self.org_id, self.sddc_id) status = self.vmc_client.draas.SiteRecovery.get(self.org_id, self.sddc_id)
if status.site_recovery_state in ['ACTIVATED', 'DEACTIVATED', 'CANCELLED', 'FAILED']: if status.site_recovery_state in ['ACTIVATED', 'DEACTIVATED', 'CANCELLED', 'FAILED']:
print("Site Recovery (DRaaS) Activation Status in {} : {}" print("Site Recovery (DRaaS) Activation Status in {} : {}"
.format(status.updated, status.site_recovery_state)) .format(status.updated, status.site_recovery_state))
@ -95,7 +93,7 @@ class SrmActivationOperations(object):
def deactivate_srm(self): def deactivate_srm(self):
if self.cleanup: if self.cleanup:
print("Deactivating SRM") print("Deactivating SRM")
self.draas_client.SiteRecovery.delete(self.org_id, self.vmc_client.draas.SiteRecovery.delete(self.org_id,
self.sddc_id, self.sddc_id,
force=True) force=True)
self.query_activation_status() self.query_activation_status()

View File

@ -17,7 +17,6 @@ __author__ = 'VMware, Inc.'
import time import time
from samples.vmc.helpers.sample_cli import parser, optional_args from samples.vmc.helpers.sample_cli import parser, optional_args
from vmware.vapi.vmc.vmc_draas_client import create_vmc_draas_client
from vmware.vapi.vmc.client import create_vmc_client from vmware.vapi.vmc.client import create_vmc_client
from com.vmware.vmc.draas.model_client import ProvisionSrmConfig from com.vmware.vmc.draas.model_client import ProvisionSrmConfig
@ -46,7 +45,6 @@ class DeployAdditionalNode(object):
self.cleanup = args.cleardata self.cleanup = args.cleardata
self.vmc_client = create_vmc_client(refresh_token=args.refresh_token) self.vmc_client = create_vmc_client(refresh_token=args.refresh_token)
self.draas_client = create_vmc_draas_client(refresh_token=args.refresh_token)
def setup(self): def setup(self):
# Check if the organization exists # Check if the organization exists
@ -61,13 +59,13 @@ class DeployAdditionalNode(object):
format(self.sddc_id, self.org_id)) format(self.sddc_id, self.org_id))
# Check if the SRM Add-on is activated in VMC # Check if the SRM Add-on is activated in VMC
if "ACTIVATED" != self.draas_client.SiteRecovery.get(self.org_id, self.sddc_id).site_recovery_state: if "ACTIVATED" != self.vmc_client.draas.SiteRecovery.get(self.org_id, self.sddc_id).site_recovery_state:
raise ValueError("DRaaS is not activated in SDDC with ID {} & org with ID {}". raise ValueError("DRaaS is not activated in SDDC with ID {} & org with ID {}".
format(self.sddc_id, self.org_id)) format(self.sddc_id, self.org_id))
# Deploy Additional SRM Node # Deploy Additional SRM Node
def deploy_srm(self): def deploy_srm(self):
deploy_srm = self.draas_client.SiteRecoverySrmNodes.post( deploy_srm = self.vmc_client.draas.SiteRecoverySrmNodes.post(
self.org_id, self.org_id,
self.sddc_id, self.sddc_id,
ProvisionSrmConfig(srm_extension_key_suffix=self.node_extension_id)) ProvisionSrmConfig(srm_extension_key_suffix=self.node_extension_id))
@ -79,12 +77,12 @@ class DeployAdditionalNode(object):
Hence querying the SRM activation status with resource_id and state for the status. Hence querying the SRM activation status with resource_id and state for the status.
''' '''
def query_deployment(self, deployed_node_id): def query_deployment(self, deployed_node_id):
srm_node_details = self.draas_client.SiteRecovery.get(self.org_id, self.sddc_id).srm_nodes srm_node_details = self.vmc_client.draas.SiteRecovery.get(self.org_id, self.sddc_id).srm_nodes
for node_index in range(len(srm_node_details)): for node_index in range(len(srm_node_details)):
if deployed_node_id == srm_node_details[node_index].id: if deployed_node_id == srm_node_details[node_index].id:
timeout = time.time() + self.max_wait_time timeout = time.time() + self.max_wait_time
while time.time() < timeout: while time.time() < timeout:
node_details = self.draas_client.SiteRecovery.get(self.org_id, self.sddc_id) node_details = self.vmc_client.draas.SiteRecovery.get(self.org_id, self.sddc_id)
time.sleep(self.wait_time) time.sleep(self.wait_time)
if node_details.srm_nodes[node_index].state in ['READY', 'DELETING', 'CANCELLED', 'FAILED']: if node_details.srm_nodes[node_index].state in ['READY', 'DELETING', 'CANCELLED', 'FAILED']:
print("Site Recovery (DRaaS) Additonal Node Deployment Status {} : {}" print("Site Recovery (DRaaS) Additonal Node Deployment Status {} : {}"
@ -104,7 +102,7 @@ class DeployAdditionalNode(object):
def delete_node(self, node_id): def delete_node(self, node_id):
if self.cleanup: if self.cleanup:
print("Removing the Additional Node") print("Removing the Additional Node")
self.draas_client.SiteRecoverySrmNodes.delete( self.vmc_client.draas.SiteRecoverySrmNodes.delete(
self.org_id, self.org_id,
self.sddc_id, self.sddc_id,
node_id) node_id)

View File

@ -1,8 +1,7 @@
import argparse import argparse
import requests import requests
from vmware.vapi.vmc.vmc_draas_client import create_vmc_draas_client from vmware.vapi.vmc.client import create_vmc_client
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument( parser.add_argument(
@ -25,6 +24,6 @@ refresh_token = args.refresh_token
org_id = args.org_id org_id = args.org_id
sddc_id = args.sddc_id sddc_id = args.sddc_id
client = create_vmc_draas_client(refresh_token) client = create_vmc_client(refresh_token)
site_recovery_activation_task = client.SiteRecovery.get(org_id, sddc_id) site_recovery_activation_task = client.draas.SiteRecovery.get(org_id, sddc_id)
print(site_recovery_activation_task) print(site_recovery_activation_task)