Example #1
0
    def delete_snapshot_schedule(self,
                                 container,
                                 lun=None,
                                 lungroup=None,
                                 schedule_name=None,
                                 delete_snapshots=None):
        """
        Delete a snapshot schedule.

        Arguments:
            container        -- string
            lun              -- string (optional)
            lungroup         -- string (optional)
            schedule_name    -- string (optional)
            delete_snapshots -- bool (optional)

        Returns:
            Action result as a dict.

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        if lun is not None:
            nodes.append(XGNode('lun', 'string', lun))
        if lungroup is not None:
            nodes.append(XGNode('lungroup', 'string', lungroup))
        if schedule_name is not None:
            nodes.append(XGNode('schedule_name', 'string', schedule_name))
        if delete_snapshots is not None:
            nodes.append(XGNode('delete_snapshots', 'bool', delete_snapshots))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/schedule/snapshot/delete', nodes)
Example #2
0
    def _igroup_create(self, igroup, delete):
        """
        Internal work function for:
            create_igroup
            delete_igroup

        """

        nodes = []
        nodes.append(XGNode('igroup', 'string', igroup))
        nodes.append(XGNode('delete', 'bool', delete))
        return self._basic.perform_action('/vshare/actions' + '/igroup/create',
                                          nodes)
Example #3
0
    def _iscsi_target_create(self, target, create):
        """
        Internal work function for:
            create_iscsi_target
            delete_iscsi_target

        """
        nodes = []
        nodes.append(XGNode('target', 'string', target))
        nodes.append(XGNode('create', 'bool', create))

        return self._basic.perform_action(
            '/vshare/actions' + '/iscsi/target/create', nodes)
Example #4
0
    def _iscsi_target_bind(self, target, ip, add):
        """
        Internal work function for:
            bind_ip_to_target
            unbind_ip_from_target

        """
        nodes = []
        nodes.append(XGNode('target', 'string', target))
        nodes.extend(XGNode.as_node_list('ip/{0}', 'string', ip))
        nodes.append(XGNode('add', 'bool', add))

        return self._basic.perform_action(
            '/vshare/actions' + '/iscsi/target/bind', nodes)
Example #5
0
    def _igroup_modify(self, igroup, initiators, delete):
        """
        Internal work function for:
            add_initiators
            delete_initiators

        """
        nodes = []
        nodes.append(XGNode('igroup', 'string', igroup))
        nodes.extend(
            XGNode.as_node_list('initiators/{0}', 'string', initiators))
        nodes.append(XGNode('delete', 'bool', delete))

        return self._basic.perform_action('/vshare/actions' + '/igroup/modify',
                                          nodes)
Example #6
0
    def format_array(self, percentage, volumeid=None):
        """
        Format the array.

        Arguments:
            percentage -- uint8
            volumeid   -- uint32

        """

        nodes = []
        nodes.append(XGNode('percentage', 'uint8', percentage))
        if volumeid:
            nodes.append(XGNode('volumeid', 'uint32', volumeid))

        return self._basic.perform_action('/array/actions' + '/format', nodes)
Example #7
0
    def _get_nodes(self,
                   node_names,
                   nostate=False,
                   noconfig=False,
                   flat=False,
                   values_only=False,
                   strip=None):

        query_flags = []
        if nostate:
            query_flags.append("no-state")
        if noconfig:
            query_flags.append("no-config")

        # Convert basestring to list, so we can accept either now
        if isinstance(node_names, basestring):
            node_names = [node_names]

        nodes = []
        for n in node_names:
            nodes.append(XGNode(n, flags=query_flags))

        req = XGQuery(nodes, flat, values_only)
        resp = self.send_request(req, strip)

        # TODO(gfreeman): If we have send_request return empty nodes
        #       dict rather than None for error we can eliminate this
        #       conditional.
        return resp.nodes
Example #8
0
    def rename_igroup(self, old_igroup, new_igroup):
        """
        Renames an igroup.

        Arguments:
            old_igroup -- string
            new_igroup -- string

        Returns:
            Action result as a dict.

        """
        nodes = []
        nodes.append(XGNode('old_igroup', 'string', old_igroup))
        nodes.append(XGNode('new_igroup', 'string', new_igroup))

        return self._basic.perform_action('/vshare/actions' + '/igroup/rename',
                                          nodes)
Example #9
0
    def _snapgroup_export(self, container, lungroup, name, initiators, ports,
                          unexport):
        """
        Internal work function for:
            export_lun_group_snapshot
            unexport_lun_group_snapshot

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('lungroup', 'string', lungroup))
        nodes.append(XGNode('name', 'string', name))
        nodes.extend(
            XGNode.as_node_list('initiators/{0}', 'string', initiators))
        nodes.extend(XGNode.as_node_list('ports/{0}', 'string', ports))
        nodes.append(XGNode('unexport', 'bool', unexport))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/snapgroup/export', nodes)
Example #10
0
    def set_lun_snapshot(self,
                         container,
                         lun,
                         name,
                         new_name=None,
                         description=None,
                         readwrite=None,
                         snap_protect=None,
                         port_A=None,
                         port_B=None):
        """
        Update a LUN snapshot.

        Arguments:
            container    -- string
            lun          -- string
            name         -- string
            new_name     -- string (optional)
            description  -- string (optional)
            readwrite    -- bool (optional)
            snap_protect -- bool (optional)
            port_A       -- bool (optional)
            port_B       -- bool (optional)

        Returns:
            Action result as a dict.

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('lun', 'string', lun))
        nodes.append(XGNode('name', 'string', name))
        if new_name is not None:
            nodes.append(XGNode('new_name', 'string', new_name))
        if description is not None:
            nodes.append(XGNode('description', 'string', description))
        if readwrite is not None:
            nodes.append(XGNode('readwrite', 'bool', readwrite))
        if snap_protect is not None:
            nodes.append(XGNode('snap_protect', 'bool', snap_protect))
        if port_A is not None:
            nodes.append(XGNode('port_A', 'bool', port_A))
        if port_B is not None:
            nodes.append(XGNode('port_B', 'bool', port_B))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/snapshot/set', nodes)
Example #11
0
    def rollback_lun_group(self, container, lungroup, name):
        """
        Rollback a LUN group to the specified snapshot.

        Arguments:
            container -- string
            lungroup -- string
            name      -- string

        Returns:
            Action result as a dict.

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('lungroup', 'string', lungroup))
        nodes.append(XGNode('name', 'string', name))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/snapgroup/rollback', nodes)
Example #12
0
    def _iscsi_global(self, enable):
        """
        Internal work function for:
            enable_iscsi_globally
            disable_iscsi_globally

        """
        nodes = []
        nodes.append(XGNode('enable', 'bool', enable))

        return self._basic.perform_action(
            '/vshare/actions' + '/iscsi/enable_global', nodes)
Example #13
0
    def _snapshot_export(self, container, lun, names, initiators, ports,
                         lun_id, unexport, force):
        """
        Internal work function for:
            export_lun_snapshot
            unexport_lun_snapshot

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('lun', 'string', lun))
        nodes.extend(XGNode.as_node_list('names/{0}', 'string', names))
        nodes.extend(
            XGNode.as_node_list('initiators/{0}', 'string', initiators))
        nodes.extend(XGNode.as_node_list('ports/{0}', 'string', ports))
        nodes.append(XGNode('lun_id', 'string', lun_id))
        nodes.append(XGNode('unexport', 'bool', unexport))
        if force is not None:
            nodes.append(XGNode('force', 'bool', force))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/snapshot/export', nodes)
Example #14
0
    def _snapshot_create(self, container, lun, name, action, description,
                         readwrite, snap_protect):
        """
        Internal work function for:
            create_lun_snapshot
            delete_lun_snapshot

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('lun', 'string', lun))
        nodes.append(XGNode('name', 'string', name))
        nodes.append(XGNode('action', 'string', action))
        if description is not None:
            nodes.append(XGNode('description', 'string', description))
        if readwrite is not None:
            nodes.append(XGNode('readwrite', 'bool', readwrite))
        if snap_protect is not None:
            nodes.append(XGNode('snap_protect', 'bool', snap_protect))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/snapshot/create', nodes)
Example #15
0
    def modify_snapshot_schedule(self,
                                 container,
                                 schedule_name,
                                 type,
                                 is_lungroup_schedule,
                                 lun_or_group_name,
                                 new_schedule_name=None,
                                 description=None,
                                 date=None,
                                 time=None,
                                 start_date=None,
                                 start_time=None,
                                 end_date=None,
                                 end_time=None,
                                 periodicity=None,
                                 days_of_week=None,
                                 monthly_interval=None,
                                 day_of_month=None,
                                 readwrite=None,
                                 protect=None,
                                 max_keep=None,
                                 enable=None):
        """
        Modify a snapshot schedule.

        Arguments:
            container            -- string
            schedule_name        -- string
            type                 -- string
            is_lungroup_schedule -- bool
            lun_or_group_name    -- string
            new_schedule_name    -- string (optional)
            description          -- string (optional)
            date                 -- date (string or datetime; optional)
            time                 -- time_sec (string or datetime; optional)
            start_date           -- date (string or datetime; optional)
            start_time           -- time_sec (string or datetime; optional)
            end_date             -- date (string or datetime; optional)
            end_time             -- time_sec (string or datetime; optional)
            periodicity          -- duration_sec (string; optional)
            days_of_week         -- string (optional)
            monthly_interval     -- uint32 (optional)
            day_of_month         -- int32 (optional)
            readwrite            -- bool (optional)
            protect              -- bool (optional)
            max_keep             -- int32 (optional)
            enable               -- bool (optional)

        Returns:
            Action result as a dict.

        """
        nodes = []
        nodes.append(XGNode('container', 'string', container))
        nodes.append(XGNode('schedule_name', 'string', schedule_name))
        nodes.append(XGNode('type', 'string', type))
        nodes.append(
            XGNode('is_lungroup_schedule', 'bool', is_lungroup_schedule))
        nodes.append(XGNode('lun_or_group_name', 'string', lun_or_group_name))
        if new_schedule_name is not None:
            nodes.append(
                XGNode('new_schedule_name', 'string', new_schedule_name))
        if description is not None:
            nodes.append(XGNode('description', 'string', description))
        if date is not None:
            nodes.append(XGNode('date', 'date', date))
        if time is not None:
            nodes.append(XGNode('time', 'time_sec', time))
        if start_date is not None:
            nodes.append(XGNode('start_date', 'date', start_date))
        if start_time is not None:
            nodes.append(XGNode('start_time', 'time_sec', start_time))
        if end_date is not None:
            nodes.append(XGNode('end_date', 'date', end_date))
        if end_time is not None:
            nodes.append(XGNode('end_time', 'time_sec', end_time))
        if periodicity is not None:
            nodes.append(XGNode('periodicity', 'duration_sec', periodicity))
        if days_of_week is not None:
            nodes.append(XGNode('days_of_week', 'string', days_of_week))
        if monthly_interval is not None:
            nodes.append(XGNode('monthly_interval', 'uint32',
                                monthly_interval))
        if day_of_month is not None:
            nodes.append(XGNode('day_of_month', 'int32', day_of_month))
        if readwrite is not None:
            nodes.append(XGNode('readwrite', 'bool', readwrite))
        if protect is not None:
            nodes.append(XGNode('protect', 'bool', protect))
        if max_keep is not None:
            nodes.append(XGNode('max_keep', 'int32', max_keep))
        if enable is not None:
            nodes.append(XGNode('enable', 'bool', enable))

        return self._basic.perform_action(
            '/vshare/actions/vdm' + '/schedule/snapshot/modify', nodes)