def __init__(self, username=None, password=None, server_ip=None, port=None, verify=None, u4v_version=constants.UNISPHERE_VERSION, interval=5, retries=200, array_id=None, application_type=None, remote_array=None, remote_array_2=None): """__init__.""" config = config_handler.set_logger_and_config(file_path) self.end_date = int(round(time.time() * 1000)) self.start_date = (self.end_date - 3600000) self.array_id = array_id # Set array ID if not self.array_id: try: self.array_id = config.get(SETUP, ARRAY) except Exception: LOG.warning( 'No array id specified. Please set array ID using ' 'U4VConn.set_array_id(array_id).') # Set environment config if config is not None: if not username: username = config.get(SETUP, USERNAME) if not password: password = config.get(SETUP, PASSWORD) if not server_ip: server_ip = config.get(SETUP, SERVER_IP) if not port: port = config.get(SETUP, PORT) # Optional Parameters for SRDF Remote array configurations if config.has_option(SETUP, R_ARRAY): if not remote_array: self.remote_array = config.get(SETUP, R_ARRAY) else: self.remote_array = None if config.has_option(SETUP, R_ARRAY_2): if not remote_array_2: self.remote_array_2 = config.get(SETUP, R_ARRAY_2) else: self.remote_array_2 = None # Set verification if verify is None: try: verify = config.get(SETUP, VERIFY) if verify.lower() == 'false': verify = False elif verify.lower() == 'true': verify = True except Exception: verify = True if None in [username, password, server_ip, port]: raise exception.MissingConfigurationException # Initialise REST session base_url = 'https://{server_ip}:{port}/univmax/restapi'.format( server_ip=server_ip, port=port) self.rest_client = RestRequests( username, password, verify, base_url, interval, retries, application_type) self.request = self.rest_client.rest_request self.common = CommonFunctions(self.rest_client) self.provisioning = ProvisioningFunctions(self.array_id, self.rest_client) self.performance = PerformanceFunctions(self.array_id, self.rest_client) self.replication = ReplicationFunctions(self.array_id, self.rest_client) self.metro_dr = MetroDRFunctions(self.array_id, self.rest_client) self.migration = MigrationFunctions(self.array_id, self.rest_client) self.wlp = WLPFunctions(self.array_id, self.rest_client) self.snapshot_policy = SnapshotPolicyFunctions(self.array_id, self.rest_client) self.system = SystemFunctions(self.array_id, self.rest_client) self.validate_unisphere()
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """univmax_conn.py.""" import logging import time from PyU4V.common import CommonFunctions from PyU4V.migration import MigrationFunctions from PyU4V.performance import PerformanceFunctions from PyU4V.provisioning import ProvisioningFunctions from PyU4V.replication import ReplicationFunctions from PyU4V.rest_requests import RestRequests from PyU4V.utils import config_handler from PyU4V.utils import constants file_path = None CFG = config_handler.set_logger_and_config(file_path) LOG = logging.getLogger(__name__) class U4VConn(object): """U4VConn.""" def __init__(self, username=None, password=None, server_ip=None, port=None, verify=None, u4v_version=constants.UNIVMAX_VERSION, interval=5, retries=200, array_id=None):
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """PyU4V exception class.""" import logging # register configuration file from PyU4V.utils import config_handler import six LOG = logging.getLogger(__name__) CFG = config_handler.set_logger_and_config() class PyU4VException(Exception): """PyU4V exception class.""" message = "An unknown exception occurred." code = 500 headers = {} safe = False def __init__(self, message=None, **kwargs): """Class initialization.""" self.kwargs = kwargs self.kwargs['message'] = message