Пример #1
0
 def create_host(self, hostname, host_os, domain, wwn_or_iscsi=None):
     """
     Defines a new system host.  Either Fibre Channel or iSCSI specified by
     'conn_type' parameter.
     Parameters:
             hostname    -> Name of host, up to 31 characters
             wwn_or_iscsi -> Specifies a WWN or iSCSI name to be assigned
             host_os     -> Specifies OS running on host
             conn_type   -> valid values are 'wwn' or 'iscsi'
     """
     try:
         if wwn_or_iscsi is not None:
             if check_wwn(wwn_or_iscsi):
                 output = ha_library.run_storage_commands(
                     self.mgt_ip, self.mgt_username, self.mgt_pw,
                     "createhost -os %s -domain %a %s %s" %
                     (host_os, domain, hostname, wwn_or_iscsi))
             else:
                 output = ha_library.run_storage_commands(
                     self.mgt_ip, self.mgt_username, self.mgt_pw,
                     "createhost -iscsi -os %s -domain %s %s %s" %
                     (host_os, domain, hostname, wwn_or_iscsi))
             # else:
             # raise ValueError("invalid conn_type: only accepts either 'wwn' or 'iscsi'")
         else:
             output = ha_library.run_storage_commands(
                 self.mgt_ip, self.mgt_username, self.mgt_pw,
                 "createhost -os %s -domain %s %s" %
                 (host_os, domain, hostname))
         time.sleep(5)
         return output
     except:
         log._warn("storage_3par: failed to execute create_host command..")
         return False
Пример #2
0
 def create_virtual_volume(self, name, size, user_cpg, thin=False):
     """
     Parameters:
             name     -> Name of virtual volume, up to 31 characters
             size     -> Size of the volume in GB, must be integer.
             user_cpg -> Name of common provisioning group (CPG)
             thin     -> Optional boolean flag for thin provisoned volume
     """
     if is_int(size):
         if thin:
             output = ha_library.run_storage_commands(
                 self.mgt_ip, self.mgt_username, self.mgt_pw,
                 "createvv -tpvv %s %s %sg" % (user_cpg, name, size))
         else:
             output = ha_library.run_storage_commands(
                 self.mgt_ip, self.mgt_username, self.mgt_pw,
                 "createvv %s %s %sg" % (user_cpg, name, size))
     else:
         raise ValueError("size not of type 'int'")
     return output
Пример #3
0
 def get_vluns(self):
     """
     Returns VLUN information from the system
     """
     output = ha_library.run_storage_commands(self.mgt_ip,
                                              self.mgt_username,
                                              self.mgt_pw, "showvlun")
     if output:
         return output
     else:
         log._warn("Failed to execute get_vlun command")
         return False
Пример #4
0
 def get_cpgs(self):
     """
     Returns common provisioning group information
     """
     output = ha_library.run_storage_commands(self.mgt_ip,
                                              self.mgt_username,
                                              self.mgt_pw, "showcpg")
     if output:
         return output
     else:
         log._warn("Failed to execute get_cpg command")
         return False
Пример #5
0
 def get_domains(self):
     """
     Returns domains in 3PAR system
     """
     output = ha_library.run_storage_commands(self.mgt_ip,
                                              self.mgt_username,
                                              self.mgt_pw, "showdomain")
     if output:
         return output
     else:
         log._warn("Failed to execute get_domains command")
         return False
Пример #6
0
 def delete_vlun(self, lun, virt_vol, host):
     """
     Deletes VLUN from the system
     """
     output = ha_library.run_storage_commands(
         self.mgt_ip, self.mgt_username, self.mgt_pw,
         "removevlun -f %s %s %s" % (virt_vol, lun, host))
     if output:
         return output
     else:
         log._warn("Failed to execute delete_vlun command for %s" %
                   virt_vol)
         return False
Пример #7
0
 def delete_cpg(self, cpg_name):
     """
     Deletes common provisioning group information
     """
     output = ha_library.run_storage_commands(self.mgt_ip,
                                              self.mgt_username,
                                              self.mgt_pw,
                                              "removecpg -f %s" % cpg_name)
     if output:
         return output
     else:
         log._warn("Failed to execute delete_cpg command on %s" % cpg_name)
         return False
Пример #8
0
    def get_hosts(self):
        """
        Returns host information from 3par system
        """

        output = ha_library.run_storage_commands(self.mgt_ip,
                                                 self.mgt_username,
                                                 self.mgt_pw, "showhost")
        if output:
            return output
        else:
            log._warn("Failed to execute get_hosts command")
            return False
Пример #9
0
    def delete_host(self, host):
        """
        Deletes host from 3par system
        """

        output = ha_library.run_storage_commands(self.mgt_ip,
                                                 self.mgt_username,
                                                 self.mgt_pw,
                                                 "removehost %s" % host)
        # can add check by issuing get_host and seeing if host in output of
        # get_host...
        if output:
            return output
        else:
            log._warn("Failed to execute delete_host command on %s" % host)
            return False
Пример #10
0
    def delete_virtualvolume(self, virt_vol):
        """
        Deletes virtual volumes on the 3par system.

        """

        output = ha_library.run_storage_commands(self.mgt_ip,
                                                 self.mgt_username,
                                                 self.mgt_pw,
                                                 "removevv -f %s" % virt_vol)
        if output:
            return output
        else:
            log._warn("Failed to execute delete_virtualvolume command on %s" %
                      virt_vol)
            return False
Пример #11
0
 def delete_user(self, username):
     """
     Parameters:                 username     -> Name of the user, up to 31 characters long. First
                                     character must be alphanumeric, and can contain
                                     period ('.'), dash ('-') and underscore ('_').
                                 domain_name  -> List of users to be added to domain.
     Optional Parameters:        role         -> browse, edit, service, super [default is super]
     """
     output = ha_library.run_storage_commands(
         self.mgt_ip, self.mgt_username, self.mgt_pw,
         "removeuser -f %s" % (username))
     if output:
         return output
     else:
         log._warn("Failed to execute createuser command")
         return False
Пример #12
0
 def create_domain(self, domain_name, domain_users):
     """
     Parameters:
             domain_name  -> Specifies the name of the domain you are creating.
                             Cannot be longer than 31 characters.  Name "all"
                             is reserved.
             domain_users -> List of users to be added to domain.
     """
     output = ha_library.run_storage_commands(
         self.mgt_ip, self.mgt_username, self.mgt_pw,
         "createdomain %s" % (domain_name))
     for user in domain_users:
         test = self.create_user(user, domain_name)
         if test is False:
             log._debug("User '%s' not added", user)
             return False
     return output
Пример #13
0
 def delete_domain(self, domain, domain_users):
     """
     Deletes domains in 3PAR system
     """
     for user in domain_users:
         test = self.delete_user(user)
         if test is False:
             log._debug("User '%s' not added", user)
             return False
     output = ha_library.run_storage_commands(self.mgt_ip,
                                              self.mgt_username,
                                              self.mgt_pw,
                                              "removedomain -f %s" % domain)
     if output:
         return output
     else:
         log._warn("Failed to execute delete_domain command")
         return False
Пример #14
0
    def create_vlun(self, lun, hostname, vv_name):
        """
        Exports a virtual volume as a SCSI LUN

        Parameters:
                lun      -> LUN as string from 0 to 16383 or 'auto'
                hostname -> Specifies the host where the LUN is exported, up to
                            31 characters
                vv_name  -> Specifies virtual volume name
        """
        lun = lun.lower()
        output = ha_library.run_storage_commands(
            self.mgt_ip, self.mgt_username, self.mgt_pw,
            "createvlun %s %s %s" % (vv_name, lun, hostname))
        if output:
            return output
        else:
            log._warn("Failed to execute createvlun command")
            return False
Пример #15
0
    def get_virtualvolumes(self, verbose=False):
        """
        Returns virtual volumes on the 3par system.

        Optional Params:
                        verbose = boolean for verbose output, default is False
        """
        if verbose:
            command = 'showvv'
        else:
            command = 'showvv -showcols Name'

        output = ha_library.run_storage_commands(self.mgt_ip,
                                                 self.mgt_username,
                                                 self.mgt_pw, command)
        if output:
            return output
        else:
            log._warn("Failed to execute get_virtualvolumes command")
            return False
Пример #16
0
 def create_cpg(self, cpg_name, size, domain, raid_type):
     """
     Parameters:
             cpg_name    -> Name of common provisioning group being created
             size        -> Specifies auto-growth limit in GB, must be int
             domain      -> Name of domain with which the object will reside.
             raid_type   -> Specifies RAID type of logical disk
                    Ex. For RAID5, raid_type should be '5'
     """
     if 'raid' in raid_type.lower():
         raid_type = raid_type.translate(None, 'raidRAID')
     raid_type = raid_type.strip()
     if not is_int(size):
         log._warn("Invalid value for 'size' parameter")
         return False
     output = ha_library.run_storage_commands(
         self.mgt_ip, self.mgt_username, self.mgt_pw,
         "createcpg -f -sdgs %sg -domain %s -t r%s %s" %
         (size, domain, raid_type, cpg_name))
     if output:
         return output
     else:
         log._warn("Failed to execute createcpg command")
         return False