Esempio n. 1
0
 def _create_avl_vol_request(self, vserver, tag=None):
     vol_get_iter = NaElement('volume-get-iter')
     vol_get_iter.add_new_child('max-records', '100')
     if tag:
         vol_get_iter.add_new_child('tag', tag, True)
     query = NaElement('query')
     vol_get_iter.add_child_elem(query)
     vol_attrs = NaElement('volume-attributes')
     query.add_child_elem(vol_attrs)
     if vserver:
         vol_attrs.add_node_with_children(
             'volume-id-attributes',
             **{"owning-vserver-name": vserver})
     vol_attrs.add_node_with_children(
         'volume-state-attributes',
         **{"is-vserver-root": "false", "state": "online"})
     desired_attrs = NaElement('desired-attributes')
     vol_get_iter.add_child_elem(desired_attrs)
     des_vol_attrs = NaElement('volume-attributes')
     desired_attrs.add_child_elem(des_vol_attrs)
     des_vol_attrs.add_node_with_children(
         'volume-id-attributes',
         **{"name": None, "owning-vserver-name": None})
     des_vol_attrs.add_node_with_children(
         'volume-space-attributes',
         **{"size-available": None})
     des_vol_attrs.add_node_with_children('volume-state-attributes',
                                          **{"is-cluster-volume": None,
                                          "is-vserver-root": None,
                                          "state": None})
     return vol_get_iter
Esempio n. 2
0
 def _get_lun_map(self, path):
     """Gets the lun map by lun path."""
     tag = None
     map_list = []
     while True:
         lun_map_iter = NaElement("lun-map-get-iter")
         lun_map_iter.add_new_child("max-records", "100")
         if tag:
             lun_map_iter.add_new_child("tag", tag, True)
         query = NaElement("query")
         lun_map_iter.add_child_elem(query)
         query.add_node_with_children("lun-map-info", **{"path": path})
         result = self.client.invoke_successfully(lun_map_iter, True)
         tag = result.get_child_content("next-tag")
         if result.get_child_content("num-records") and int(result.get_child_content("num-records")) >= 1:
             attr_list = result.get_child_by_name("attributes-list")
             lun_maps = attr_list.get_children()
             for lun_map in lun_maps:
                 lun_m = dict()
                 lun_m["initiator-group"] = lun_map.get_child_content("initiator-group")
                 lun_m["lun-id"] = lun_map.get_child_content("lun-id")
                 lun_m["vserver"] = lun_map.get_child_content("vserver")
                 map_list.append(lun_m)
         if tag is None:
             break
     return map_list
Esempio n. 3
0
 def _get_vol_by_junc_vserver(self, vserver, junction):
     """Gets the volume by junction path and vserver."""
     vol_iter = NaElement('volume-get-iter')
     vol_iter.add_new_child('max-records', '10')
     query = NaElement('query')
     vol_iter.add_child_elem(query)
     vol_attrs = NaElement('volume-attributes')
     query.add_child_elem(vol_attrs)
     vol_attrs.add_node_with_children(
         'volume-id-attributes',
         **{'junction-path': junction,
         'owning-vserver-name': vserver})
     des_attrs = NaElement('desired-attributes')
     des_attrs.add_node_with_children('volume-attributes',
                                      **{'volume-id-attributes': None})
     vol_iter.add_child_elem(des_attrs)
     result = self._invoke_successfully(vol_iter, vserver)
     if result.get_child_content('num-records') and\
             int(result.get_child_content('num-records')) >= 1:
         attr_list = result.get_child_by_name('attributes-list')
         vols = attr_list.get_children()
         vol_id = vols[0].get_child_by_name('volume-id-attributes')
         return vol_id.get_child_content('name')
     raise exception.NotFound(_("""No volume on cluster with vserver
                                %(vserver)s and junction path %(junction)s
                                """) % locals())
Esempio n. 4
0
 def _get_lun_map(self, path):
     """Gets the lun map by lun path."""
     tag = None
     map_list = []
     while True:
         lun_map_iter = NaElement('lun-map-get-iter')
         lun_map_iter.add_new_child('max-records', '100')
         if tag:
             lun_map_iter.add_new_child('tag', tag, True)
         query = NaElement('query')
         lun_map_iter.add_child_elem(query)
         query.add_node_with_children('lun-map-info', **{'path': path})
         result = self.client.invoke_successfully(lun_map_iter, True)
         tag = result.get_child_content('next-tag')
         if result.get_child_content('num-records') and \
                 int(result.get_child_content('num-records')) >= 1:
             attr_list = result.get_child_by_name('attributes-list')
             lun_maps = attr_list.get_children()
             for lun_map in lun_maps:
                 lun_m = dict()
                 lun_m['initiator-group'] = lun_map.get_child_content(
                     'initiator-group')
                 lun_m['lun-id'] = lun_map.get_child_content('lun-id')
                 lun_m['vserver'] = lun_map.get_child_content('vserver')
                 map_list.append(lun_m)
         if tag is None:
             break
     return map_list
Esempio n. 5
0
File: nfs.py Progetto: jcru/cinder
 def _get_vol_by_junc_vserver(self, vserver, junction):
     """Gets the volume by junction path and vserver."""
     vol_iter = NaElement("volume-get-iter")
     vol_iter.add_new_child("max-records", "10")
     query = NaElement("query")
     vol_iter.add_child_elem(query)
     vol_attrs = NaElement("volume-attributes")
     query.add_child_elem(vol_attrs)
     vol_attrs.add_node_with_children(
         "volume-id-attributes", **{"junction-path": junction, "owning-vserver-name": vserver}
     )
     des_attrs = NaElement("desired-attributes")
     des_attrs.add_node_with_children("volume-attributes", **{"volume-id-attributes": None})
     vol_iter.add_child_elem(des_attrs)
     result = self._invoke_successfully(vol_iter, vserver)
     if result.get_child_content("num-records") and int(result.get_child_content("num-records")) >= 1:
         attr_list = result.get_child_by_name("attributes-list")
         vols = attr_list.get_children()
         vol_id = vols[0].get_child_by_name("volume-id-attributes")
         return vol_id.get_child_content("name")
     msg_fmt = {"vserver": vserver, "junction": junction}
     raise exception.NotFound(
         _(
             """No volume on cluster with vserver
                                %(vserver)s and junction path %(junction)s
                                """
         )
         % msg_fmt
     )
Esempio n. 6
0
def create_api_request(api_name,
                       query=None,
                       des_result=None,
                       additional_elems=None,
                       is_iter=False,
                       record_step=50,
                       tag=None):
    """Creates a NetApp api request.

        :param api_name: api name string
        :param query: api query as dict
        :param des_result: desired result as dict
        :param additional_elems: dict other than query and des_result
        :param is_iter: is iterator api
        :param record_step: records at a time for iter api
        :param tag: next tag for iter api
    """
    api_el = NaElement(api_name)
    if query:
        query_el = NaElement('query')
        query_el.translate_struct(query)
        api_el.add_child_elem(query_el)
    if des_result:
        res_el = NaElement('desired-attributes')
        res_el.translate_struct(des_result)
        api_el.add_child_elem(res_el)
    if additional_elems:
        api_el.translate_struct(additional_elems)
    if is_iter:
        api_el.add_new_child('max-records', str(record_step))
    if tag:
        api_el.add_new_child('tag', tag, True)
    return api_el
Esempio n. 7
0
 def _create_avl_vol_request(self, vserver, tag=None):
     vol_get_iter = NaElement('volume-get-iter')
     vol_get_iter.add_new_child('max-records', '100')
     if tag:
         vol_get_iter.add_new_child('tag', tag, True)
     query = NaElement('query')
     vol_get_iter.add_child_elem(query)
     vol_attrs = NaElement('volume-attributes')
     query.add_child_elem(vol_attrs)
     if vserver:
         vol_attrs.add_node_with_children(
             'volume-id-attributes',
             **{"owning-vserver-name": vserver})
     vol_attrs.add_node_with_children(
         'volume-state-attributes',
         **{"is-vserver-root": "false", "state": "online"})
     desired_attrs = NaElement('desired-attributes')
     vol_get_iter.add_child_elem(desired_attrs)
     des_vol_attrs = NaElement('volume-attributes')
     desired_attrs.add_child_elem(des_vol_attrs)
     des_vol_attrs.add_node_with_children(
         'volume-id-attributes',
         **{"name": None, "owning-vserver-name": None})
     des_vol_attrs.add_node_with_children(
         'volume-space-attributes',
         **{"size-available": None})
     des_vol_attrs.add_node_with_children('volume-state-attributes',
                                          **{"is-cluster-volume": None,
                                          "is-vserver-root": None,
                                          "state": None})
     return vol_get_iter
Esempio n. 8
0
def create_api_request(api_name, query=None, des_result=None,
                       additional_elems=None, is_iter=False,
                       record_step=50, tag=None):
        """Creates a NetApp api request.

            :param api_name: api name string
            :param query: api query as dict
            :param des_result: desired result as dict
            :param additional_elems: dict other than query and des_result
            :param is_iter: is iterator api
            :param record_step: records at a time for iter api
            :param tag: next tag for iter api
        """
        api_el = NaElement(api_name)
        if query:
            query_el = NaElement('query')
            query_el.translate_struct(query)
            api_el.add_child_elem(query_el)
        if des_result:
            res_el = NaElement('desired-attributes')
            res_el.translate_struct(des_result)
            api_el.add_child_elem(res_el)
        if additional_elems:
            api_el.translate_struct(additional_elems)
        if is_iter:
            api_el.add_new_child('max-records', str(record_step))
        if tag:
            api_el.add_new_child('tag', tag, True)
        return api_el
Esempio n. 9
0
File: iscsi.py Progetto: jcru/cinder
 def _get_lun_map(self, path):
     """Gets the lun map by lun path."""
     tag = None
     map_list = []
     while True:
         lun_map_iter = NaElement('lun-map-get-iter')
         lun_map_iter.add_new_child('max-records', '100')
         if tag:
             lun_map_iter.add_new_child('tag', tag, True)
         query = NaElement('query')
         lun_map_iter.add_child_elem(query)
         query.add_node_with_children('lun-map-info', **{'path': path})
         result = self.client.invoke_successfully(lun_map_iter, True)
         tag = result.get_child_content('next-tag')
         if result.get_child_content('num-records') and \
                 int(result.get_child_content('num-records')) >= 1:
             attr_list = result.get_child_by_name('attributes-list')
             lun_maps = attr_list.get_children()
             for lun_map in lun_maps:
                 lun_m = dict()
                 lun_m['initiator-group'] = lun_map.get_child_content(
                     'initiator-group')
                 lun_m['lun-id'] = lun_map.get_child_content('lun-id')
                 lun_m['vserver'] = lun_map.get_child_content('vserver')
                 map_list.append(lun_m)
         if tag is None:
             break
     return map_list
Esempio n. 10
0
 def _get_vol_by_junc_vserver(self, vserver, junction):
     """Gets the volume by junction path and vserver."""
     vol_iter = NaElement('volume-get-iter')
     vol_iter.add_new_child('max-records', '10')
     query = NaElement('query')
     vol_iter.add_child_elem(query)
     vol_attrs = NaElement('volume-attributes')
     query.add_child_elem(vol_attrs)
     vol_attrs.add_node_with_children(
         'volume-id-attributes',
         **{'junction-path': junction,
         'owning-vserver-name': vserver})
     des_attrs = NaElement('desired-attributes')
     des_attrs.add_node_with_children('volume-attributes',
                                      **{'volume-id-attributes': None})
     vol_iter.add_child_elem(des_attrs)
     result = self._invoke_successfully(vol_iter, vserver)
     if result.get_child_content('num-records') and\
             int(result.get_child_content('num-records')) >= 1:
         attr_list = result.get_child_by_name('attributes-list')
         vols = attr_list.get_children()
         vol_id = vols[0].get_child_by_name('volume-id-attributes')
         return vol_id.get_child_content('name')
     msg_fmt = {'vserver': vserver, 'junction': junction}
     raise exception.NotFound(_("""No volume on cluster with vserver
                                %(vserver)s and junction path %(junction)s
                                """) % msg_fmt)
Esempio n. 11
0
 def _get_vol_luns(self, vol_name):
     """Gets the luns for a volume."""
     api = NaElement("lun-list-info")
     if vol_name:
         api.add_new_child("volume-name", vol_name)
     result = self.client.invoke_successfully(api, True)
     luns = result.get_child_by_name("luns")
     return luns.get_children()
Esempio n. 12
0
 def _get_vol_luns(self, vol_name):
     """Gets the luns for a volume."""
     api = NaElement('lun-list-info')
     if vol_name:
         api.add_new_child('volume-name', vol_name)
     result = self.client.invoke_successfully(api, True)
     luns = result.get_child_by_name('luns')
     return luns.get_children()
Esempio n. 13
0
 def _get_lun_by_args(self, **args):
     """Retrives lun with specified args."""
     lun_iter = NaElement('lun-get-iter')
     lun_iter.add_new_child('max-records', '100')
     query = NaElement('query')
     lun_iter.add_child_elem(query)
     query.add_node_with_children('lun-info', **args)
     luns = self.client.invoke_successfully(lun_iter)
     attr_list = luns.get_child_by_name('attributes-list')
     return attr_list.get_children()
Esempio n. 14
0
File: iscsi.py Progetto: jcru/cinder
 def _get_lun_by_args(self, **args):
     """Retrives lun with specified args."""
     lun_iter = NaElement('lun-get-iter')
     lun_iter.add_new_child('max-records', '100')
     query = NaElement('query')
     lun_iter.add_child_elem(query)
     query.add_node_with_children('lun-info', **args)
     luns = self.client.invoke_successfully(lun_iter)
     attr_list = luns.get_child_by_name('attributes-list')
     return attr_list.get_children()
Esempio n. 15
0
 def _get_lun_by_args(self, **args):
     """Retrives lun with specified args."""
     lun_iter = NaElement("lun-get-iter")
     lun_iter.add_new_child("max-records", "100")
     query = NaElement("query")
     lun_iter.add_child_elem(query)
     query.add_node_with_children("lun-info", **args)
     luns = self.client.invoke_successfully(lun_iter)
     attr_list = luns.get_child_by_name("attributes-list")
     return attr_list.get_children()
Esempio n. 16
0
 def _create_vs_get():
     """Create vs_get api request."""
     vs_get = NaElement("vserver-get-iter")
     vs_get.add_new_child("max-records", "1")
     query = NaElement("query")
     query.add_node_with_children("vserver-info", **{"vserver-type": "node"})
     vs_get.add_child_elem(query)
     desired = NaElement("desired-attributes")
     desired.add_node_with_children("vserver-info", **{"vserver-name": "", "vserver-type": ""})
     vs_get.add_child_elem(desired)
     return vs_get
Esempio n. 17
0
File: nfs.py Progetto: jcru/cinder
 def _get_if_info_by_ip(self, ip):
     """Gets the network interface info by ip."""
     net_if_iter = NaElement("net-interface-get-iter")
     net_if_iter.add_new_child("max-records", "10")
     query = NaElement("query")
     net_if_iter.add_child_elem(query)
     query.add_node_with_children("net-interface-info", **{"address": ip})
     result = self._invoke_successfully(net_if_iter)
     if result.get_child_content("num-records") and int(result.get_child_content("num-records")) >= 1:
         attr_list = result.get_child_by_name("attributes-list")
         return attr_list.get_children()
     raise exception.NotFound(_("No interface found on cluster for ip %s") % (ip))
Esempio n. 18
0
 def _create_vs_get():
     """Create vs_get api request."""
     vs_get = NaElement('vserver-get-iter')
     vs_get.add_new_child('max-records', '1')
     query = NaElement('query')
     query.add_node_with_children('vserver-info',
                                  **{'vserver-type': 'node'})
     vs_get.add_child_elem(query)
     desired = NaElement('desired-attributes')
     desired.add_node_with_children(
         'vserver-info', **{'vserver-name': '', 'vserver-type': ''})
     vs_get.add_child_elem(desired)
     return vs_get
Esempio n. 19
0
 def _create_vs_get():
     """Create vs_get api request."""
     vs_get = NaElement('vserver-get-iter')
     vs_get.add_new_child('max-records', '1')
     query = NaElement('query')
     query.add_node_with_children('vserver-info',
                                  **{'vserver-type': 'node'})
     vs_get.add_child_elem(query)
     desired = NaElement('desired-attributes')
     desired.add_node_with_children(
         'vserver-info', **{'vserver-name': '', 'vserver-type': ''})
     vs_get.add_child_elem(desired)
     return vs_get
Esempio n. 20
0
 def _get_if_info_by_ip(self, ip):
     """Gets the network interface info by ip."""
     net_if_iter = NaElement('net-interface-get-iter')
     net_if_iter.add_new_child('max-records', '10')
     query = NaElement('query')
     net_if_iter.add_child_elem(query)
     query.add_node_with_children('net-interface-info', **{'address': ip})
     result = self._invoke_successfully(net_if_iter)
     if result.get_child_content('num-records') and\
             int(result.get_child_content('num-records')) >= 1:
         attr_list = result.get_child_by_name('attributes-list')
         return attr_list.get_children()
     raise exception.NotFound(
         _('No interface found on cluster for ip %s') % (ip))
Esempio n. 21
0
 def _get_if_info_by_ip(self, ip):
     """Gets the network interface info by ip."""
     net_if_iter = NaElement('net-interface-get-iter')
     net_if_iter.add_new_child('max-records', '10')
     query = NaElement('query')
     net_if_iter.add_child_elem(query)
     query.add_node_with_children('net-interface-info', **{'address': ip})
     result = self._invoke_successfully(net_if_iter)
     if result.get_child_content('num-records') and\
             int(result.get_child_content('num-records')) >= 1:
         attr_list = result.get_child_by_name('attributes-list')
         return attr_list.get_children()
     raise exception.NotFound(
         _('No interface found on cluster for ip %s')
         % (ip))
Esempio n. 22
0
File: iscsi.py Progetto: jcru/cinder
    def _get_lun_list(self):
        """Gets the list of luns on filer.

        Gets the luns from cluster with vserver.
        """

        tag = None
        while True:
            api = NaElement('lun-get-iter')
            api.add_new_child('max-records', '100')
            if tag:
                api.add_new_child('tag', tag, True)
            lun_info = NaElement('lun-info')
            lun_info.add_new_child('vserver', self.vserver)
            query = NaElement('query')
            query.add_child_elem(lun_info)
            api.add_child_elem(query)
            result = self.client.invoke_successfully(api)
            if result.get_child_by_name('num-records') and\
                    int(result.get_child_content('num-records')) >= 1:
                attr_list = result.get_child_by_name('attributes-list')
                self._extract_and_populate_luns(attr_list.get_children())
            tag = result.get_child_content('next-tag')
            if tag is None:
                break
Esempio n. 23
0
    def _get_lun_list(self):
        """Gets the list of luns on filer.

        Gets the luns from cluster with vserver.
        """
        tag = None
        while True:
            api = NaElement("lun-get-iter")
            api.add_new_child("max-records", "100")
            if tag:
                api.add_new_child("tag", tag, True)
            lun_info = NaElement("lun-info")
            lun_info.add_new_child("vserver", self.vserver)
            query = NaElement("query")
            query.add_child_elem(lun_info)
            api.add_child_elem(query)
            result = self.client.invoke_successfully(api)
            if result.get_child_by_name("num-records") and int(result.get_child_content("num-records")) >= 1:
                attr_list = result.get_child_by_name("attributes-list")
                self._extract_and_populate_luns(attr_list.get_children())
            tag = result.get_child_content("next-tag")
            if tag is None:
                break
Esempio n. 24
0
    def _get_lun_list(self):
        """Gets the list of luns on filer.

        Gets the luns from cluster with vserver.
        """
        tag = None
        while True:
            api = NaElement('lun-get-iter')
            api.add_new_child('max-records', '100')
            if tag:
                api.add_new_child('tag', tag, True)
            lun_info = NaElement('lun-info')
            lun_info.add_new_child('vserver', self.vserver)
            query = NaElement('query')
            query.add_child_elem(lun_info)
            api.add_child_elem(query)
            result = self.client.invoke_successfully(api)
            if result.get_child_by_name('num-records') and\
                    int(result.get_child_content('num-records')) >= 1:
                attr_list = result.get_child_by_name('attributes-list')
                self._extract_and_populate_luns(attr_list.get_children())
            tag = result.get_child_content('next-tag')
            if tag is None:
                break
Esempio n. 25
0
 def _create_ems(stats, netapp_backend, server_type):
     """Create ems api request."""
     ems_log = NaElement('ems-autosupport-log')
     host = socket.getfqdn() or 'Cinder_node'
     dest = "cluster node" if server_type == "cluster"\
            else "7 mode controller"
     ems_log.add_new_child('computer-name', host)
     ems_log.add_new_child('event-id', '0')
     ems_log.add_new_child('event-source',
                           'Cinder driver %s' % netapp_backend)
     ems_log.add_new_child('app-version', stats.get('driver_version',
                           'Undefined'))
     ems_log.add_new_child('category', 'provisioning')
     ems_log.add_new_child('event-description',
                           'OpenStack volume created on %s' % dest)
     ems_log.add_new_child('log-level', '6')
     ems_log.add_new_child('auto-support', 'true')
     return ems_log
Esempio n. 26
0
 def _create_ems(stats, netapp_backend, server_type):
     """Create ems api request."""
     ems_log = NaElement('ems-autosupport-log')
     host = socket.getfqdn() or 'Cinder_node'
     dest = "cluster node" if server_type == "cluster"\
            else "7 mode controller"
     ems_log.add_new_child('computer-name', host)
     ems_log.add_new_child('event-id', '0')
     ems_log.add_new_child('event-source',
                           'Cinder driver %s' % netapp_backend)
     ems_log.add_new_child('app-version',
                           stats.get('driver_version', 'Undefined'))
     ems_log.add_new_child('category', 'provisioning')
     ems_log.add_new_child('event-description',
                           'OpenStack volume created on %s' % dest)
     ems_log.add_new_child('log-level', '6')
     ems_log.add_new_child('auto-support', 'true')
     return ems_log
Esempio n. 27
0
 def _get_igroup_by_initiator(self, initiator):
     """Get igroups by initiator."""
     tag = None
     igroup_list = []
     while True:
         igroup_iter = NaElement('igroup-get-iter')
         igroup_iter.add_new_child('max-records', '100')
         if tag:
             igroup_iter.add_new_child('tag', tag, True)
         query = NaElement('query')
         igroup_iter.add_child_elem(query)
         igroup_info = NaElement('initiator-group-info')
         query.add_child_elem(igroup_info)
         igroup_info.add_new_child('vserver', self.vserver)
         initiators = NaElement('initiators')
         igroup_info.add_child_elem(initiators)
         initiators.add_node_with_children('initiator-info',
                                           **{'initiator-name': initiator})
         des_attrs = NaElement('desired-attributes')
         des_ig_info = NaElement('initiator-group-info')
         des_attrs.add_child_elem(des_ig_info)
         des_ig_info.add_node_with_children('initiators',
                                            **{'initiator-info': None})
         des_ig_info.add_new_child('vserver', None)
         des_ig_info.add_new_child('initiator-group-name', None)
         des_ig_info.add_new_child('initiator-group-type', None)
         des_ig_info.add_new_child('initiator-group-os-type', None)
         igroup_iter.add_child_elem(des_attrs)
         result = self.client.invoke_successfully(igroup_iter, False)
         tag = result.get_child_content('next-tag')
         if result.get_child_content('num-records') and\
                 int(result.get_child_content('num-records')) > 0:
             attr_list = result.get_child_by_name('attributes-list')
             igroups = attr_list.get_children()
             for igroup in igroups:
                 ig = dict()
                 ig['initiator-group-os-type'] = igroup.get_child_content(
                     'initiator-group-os-type')
                 ig['initiator-group-type'] = igroup.get_child_content(
                     'initiator-group-type')
                 ig['initiator-group-name'] = igroup.get_child_content(
                     'initiator-group-name')
                 igroup_list.append(ig)
         if tag is None:
             break
     return igroup_list
Esempio n. 28
0
File: iscsi.py Progetto: jcru/cinder
 def _get_igroup_by_initiator(self, initiator):
     """Get igroups by initiator."""
     tag = None
     igroup_list = []
     while True:
         igroup_iter = NaElement('igroup-get-iter')
         igroup_iter.add_new_child('max-records', '100')
         if tag:
             igroup_iter.add_new_child('tag', tag, True)
         query = NaElement('query')
         igroup_iter.add_child_elem(query)
         igroup_info = NaElement('initiator-group-info')
         query.add_child_elem(igroup_info)
         igroup_info.add_new_child('vserver', self.vserver)
         initiators = NaElement('initiators')
         igroup_info.add_child_elem(initiators)
         initiators.add_node_with_children('initiator-info',
                                           **{'initiator-name': initiator})
         des_attrs = NaElement('desired-attributes')
         des_ig_info = NaElement('initiator-group-info')
         des_attrs.add_child_elem(des_ig_info)
         des_ig_info.add_node_with_children('initiators',
                                            **{'initiator-info': None})
         des_ig_info.add_new_child('vserver', None)
         des_ig_info.add_new_child('initiator-group-name', None)
         des_ig_info.add_new_child('initiator-group-type', None)
         des_ig_info.add_new_child('initiator-group-os-type', None)
         igroup_iter.add_child_elem(des_attrs)
         result = self.client.invoke_successfully(igroup_iter, False)
         tag = result.get_child_content('next-tag')
         if result.get_child_content('num-records') and\
                 int(result.get_child_content('num-records')) > 0:
             attr_list = result.get_child_by_name('attributes-list')
             igroups = attr_list.get_children()
             for igroup in igroups:
                 ig = dict()
                 ig['initiator-group-os-type'] = igroup.get_child_content(
                     'initiator-group-os-type')
                 ig['initiator-group-type'] = igroup.get_child_content(
                     'initiator-group-type')
                 ig['initiator-group-name'] = igroup.get_child_content(
                     'initiator-group-name')
                 igroup_list.append(ig)
         if tag is None:
             break
     return igroup_list
Esempio n. 29
0
 def _create_ems(netapp_backend, app_version, server_type):
     """Create ems api request."""
     ems_log = NaElement('ems-autosupport-log')
     host = socket.getfqdn() or 'Cinder_node'
     if server_type == "cluster":
         dest = "cluster node"
     else:
         dest = "7 mode controller"
     ems_log.add_new_child('computer-name', host)
     ems_log.add_new_child('event-id', '0')
     ems_log.add_new_child('event-source',
                           'Cinder driver %s' % netapp_backend)
     ems_log.add_new_child('app-version', app_version)
     ems_log.add_new_child('category', 'provisioning')
     ems_log.add_new_child('event-description',
                           'OpenStack Cinder connected to %s' % dest)
     ems_log.add_new_child('log-level', '6')
     ems_log.add_new_child('auto-support', 'false')
     return ems_log
Esempio n. 30
0
 def _create_ems(netapp_backend, app_version, server_type):
     """Create ems api request."""
     ems_log = NaElement('ems-autosupport-log')
     host = socket.getfqdn() or 'Cinder_node'
     if server_type == "cluster":
         dest = "cluster node"
     else:
         dest = "7 mode controller"
     ems_log.add_new_child('computer-name', host)
     ems_log.add_new_child('event-id', '0')
     ems_log.add_new_child('event-source',
                           'Cinder driver %s' % netapp_backend)
     ems_log.add_new_child('app-version', app_version)
     ems_log.add_new_child('category', 'provisioning')
     ems_log.add_new_child('event-description',
                           'OpenStack Cinder connected to %s' % dest)
     ems_log.add_new_child('log-level', '6')
     ems_log.add_new_child('auto-support', 'false')
     return ems_log
Esempio n. 31
0
 def _create_ems(stats, netapp_backend, server_type):
     """Create ems api request."""
     ems_log = NaElement("ems-autosupport-log")
     host = socket.getfqdn() or "Cinder_node"
     dest = "cluster node" if server_type == "cluster" else "7 mode controller"
     ems_log.add_new_child("computer-name", host)
     ems_log.add_new_child("event-id", "0")
     ems_log.add_new_child("event-source", "Cinder driver %s" % netapp_backend)
     ems_log.add_new_child("app-version", stats.get("driver_version", "Undefined"))
     ems_log.add_new_child("category", "provisioning")
     ems_log.add_new_child("event-description", "OpenStack volume created on %s" % dest)
     ems_log.add_new_child("log-level", "6")
     ems_log.add_new_child("auto-support", "true")
     return ems_log
Esempio n. 32
0
 def _get_igroup_by_initiator(self, initiator):
     """Get igroups by initiator."""
     tag = None
     igroup_list = []
     while True:
         igroup_iter = NaElement("igroup-get-iter")
         igroup_iter.add_new_child("max-records", "100")
         if tag:
             igroup_iter.add_new_child("tag", tag, True)
         query = NaElement("query")
         igroup_iter.add_child_elem(query)
         igroup_info = NaElement("initiator-group-info")
         query.add_child_elem(igroup_info)
         igroup_info.add_new_child("vserver", self.vserver)
         initiators = NaElement("initiators")
         igroup_info.add_child_elem(initiators)
         initiators.add_node_with_children("initiator-info", **{"initiator-name": initiator})
         des_attrs = NaElement("desired-attributes")
         des_ig_info = NaElement("initiator-group-info")
         des_attrs.add_child_elem(des_ig_info)
         des_ig_info.add_node_with_children("initiators", **{"initiator-info": None})
         des_ig_info.add_new_child("vserver", None)
         des_ig_info.add_new_child("initiator-group-name", None)
         des_ig_info.add_new_child("initiator-group-type", None)
         des_ig_info.add_new_child("initiator-group-os-type", None)
         igroup_iter.add_child_elem(des_attrs)
         result = self.client.invoke_successfully(igroup_iter, False)
         tag = result.get_child_content("next-tag")
         if result.get_child_content("num-records") and int(result.get_child_content("num-records")) > 0:
             attr_list = result.get_child_by_name("attributes-list")
             igroups = attr_list.get_children()
             for igroup in igroups:
                 ig = dict()
                 ig["initiator-group-os-type"] = igroup.get_child_content("initiator-group-os-type")
                 ig["initiator-group-type"] = igroup.get_child_content("initiator-group-type")
                 ig["initiator-group-name"] = igroup.get_child_content("initiator-group-name")
                 igroup_list.append(ig)
         if tag is None:
             break
     return igroup_list