Beispiel #1
0
 def _check_clone_status(self, clone_id, vol_uuid, name, new_name):
     """Checks for the job till completed."""
     clone_status = NaElement("clone-list-status")
     cl_id = NaElement("clone-id")
     clone_status.add_child_elem(cl_id)
     cl_id.add_node_with_children("clone-id-info", **{"clone-op-id": clone_id, "volume-uuid": vol_uuid})
     running = True
     clone_ops_info = None
     while running:
         result = self.client.invoke_successfully(clone_status, True)
         status = result.get_child_by_name("status")
         ops_info = status.get_children()
         if ops_info:
             for info in ops_info:
                 if info.get_child_content("clone-state") == "running":
                     time.sleep(1)
                     break
                 else:
                     running = False
                     clone_ops_info = info
                     break
     else:
         if clone_ops_info:
             fmt = {"name": name, "new_name": new_name}
             if clone_ops_info.get_child_content("clone-state") == "completed":
                 LOG.debug(_("Clone operation with src %(name)s" " and dest %(new_name)s completed") % fmt)
             else:
                 LOG.debug(_("Clone operation with src %(name)s" " and dest %(new_name)s failed") % fmt)
                 raise NaApiError(
                     clone_ops_info.get_child_content("error"), clone_ops_info.get_child_content("reason")
                 )
Beispiel #2
0
 def _wait_for_clone_finish(self, clone_op_id, vol_uuid):
     """Waits till a clone operation is complete or errored out."""
     clone_ls_st = NaElement('clone-list-status')
     clone_id = NaElement('clone-id')
     clone_ls_st.add_child_elem(clone_id)
     clone_id.add_node_with_children('clone-id-info',
                                     **{'clone-op-id': clone_op_id,
                                     'volume-uuid': vol_uuid})
     task_running = True
     while task_running:
         result = self._invoke_successfully(clone_ls_st, None)
         status = result.get_child_by_name('status')
         ops_info = status.get_children()
         if ops_info:
             state = ops_info[0].get_child_content('clone-state')
             if state == 'completed':
                 task_running = False
             elif state == 'failed':
                 code = ops_info[0].get_child_content('error')
                 reason = ops_info[0].get_child_content('reason')
                 raise NaApiError(code, reason)
             else:
                 time.sleep(1)
         else:
             raise NaApiError(
                 'UnknownCloneId',
                 'No clone operation for clone id %s found on the filer'
                 % (clone_id))
Beispiel #3
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
Beispiel #4
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
Beispiel #5
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())
Beispiel #6
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
     )
Beispiel #7
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
Beispiel #8
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
Beispiel #9
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)
Beispiel #10
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
Beispiel #11
0
 def _wait_for_clone_finish(self, clone_op_id, vol_uuid):
     """Waits till a clone operation is complete or errored out."""
     clone_ls_st = NaElement('clone-list-status')
     clone_id = NaElement('clone-id')
     clone_ls_st.add_child_elem(clone_id)
     clone_id.add_node_with_children('clone-id-info',
                                     **{'clone-op-id': clone_op_id,
                                     'volume-uuid': vol_uuid})
     task_running = True
     while task_running:
         result = self._invoke_successfully(clone_ls_st, None)
         status = result.get_child_by_name('status')
         ops_info = status.get_children()
         if ops_info:
             state = ops_info[0].get_child_content('clone-state')
             if state == 'completed':
                 task_running = False
             elif state == 'failed':
                 code = ops_info[0].get_child_content('error')
                 reason = ops_info[0].get_child_content('reason')
                 raise NaApiError(code, reason)
             else:
                 time.sleep(1)
         else:
             raise NaApiError(
                 'UnknownCloneId',
                 'No clone operation for clone id %s found on the filer'
                 % (clone_id))
Beispiel #12
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()
Beispiel #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()
Beispiel #14
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()
Beispiel #15
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
Beispiel #16
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))
Beispiel #17
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
Beispiel #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
Beispiel #19
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))
Beispiel #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))
Beispiel #21
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
Beispiel #22
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
Beispiel #23
0
 def _check_clone_status(self, clone_id, vol_uuid, name, new_name):
     """Checks for the job till completed."""
     clone_status = NaElement('clone-list-status')
     cl_id = NaElement('clone-id')
     clone_status.add_child_elem(cl_id)
     cl_id.add_node_with_children(
         'clone-id-info', **{
             'clone-op-id': clone_id,
             'volume-uuid': vol_uuid
         })
     running = True
     clone_ops_info = None
     while running:
         result = self.client.invoke_successfully(clone_status, True)
         status = result.get_child_by_name('status')
         ops_info = status.get_children()
         if ops_info:
             for info in ops_info:
                 if info.get_child_content('clone-state') == 'running':
                     time.sleep(1)
                     break
                 else:
                     running = False
                     clone_ops_info = info
                     break
     else:
         if clone_ops_info:
             fmt = {'name': name, 'new_name': new_name}
             if clone_ops_info.get_child_content('clone-state')\
                     == 'completed':
                 LOG.debug(
                     _("Clone operation with src %(name)s"
                       " and dest %(new_name)s completed") % fmt)
             else:
                 LOG.debug(
                     _("Clone operation with src %(name)s"
                       " and dest %(new_name)s failed") % fmt)
                 raise NaApiError(
                     clone_ops_info.get_child_content('error'),
                     clone_ops_info.get_child_content('reason'))
Beispiel #24
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
Beispiel #25
0
 def _wait_for_clone_finish(self, clone_op_id, vol_uuid):
     """Waits till a clone operation is complete or errored out."""
     clone_ls_st = NaElement("clone-list-status")
     clone_id = NaElement("clone-id")
     clone_ls_st.add_child_elem(clone_id)
     clone_id.add_node_with_children("clone-id-info", **{"clone-op-id": clone_op_id, "volume-uuid": vol_uuid})
     task_running = True
     while task_running:
         result = self._invoke_successfully(clone_ls_st, None)
         status = result.get_child_by_name("status")
         ops_info = status.get_children()
         if ops_info:
             state = ops_info[0].get_child_content("clone-state")
             if state == "completed":
                 task_running = False
             elif state == "failed":
                 code = ops_info[0].get_child_content("error")
                 reason = ops_info[0].get_child_content("reason")
                 raise NaApiError(code, reason)
             else:
                 time.sleep(1)
         else:
             raise NaApiError("UnknownCloneId", "No clone operation for clone id %s found on the filer" % (clone_id))
Beispiel #26
0
 def _check_clone_status(self, clone_id, vol_uuid, name, new_name):
     """Checks for the job till completed."""
     clone_status = NaElement('clone-list-status')
     cl_id = NaElement('clone-id')
     clone_status.add_child_elem(cl_id)
     cl_id.add_node_with_children(
         'clone-id-info',
         **{'clone-op-id': clone_id, 'volume-uuid': vol_uuid})
     running = True
     clone_ops_info = None
     while running:
         result = self.client.invoke_successfully(clone_status, True)
         status = result.get_child_by_name('status')
         ops_info = status.get_children()
         if ops_info:
             for info in ops_info:
                 if info.get_child_content('clone-state') == 'running':
                     time.sleep(1)
                     break
                 else:
                     running = False
                     clone_ops_info = info
                     break
     else:
         if clone_ops_info:
             fmt = {'name': name, 'new_name': new_name}
             if clone_ops_info.get_child_content('clone-state')\
                     == 'completed':
                 LOG.debug(_("Clone operation with src %(name)s"
                             " and dest %(new_name)s completed") % fmt)
             else:
                 LOG.debug(_("Clone operation with src %(name)s"
                             " and dest %(new_name)s failed") % fmt)
                 raise NaApiError(
                     clone_ops_info.get_child_content('error'),
                     clone_ops_info.get_child_content('reason'))