Class: Zm::Client::Cluster
- Inherits:
-
Object
- Object
- Zm::Client::Cluster
- Defined in:
- lib/zm/client/cluster/cluster.rb
Overview
class admin connection
Instance Attribute Summary collapse
-
#buildDate ⇒ Object
readonly
Returns the value of attribute buildDate.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#majorversion ⇒ Object
readonly
Returns the value of attribute majorversion.
-
#microversion ⇒ Object
readonly
Returns the value of attribute microversion.
-
#minorversion ⇒ Object
readonly
Returns the value of attribute minorversion.
-
#release ⇒ Object
readonly
Returns the value of attribute release.
-
#soap_admin_connector ⇒ Object
readonly
Returns the value of attribute soap_admin_connector.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
-
#zimbra_attributes ⇒ Object
readonly
Returns the value of attribute zimbra_attributes.
Instance Method Summary collapse
- #accounts ⇒ Object
- #alive? ⇒ Boolean
- #coses ⇒ Object
- #count_object(type) ⇒ Object
- #distributionlists ⇒ Object (also: #distribution_lists)
- #domain_key(domain_name) ⇒ Object
- #domains ⇒ Object
- #email_exist?(email) ⇒ Boolean
- #has_admin_credentials? ⇒ Boolean
- #infos! ⇒ Object
-
#initialize(config) ⇒ Cluster
constructor
A new instance of Cluster.
- #license ⇒ Object
- #logged? ⇒ Boolean
- #login ⇒ Object
- #resources ⇒ Object
- #servers ⇒ Object
- #soap_account_connector ⇒ Object
- #token_metadata ⇒ Object
Constructor Details
#initialize(config) ⇒ Cluster
Returns a new instance of Cluster.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/zm/client/cluster/cluster.rb', line 24 def initialize(config) extend(ZmLogger) @config = config @version = config.zimbra_version @zimbra_attributes = Base::ZimbraAttributesCollection.new(self) @zimbra_attributes.set_methods @soap_admin_connector = SoapAdminConnector.new( @config.zimbra_admin_scheme, @config.zimbra_admin_host, @config.zimbra_admin_port ) @soap_admin_connector.logger = logger end |
Instance Attribute Details
#buildDate ⇒ Object (readonly)
Returns the value of attribute buildDate.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def buildDate @buildDate end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
20 21 22 |
# File 'lib/zm/client/cluster/cluster.rb', line 20 def config @config end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def host @host end |
#majorversion ⇒ Object (readonly)
Returns the value of attribute majorversion.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def majorversion @majorversion end |
#microversion ⇒ Object (readonly)
Returns the value of attribute microversion.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def microversion @microversion end |
#minorversion ⇒ Object (readonly)
Returns the value of attribute minorversion.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def minorversion @minorversion end |
#release ⇒ Object (readonly)
Returns the value of attribute release.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def release @release end |
#soap_admin_connector ⇒ Object (readonly)
Returns the value of attribute soap_admin_connector.
20 21 22 |
# File 'lib/zm/client/cluster/cluster.rb', line 20 def soap_admin_connector @soap_admin_connector end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def type @type end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
22 23 24 |
# File 'lib/zm/client/cluster/cluster.rb', line 22 def version @version end |
#zimbra_attributes ⇒ Object (readonly)
Returns the value of attribute zimbra_attributes.
20 21 22 |
# File 'lib/zm/client/cluster/cluster.rb', line 20 def zimbra_attributes @zimbra_attributes end |
Instance Method Details
#accounts ⇒ Object
94 95 96 |
# File 'lib/zm/client/cluster/cluster.rb', line 94 def accounts @accounts ||= AccountsCollection.new self end |
#alive? ⇒ Boolean
59 60 61 62 63 64 65 |
# File 'lib/zm/client/cluster/cluster.rb', line 59 def alive? @soap_admin_connector.noop true rescue Zm::Client::SoapError => e logger.error "Admin session token alive ? #{e.message}" false end |
#coses ⇒ Object
106 107 108 |
# File 'lib/zm/client/cluster/cluster.rb', line 106 def coses @coses ||= CosesCollection.new self end |
#count_object(type) ⇒ Object
122 123 124 125 126 127 |
# File 'lib/zm/client/cluster/cluster.rb', line 122 def count_object(type) raise ZmError, 'Unknown object type' unless Zm::Client::CountTypes::ALL.include?(type) resp = soap_admin_connector.count_object(type) resp[:Body][:CountObjectsResponse][:num] end |
#distributionlists ⇒ Object Also known as: distribution_lists
110 111 112 |
# File 'lib/zm/client/cluster/cluster.rb', line 110 def distributionlists @distributionlists ||= DistributionListsCollection.new self end |
#domain_key(domain_name) ⇒ Object
116 117 118 119 120 |
# File 'lib/zm/client/cluster/cluster.rb', line 116 def domain_key(domain_name) key = @config.domain_key(domain_name) key ||= find_domain_key(domain_name) key end |
#domains ⇒ Object
90 91 92 |
# File 'lib/zm/client/cluster/cluster.rb', line 90 def domains @domains ||= DomainsCollection.new self end |
#email_exist?(email) ⇒ Boolean
129 130 131 132 133 134 |
# File 'lib/zm/client/cluster/cluster.rb', line 129 def email_exist?(email) filter = "(mail=#{email})" resp = soap_admin_connector.search_directory(filter, nil, nil, nil, nil, nil, nil, nil, 'accounts,distributionlists,aliases,resources',nil, 1) num = resp[:Body][:SearchDirectoryResponse][:num] !num.zero? end |
#has_admin_credentials? ⇒ Boolean
41 42 43 |
# File 'lib/zm/client/cluster/cluster.rb', line 41 def has_admin_credentials? @config.has_admin_credentials? end |
#infos! ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/zm/client/cluster/cluster.rb', line 136 def infos! rep = soap_admin_connector.get_version_info json = rep[:Body][:GetVersionInfoResponse][:info].first instance_variable_set(:@type, json[:type]) instance_variable_set(:@version, json[:version]) instance_variable_set(:@release, json[:release]) instance_variable_set(:@buildDate, json[:buildDate]) instance_variable_set(:@host, json[:host]) instance_variable_set(:@majorversion, json[:majorversion]) instance_variable_set(:@minorversion, json[:minorversion]) instance_variable_set(:@microversion, json[:microversion]) end |
#license ⇒ Object
83 84 85 86 87 88 |
# File 'lib/zm/client/cluster/cluster.rb', line 83 def license @license ||= LicensesCollection.new(self).find rescue Zm::Client::SoapError => e logger.error "Get License info #{e.message}" nil end |
#logged? ⇒ Boolean
55 56 57 |
# File 'lib/zm/client/cluster/cluster.rb', line 55 def logged? !@soap_admin_connector.token.nil? end |
#login ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/zm/client/cluster/cluster.rb', line 45 def login raise ClusterConfigError, 'admin credentials are missing' unless @config.has_admin_credentials? logger.info "Get Admin session token" @soap_admin_connector.auth( @config.zimbra_admin_login, @config.zimbra_admin_password ) end |
#resources ⇒ Object
98 99 100 |
# File 'lib/zm/client/cluster/cluster.rb', line 98 def resources @resources ||= ResourcesCollection.new self end |
#servers ⇒ Object
102 103 104 |
# File 'lib/zm/client/cluster/cluster.rb', line 102 def servers @servers ||= ServersCollection.new self end |
#soap_account_connector ⇒ Object
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/zm/client/cluster/cluster.rb', line 67 def soap_account_connector return @soap_account_connector unless @soap_account_connector.nil? @soap_account_connector = SoapAccountConnector.new( @config.zimbra_public_scheme, @config.zimbra_public_host, @config.zimbra_public_port ) @soap_account_connector.logger = logger @soap_account_connector end |
#token_metadata ⇒ Object
79 80 81 |
# File 'lib/zm/client/cluster/cluster.rb', line 79 def ||= TokenMetaData.new(@soap_admin_connector.token) end |