Skip to content

Commit

Permalink
Commvault weekly update 04-01-2019
Browse files Browse the repository at this point in the history
  • Loading branch information
TurinEngineering committed Jan 4, 2019
1 parent 4116620 commit 136322f
Show file tree
Hide file tree
Showing 12 changed files with 953 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ GNUmakefile

.gitignore

build/*
cvpysdk.egg-info/*
dist/*

*.pyc
*.bat
/CVS
Expand Down
131 changes: 127 additions & 4 deletions cvpysdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
add_exchange_client() -- adds a new Exchange Virtual Client to the Commcell
add_case_client() -- adds a new Case Manger Client to the Commcell
get(client_name) -- returns the Client class object of the input client
name
Expand Down Expand Up @@ -158,7 +160,7 @@
reconfigure_client() -- reapplies license to the client
push_servicepack_and_hotfixes() -- triggers installation of service pack and hotfixes
get_dag_member_servers() -- Gets the member servers of an Exchange DAG client.
Client Attributes
Expand Down Expand Up @@ -253,6 +255,7 @@
from .deployment.install import Install

from .network import Network
from .network_throttle import NetworkThrottle

from .security.user import Users

Expand Down Expand Up @@ -957,6 +960,113 @@ def add_exchange_client(
else:
raise SDKException('Response', '101', self._update_response_(response.text))

def add_case_client(
self,
client_name,
server_plan,
dc_plan,
hold_type):
"""Adds a new Exchange Mailbox Client to the Commcell.
Args:
client_name (str) -- name of the new Case Client
server_plan (str) -- Server plan to assocaite to case
dc_plan (str) -- DC plan to assocaite to case
hold_type (int) -- Type of client (values: 1, 2, 3)
Returns:
object - instance of the Client class for this new client
Raises:
SDKException:
if client with given name already exists
if failed to add the client
if response is empty
if response is not success
"""

plans_list = []
dc_plan_dict = {}
if self._commcell_object.plans.has_plan(dc_plan):
dc_plan_object = self._commcell_object.plans.get(dc_plan)
dc_plan_dict = {
"planId": int(dc_plan_object.plan_id),
"planType": int(dc_plan_object.plan_type)
}
plans_list.append(dc_plan_dict)
if self._commcell_object.plans.has_plan(server_plan):
server_plan_object = self._commcell_object.plans.get(server_plan)
server_plan_dict = {
"planId": int(server_plan_object.plan_id),
"planType": int(server_plan_object.plan_type)
}
plans_list.append(server_plan_dict)

request_json = {
"clientInfo": {
"clientType": 36,
"edgeDrivePseudoClientProperties": {
"eDiscoveryInfo": {
"custodians": ""
}
},
"plan": dc_plan_dict,
"exchangeOnePassClientProperties": {
"backupSetTypeToCreate": hold_type
},
"caseManagerPseudoClientProperties": {
"eDiscoveryInfo": {
"eDiscoverySubType": 1,
"additionalPlans": plans_list,
"appTypeIds": [
137
]
}
}
},
"entity": {
"clientName": client_name,
"_type_": 3
}
}
flag, response = self._cvpysdk_object.make_request(
'POST', self._ADD_EXCHANGE_CLIENT, request_json
)
if flag:
if response.json():
if 'response' in response.json():
error_code = response.json()['response']['errorCode']

if error_code != 0:
error_string = response.json()['response']['errorString']
o_str = 'Failed to create client\nError: "{0}"'.format(error_string)

raise SDKException('Client', '102', o_str)
else:
# initialize the clients again
# so the client object has all the clients
self.refresh()

return self.get(client_name)
elif 'errorMessage' in response.json():
error_string = response.json()['errorMessage']
o_str = 'Failed to create client\nError: "{0}"'.format(error_string)

raise SDKException('Client', '102', o_str)
else:
raise SDKException('Response', '102')
else:
raise SDKException('Response', '102')
else:
raise SDKException('Response', '101', self._update_response_(response.text))

def get(self, name):
"""Returns a client object if client name or host name matches specified name
We check if specified name matches any of the existing client names else
Expand Down Expand Up @@ -1122,7 +1232,7 @@ def __init__(self, commcell_object, client_name, client_id=None):
self._schedules = None
self._users = None
self._network = None

self._network_throttle = None
self._association_object = None

self._properties = None
Expand All @@ -1145,7 +1255,6 @@ def __init__(self, commcell_object, client_name, client_id=None):
self._license_info = None
self._cvd_port = None


self.refresh()

def __repr__(self):
Expand Down Expand Up @@ -1768,6 +1877,14 @@ def network(self):

return self._network

@property
def network_throttle(self):
"""Returns the object of NetworkThrottle class"""
if self._network_throttle is None:
self._network_throttle = NetworkThrottle(self)

return self._network_throttle

def enable_backup(self):
"""Enable Backup for this Client.
Expand Down Expand Up @@ -3134,7 +3251,7 @@ def get_dag_member_servers(self):
return member_servers

else:
raise SDKException('Response', '102')
raise SDKException('Response', '102')
else:
raise SDKException('Response', '101')

Expand Down Expand Up @@ -3216,3 +3333,9 @@ def client_guid(self):
"""Returns client GUID"""

return self._properties.get('client', {}).get('clientEntity', {}).get('clientGUID', {})

@property
def client_type(self):
"""Returns client Type"""

return self._properties.get('pseudoClientInfo', {}).get('clientType', "")
14 changes: 14 additions & 0 deletions cvpysdk/clientgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@

from .exception import SDKException
from .network import Network
from .network_throttle import NetworkThrottle
from .deployment.install import Install


Expand Down Expand Up @@ -1146,6 +1147,16 @@ def network(self):

return self._networkprop


@property
def network_throttle(self):
"""Returns the object of NetworkThrottle class"""
if self._network_throttle is None:
self._network_throttle = NetworkThrottle(self)

return self._network_throttle


@property
def client_group_filter(self):
"""Returns the client group filters"""
Expand Down Expand Up @@ -1186,6 +1197,7 @@ def client_group_filter(self, filters):
self._process_request_(request_json)
self.refresh()


def enable_backup(self):
"""Enable Backup for this ClientGroup.
Expand Down Expand Up @@ -1620,3 +1632,5 @@ def refresh(self):
"""Refresh the properties of the ClientGroup."""
self._initialize_clientgroup_properties()
self._networkprop = Network(self)
self._network_throttle = None

12 changes: 12 additions & 0 deletions cvpysdk/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
SQLDefines -- Class which maintains the defines list for SQL Server
AdvancedJobDetailType -- Enum to maintain advanced job details info type
"""

from enum import Enum
Expand Down Expand Up @@ -115,3 +117,13 @@ class SharepointDefines:
# sharepoint strings
CONTENT_WEBAPP = '\\MB\\Farm\\Microsoft SharePoint Foundation Web Application\\{0}'
CONTENT_DB = '\\MB\\Farm\\Microsoft SharePoint Foundation Web Application\\{0}\\{1}'

class AdvancedJobDetailType(Enum):
"""Class to maintain advanced job details info type
"""

RETENTION_INFO = 1
REFERNCE_COPY_INFO = 2
DASH_COPY_INFO = 4
ADMIN_DATA_INFO = 8
BKUP_INFO = 16
3 changes: 2 additions & 1 deletion cvpysdk/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@
'103': 'No job exists with the specified Job ID',
'104': 'No records found for this Job',
'105': 'Failed to get the Job Details',
'106': 'Unexpected response received from server'
'106': 'Unexpected response received from server',
'107': 'Job Info Type not passed from AdvancedJobDetailType enum'
},
'Storage': {
'101': 'Data type of the input(s) is not valid',
Expand Down
40 changes: 40 additions & 0 deletions cvpysdk/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@
refresh() -- refresh the properties of the Job
advanced_job_details() -- Returns advanced properties for the job
Job instance Attributes
-----------------------
Expand Down Expand Up @@ -136,6 +138,7 @@
import time

from .exception import SDKException
from .constants import AdvancedJobDetailType


class JobController(object):
Expand Down Expand Up @@ -1183,3 +1186,40 @@ def refresh(self):
"""Refresh the properties of the Job."""
self._initialize_job_properties()
self.is_finished

def advanced_job_details(self, info_type):
"""Returns advanced properties for the job
Args:
infoType (object) -- job detail type to be passed from AdvancedJobDetailType
enum from the constants
Returns:
dict - dictionary with advanced details of the job info type given
Raises:
SDKException:
if response is empty
if response is not success
"""
if not isinstance(info_type, AdvancedJobDetailType):
raise SDKException('Response', '107')
url = self._services['ADVANCED_JOB_DETAIL_TYPE'] % (self.job_id, info_type.value)
flag, response = self._cvpysdk_object.make_request('GET', url)

if flag:
if response.json():
response = response.json()

if response.get('errorCode', 0) != 0:
error_message = response.json()['errorMessage']
o_str = 'Failed to fetch details.\nError: "{0}"'.format(error_message)
raise SDKException('Job', '102', o_str)

return response
else:
raise SDKException('Response', '102')
else:
raise SDKException('Response', '101', self._update_response_(response.text))
Loading

0 comments on commit 136322f

Please sign in to comment.