Beispiel #1
0
    def __init__(self):
        """ Define all parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_distributed_device_parameters())
        # initialize the ansible module
        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False)
        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)
        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")
        # Create the configuration instance to communicate with vplexapi
        self.client = utils.config_vplexapi(self.module.params)
        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client
            LOG.error(msg)
            LOG.error(err_code)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        api_obj = utils.VplexapiModules()
        # Create an instance to required API's to communicate with vplexapi
        self.distdevice = api_obj.DistributedStorageApi(api_client=self.client)
        self.device = api_obj.DevicesApi(api_client=self.client)
        self.cluster = api_obj.ClustersApi(api_client=self.client)
        self.maps_client = api_obj.MapsApi(api_client=self.client)
Beispiel #2
0
    def __init__(self):
        """Define all parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_extent_parameters())
        self.resource_fail_msg = "Failed to collect resources"
        self.fail_msg = "Could not collect resources in {0}"
        mutually_exclusive = [['storage_volume_name', 'storage_volume_id']]
        required_one_of = [[
            'storage_volume_name', 'storage_volume_id', 'extent_name'
        ]]
        # initialize the ansible module
        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False,
                                    mutually_exclusive=mutually_exclusive,
                                    required_one_of=required_one_of)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        self.cl_name = self.module.params['cluster_name']
        self.state = self.module.params['state']
        # Create the configuration instance to communicate with
        # vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        (err_code, msg) = utils.verify_cluster_name(self.client, self.cl_name)
        if err_code != 200:
            if "Resource not found" in msg:
                msg = "Could not find resource {0}".format(self.cl_name)
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        # Create an instance to ExtentApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.extent = api_obj.ExtentApi(api_client=self.client)
        self.stor_obj = api_obj.StorageVolumeApi(api_client=self.client)

        # result is a dictionary that contains changed status and
        # extent details
        self.result = {"changed": False, "extent_details": {}}
    def __init__(self):
        """Define all parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_port_parameters())

        # initialize the ansible module
        self.module = AnsibleModule(
            argument_spec=self.module_params,
            supports_check_mode=False,
        )

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                      "the vplexapi python library to be "
                                      "installed. Please install the library "
                                      "before using these modules.")

        self.cl_name = self.module.params['cluster_name']
        self.port_nm = self.module.params['port_name']
        self.enabled = self.module.params['enabled']
        self.state = self.module.params['state']

        # Create the configuration instance to communicate with
        # vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client  # pylint: disable=W0612
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        (status, msg) = utils.verify_cluster_name(self.client, self.cl_name)
        if status != 200:
            if "Resource not found" in msg:
                msg = "Could not find resource {0}".format(self.cl_name)
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        # Create an instance to PortApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.port = api_obj.ExportsApi(api_client=self.client)

        # result is a dictionary that contains changed status and
        # port details
        self.result = {"changed": False, "port_details": {}}
    def __init__(self):
        """Define all parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_distributed_virtual_volume_parameters())

        mutually_exclusive = [[
            'distributed_virtual_volume_name', 'distributed_virtual_volume_id'
        ]]

        required_one_of = [[
            'distributed_virtual_volume_name', 'distributed_virtual_volume_id'
        ]]

        # initialize the ansible module
        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False,
                                    mutually_exclusive=mutually_exclusive,
                                    required_one_of=required_one_of)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        # Create the configuration instance to communicate with
        # vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client  # pylint: disable=W0612
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Create an instance to DistributedStorageApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.distvv = api_obj.DistributedStorageApi(api_client=self.client)
        self.cluster = api_obj.ClustersApi(api_client=self.client)
        self.vvol = api_obj.VirtualVolumeApi(api_client=self.client)

        # result is a dictionary that contains changed status and
        # distributed virtual volume details
        self.result = {"changed": False, "dist_vv_details": {}}
Beispiel #5
0
    def __init__(self):
        """Define all the parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_cg_parameters())

        required_together = [['virtual_volumes', 'virtual_volume_state']]

        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False,
                                    required_together=required_together)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        self.cl_name = self.module.params['cluster_name']

        # Create the configuration instance to communicate
        # with vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs

        if isinstance(self.client, tuple):
            err_code, msg = self.client
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        (err_code, msg) = utils.verify_cluster_name(self.client, self.cl_name)
        if err_code != 200:
            if "Resource not found" in msg:
                msg = "Could not find resource {0}".format(self.cl_name)
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        # Create an instance to ConsistencyGroupApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.cgrp = api_obj.ConsistencyGroupApi(api_client=self.client)
        self.vvol = api_obj.VirtualVolumeApi(api_client=self.client)
        LOG.info('Got the vplexapi instance for provisioning')
    def __init__(self):
        """Define all parameters required by the module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_user_parameters())
        mutually_exclusive = [['storage_volume_name', 'storage_volume_id']]
        required_one_of = [['storage_volume_name', 'storage_volume_id']]
        self.module = AnsibleModule(argument_spec=self.module_params,
                                    mutually_exclusive=mutually_exclusive,
                                    required_one_of=required_one_of,
                                    supports_check_mode=False)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        # Create the configuration instance to communicate with
        # vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        if self.module.params['cluster_name']:
            cl_name = self.module.params['cluster_name']
            (err_code, msg) = utils.verify_cluster_name(self.client, cl_name)
            if err_code != 200:
                if "Resource not found" in msg:
                    msg = "Could not find resource {0}".format(cl_name)
                LOG.error(msg)
                self.module.fail_json(msg=msg)
        api_obj = utils.VplexapiModules()
        self.strg_client = api_obj.StorageVolumeApi(api_client=self.client)
        self.cluster_name = self.module.params['cluster_name']
        self.all_vols = None

        LOG.info("Got VPLEX instance to access common lib methods " "on VPLEX")
    def __init__(self):
        """Define all the parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_dcg_parameters())

        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        # Create the configuration instance to communicate
        # with vplexapi
        self.client = utils.config_vplexapi(self.module.params)

        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client  # pylint: disable=W0612
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Create an instance to ConsistencyGroupApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.clus = api_obj.ClustersApi(api_client=self.client)
        self.cgrp = api_obj.ConsistencyGroupApi(api_client=self.client)
        self.dcgrp = api_obj.DistributedStorageApi(api_client=self.client)
        LOG.info('Got the vplexapi instance for provisioning')
    def __init__(self):
        """Define all the parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_data_migration_parameters())

        self.module = AnsibleModule(
            argument_spec=self.module_params,
            supports_check_mode=False,
        )

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        # Create the configuration instance to communicate
        # with vplexapi
        self.client = utils.config_vplexapi(self.module.params)
        self.cl_name = self.module.params['cluster_name']
        self.target_cl = self.module.params['target_cluster']

        # Validating the user inputs
        if isinstance(self.client, tuple):
            _, msg = self.client
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        clusters = []
        if self.cl_name is not None:
            clusters.append(self.cl_name)
        if (self.target_cl is not None and self.target_cl != self.cl_name):
            clusters.append(self.target_cl)

        for cluster in clusters:
            (err_code, msg) = utils.verify_cluster_name(self.client, cluster)
            if err_code != 200:
                if "Resource not found" in msg:
                    msg = "Could not find resource {0}".format(cluster)
                LOG.error(msg)
                self.module.fail_json(msg=msg)

        # Create an instance to storageApi to communicate with
        # vplexapi
        api_obj = utils.VplexapiModules()
        self.data = api_obj.DataMigrationApi(api_client=self.client)
        self.device = api_obj.DevicesApi(api_client=self.client)
        LOG.info('Got the vplexapi instance for Mobility')

        self.storage = "device"
        self.storage_uri = "devices"
Beispiel #9
0
    def __init__(self):
        """Define all the parameters required by this module"""
        self.module_params = utils.get_vplex_management_host_parameters()
        self.module_params.update(get_vplex_storageview_parameters())
        self.resource_fail_msg = "Failed to collect resources"
        self.fail_msg = "Could not collect resources in {0}"

        self.module = AnsibleModule(argument_spec=self.module_params,
                                    supports_check_mode=False)

        # Check for external libraries
        lib_status, message = utils.external_library_check()
        if not lib_status:
            LOG.error(message)
            self.module.fail_json(msg=message)

        # Check for Python vplexapi sdk
        if HAS_VPLEXAPI_SDK is False:
            self.module.fail_json(msg="Ansible modules for VPLEX require "
                                  "the vplexapi python library to be "
                                  "installed. Please install the library "
                                  "before using these modules.")

        self.cl_name = self.module.params['cluster_name']

        # Create the configuration instance to communicate
        # with vplexapi
        self.client = utils.config_vplexapi(self.module.params)
        # Validating the user inputs
        if isinstance(self.client, tuple):
            err_code, msg = self.client
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        vplex_setup = utils.get_vplex_setup(self.client)
        LOG.info(vplex_setup)
        # Checking if the cluster is reachable
        (err_code, msg) = utils.verify_cluster_name(self.client, self.cl_name)
        if err_code != 200:
            if "Resource not found" in msg:
                msg = "Could not find resource {0}".format(self.cl_name)
            LOG.error(msg)
            self.module.fail_json(msg=msg)

        # Create an instance to communicate with storageview VPLEX api
        api_obj = utils.VplexapiModules()
        self.cls = api_obj.ClustersApi(api_client=self.client)
        self.storageview = api_obj.ExportsApi(api_client=self.client)
        self.virtualvolume = api_obj.VirtualVolumeApi(api_client=self.client)
        self.maps = api_obj.MapsApi(api_client=self.client)
        self.distvv = api_obj.DistributedStorageApi(api_client=self.client)

        # Module parameters
        self.st_name = self.module.params['storage_view_name']
        self.new_st_name = self.module.params['new_storage_view_name']
        self.ports = self.module.params['ports']
        self.pt_state = self.module.params['port_state']
        self.initiators = self.module.params['initiators']
        self.ini_state = self.module.params['initiator_state']
        self.virvols = self.module.params['virtual_volumes']
        self.virvol_state = self.module.params['virtual_volume_state']
        self.vir_vol = {}

        # result is a dictionary that contains changed status and
        # storage view details
        self.result = {"changed": False, "storageview_details": {}}