def create_target_to_storage(self, port, connector, hba_ids): """Create a host group on the specified port.""" wwpns = self.get_hba_ids_from_connector(connector) target_name = utils.TARGET_PREFIX + min(wwpns) try: result = self.run_raidcom('add', 'host_grp', '-port', port, '-host_grp_name', target_name) except exception.VSPError: result = self.run_raidcom('get', 'host_grp', '-port', port) hostgroup_pt = re.compile( r"^CL\w-\w+ +(?P<gid>\d+) +%s +\d+ " % target_name, re.M) gid = hostgroup_pt.findall(result[1]) if gid: return target_name, gid[0] else: raise return target_name, horcm.find_value(result[1], 'gid')
def create_target_to_storage(self, port, connector, hba_ids): """Create a host group on the specified port.""" wwpns = self.get_hba_ids_from_connector(connector) target_name = utils.TARGET_PREFIX + min(wwpns) try: result = self.run_raidcom( 'add', 'host_grp', '-port', port, '-host_grp_name', target_name) except exception.VSPError: result = self.run_raidcom('get', 'host_grp', '-port', port) hostgroup_pt = re.compile( r"^CL\w-\w+ +(?P<gid>\d+) +%s +\d+ " % target_name, re.M) gid = hostgroup_pt.findall(result[1]) if gid: return target_name, gid[0] else: raise return target_name, horcm.find_value(result[1], 'gid')
def create_target_to_storage(self, port, connector, hba_ids): """Create an iSCSI target on the specified port.""" target_name = utils.TARGET_PREFIX + connector['ip'] args = [ 'add', 'host_grp', '-port', port, '-host_grp_name', target_name] if hba_ids: args.extend(['-iscsi_name', hba_ids + utils.TARGET_IQN_SUFFIX]) try: result = self.run_raidcom(*args) except exception.VSPError: result = self.run_raidcom('get', 'host_grp', '-port', port) hostgroup_pt = re.compile( r"^CL\w-\w+ +(?P<gid>\d+) +%s +\S+ " % target_name.replace('.', r'\.'), re.M) gid = hostgroup_pt.findall(result[1]) if gid: return target_name, gid[0] else: raise return target_name, horcm.find_value(result[1], 'gid')