示例#1
0
    def update_hosts(self, host_names):
        """Primarily for puppet-unity use.

        Update the hosts for the lun if needed.

        :param host_names: specify the new hosts which access the LUN.
        """

        if self.host_access:
            curr_hosts = [access.host.name for access in self.host_access]
        else:
            curr_hosts = []

        if set(curr_hosts) == set(host_names):
            log.info('Hosts for updating is equal to current hosts, '
                     'skip modification.')
            return None

        new_hosts = [
            UnityHostList.get(cli=self._cli, name=host_name)[0]
            for host_name in host_names
        ]
        new_access = [{
            'host': item,
            'accessMask': HostLUNAccessEnum.PRODUCTION
        } for item in new_hosts]
        resp = self.modify(host_access=new_access)
        resp.raise_if_err()
        return resp
示例#2
0
文件: system.py 项目: crook/storops
    def create_host(self, name, host_type=None, desc=None, os=None):
        host = UnityHostList.get(self._cli, name=name).first_item
        if host and host.existed:
            raise ex.UnityHostNameInUseError()
        else:
            host = UnityHost.create(self._cli, name, host_type=host_type,
                                    desc=desc, os=os)

        return host
示例#3
0
 def get_host(self, _id=None, name=None, address=None, **filters):
     ret = UnityHostList.get(self._cli, name='not found')
     if address:
         host_ip_ports = UnityHostIpPortList.get(self._cli, address=address)
         if host_ip_ports:
             ret = host_ip_ports[0].host
     else:
         ret = self._get_unity_rsc(UnityHostList, _id=_id, name=name,
                                   **filters)
     return ret
示例#4
0
    def create_host(self, name, host_type=None, desc=None, os=None,
                    tenant=None):
        host = UnityHostList.get(self._cli, name=name)
        if host:
            raise storops.exception.UnityHostNameInUseError()
        else:
            host = UnityHost.create(self._cli, name, host_type=host_type,
                                    desc=desc, os=os, tenant=tenant)

        return host
示例#5
0
文件: system.py 项目: crook/storops
 def get_host(self, _id=None, name=None, address=None, **filters):
     ret = UnityHostList.get(self._cli, name='not found')
     if address:
         host_ip_ports = UnityHostIpPortList.get(self._cli, address=address)
         if host_ip_ports:
             ret = host_ip_ports[0].host
     else:
         ret = self._get_unity_rsc(UnityHostList, _id=_id, name=name,
                                   **filters)
     return ret
示例#6
0
    def create_host(self, name, host_type=None, desc=None, os=None):
        host = UnityHostList.get(self._cli, name=name)
        if host:
            raise ex.UnityHostNameInUseError()
        else:
            host = UnityHost.create(self._cli,
                                    name,
                                    host_type=host_type,
                                    desc=desc,
                                    os=os)

        return host
示例#7
0
 def test_get_all(self):
     hosts = UnityHostList(cli=t_rest())
     assert_that(len(hosts), equal_to(7))