def add_initiator(self, uid, force_create=True, **kwargs): initiators = UnityHostInitiatorList.get(cli=self._cli, initiator_id=uid) if not initiators: # Set the ISCSI or FC type if common.is_fc_uid(uid): uid_type = HostInitiatorTypeEnum.FC elif common.is_iscsi_uid(uid): uid_type = HostInitiatorTypeEnum.ISCSI else: uid_type = HostInitiatorTypeEnum.UNKNOWN if force_create: initiator = UnityHostInitiator.create(self._cli, uid, self, uid_type, **kwargs) else: raise ex.UnityHostInitiatorNotFoundError( 'name {} not found under host {}.'.format(uid, self.name)) else: initiator = initiators.first_item log.debug('initiator {} is existed in unity system.'.format(uid)) initiator.modify(self) return initiator.update()
def test_fc_format_invalid(self): assert_that(common.is_fc_uid('20:00:00:90:DA:73:5C:D1'), equal_to(False))
def test_fc_format(self): assert_that( common.is_fc_uid( '20:00:00:90:DA:73:5C:D1:10:00:00:90:FB:54:4C:D1'), equal_to(True))