Class: SoftLayer::NetworkStorage

Inherits:
ModelBase show all
Includes:
DynamicAttribute
Defined in:
lib/softlayer/NetworkStorage.rb

Overview

Each SoftLayer NetworkStorage instance provides information about a storage product and access credentials.

This class roughly corresponds to the entity SoftLayer_Network_Storage in the API.

Instance Attribute Summary

Attributes inherited from ModelBase

#softlayer_client

Instance Method Summary collapse

Methods included from DynamicAttribute

included

Methods inherited from ModelBase

#[], #has_sl_property?, #initialize, #refresh_details, sl_attr, #to_ary

Constructor Details

This class inherits a constructor from SoftLayer::ModelBase

Instance Method Details

#account_passwordObject

Other usernames and passwords associated with a Storage volume.



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/softlayer/NetworkStorage.rb', line 59

sl_dynamic_attr :account_password do |resource|
  resource.should_update? do
    #only retrieved once per instance
    @account_password == nil
  end

  resource.to_update do
     = self.service.object_mask(AccountPassword.default_object_mask).getAccountPassword
    AccountPassword.new(softlayer_client, ) unless .empty?
  end
end

#add_credential(credential_type) ⇒ Object

Add a username/password credential to the network storage instance

Raises:

  • (ArgumentError)


114
115
116
117
118
119
120
121
122
123
# File 'lib/softlayer/NetworkStorage.rb', line 114

def add_credential(credential_type)
  raise ArgumentError, "The new credential type cannot be nil"   unless credential_type
  raise ArgumentError, "The new credential type cannot be empty" if credential_type.empty?

  new_credential = self.service.object_mask(NetworkStorageCredential.default_object_mask).assignNewCredential(credential_type.to_s)
  
  @credentials = nil

  NetworkStorageCredential.new(softlayer_client, new_credential) unless new_credential.empty?
end

#assign_credential(username) ⇒ Object

Assign an existing network storage credential specified by the username to the network storage instance

Raises:

  • (ArgumentError)


128
129
130
131
132
133
134
135
# File 'lib/softlayer/NetworkStorage.rb', line 128

def assign_credential(username)
  raise ArgumentError, "The username cannot be nil"   unless username
  raise ArgumentError, "The username cannot be empty" if username.empty?

  self.service.assignCredential(username.to_s)
  
  @credentials = nil
end

#capacityObject

:attr_reader: A Storage account's capacity, measured in gigabytes.



21
# File 'lib/softlayer/NetworkStorage.rb', line 21

sl_attr :capacity,   'capacityGb'

#createdObject

:attr_reader: The date a network storage volume was created.



26
# File 'lib/softlayer/NetworkStorage.rb', line 26

sl_attr :created,    'createDate'

#credentialsObject

A Storage volume's access credentials.



73
74
75
76
77
78
79
80
81
82
# File 'lib/softlayer/NetworkStorage.rb', line 73

sl_dynamic_attr :credentials do |resource|
  resource.should_update? do
    #only retrieved once per instance
    @credentials == nil
  end

  resource.to_update do
    self.service.object_mask(NetworkStorageCredential.default_object_mask).getCredentials.collect{|cred| NetworkStorageCredential.new(softlayer_client, cred) }
  end
end

#has_user_credential?(username) ⇒ Boolean

Determines if one of the credentials pertains to the specified username.

Returns:

  • (Boolean)


140
141
142
# File 'lib/softlayer/NetworkStorage.rb', line 140

def has_user_credential?(username)
  self.credentials.map { |credential| credential.username }.include?(username)
end

#notesObject

:attr_reader: Public notes related to a Storage volume.



31
# File 'lib/softlayer/NetworkStorage.rb', line 31

sl_attr :notes

#notes=(notes) ⇒ Object

Updates the notes for the network storage instance.



147
148
149
150
# File 'lib/softlayer/NetworkStorage.rb', line 147

def notes=(notes)
  self.service.editObject({ "notes" => notes.to_s })
  self.refresh_details()
end

#passwordObject

:attr_reader: The password used to access a non-EVault Storage volume. This password is used to register the EVault server agent with the vault backup system.



38
# File 'lib/softlayer/NetworkStorage.rb', line 38

sl_attr :password

#password=(password) ⇒ Object

Updates the password for the network storage instance.

Raises:

  • (ArgumentError)


155
156
157
158
159
160
161
# File 'lib/softlayer/NetworkStorage.rb', line 155

def password=(password)
  raise ArgumentError, "The new password cannot be nil"   unless password
  raise ArgumentError, "The new password cannot be empty" if password.empty?

  self.service.editObject({ "password" => password.to_s })
  self.refresh_details()
end

#remove_credential(username) ⇒ Object

Remove an existing network storage credential specified by the username from the network storage instance

Raises:

  • (ArgumentError)


166
167
168
169
170
171
172
173
# File 'lib/softlayer/NetworkStorage.rb', line 166

def remove_credential(username)
  raise ArgumentError, "The username cannot be nil"   unless username
  raise ArgumentError, "The username cannot be empty" if username.empty?

  self.service.removeCredential(username.to_s)
  
  @credentials = nil
end

#serviceObject

Returns the service for interacting with this network storage through the network API



178
179
180
# File 'lib/softlayer/NetworkStorage.rb', line 178

def service
  softlayer_client[:Network_Storage].object_with_id(self.id)
end

#service_resourceObject

The network resource a Storage service is connected to.



86
87
88
89
90
91
92
93
94
95
# File 'lib/softlayer/NetworkStorage.rb', line 86

sl_dynamic_attr :service_resource do |resource|
  resource.should_update? do
    #only retrieved once per instance
    @service_resource == nil
  end

  resource.to_update do
    NetworkService.new(softlayer_client, self.service.object_mask(NetworkService.default_object_mask).getServiceResource)
  end
end

#softlayer_properties(object_mask = nil) ⇒ Object

Make an API request to SoftLayer and return the latest properties hash for this object.



186
187
188
189
190
191
192
193
194
195
196
# File 'lib/softlayer/NetworkStorage.rb', line 186

def softlayer_properties(object_mask = nil)
  my_service = self.service

  if(object_mask)
    my_service = my_service.object_mask(object_mask)
  else
    my_service = my_service.object_mask(self.class.default_object_mask)
  end

  my_service.getObject()
end

#typeObject

:attr_reader: A Storage account's type.



43
# File 'lib/softlayer/NetworkStorage.rb', line 43

sl_attr :type,       'nasType'

#update_credential_password(username, password) ⇒ Object

Updates the password for the network storage credential of the username specified.

Raises:

  • (ArgumentError)


201
202
203
204
205
206
207
208
209
210
# File 'lib/softlayer/NetworkStorage.rb', line 201

def update_credential_password(username, password)
  raise ArgumentError, "The new password cannot be nil"   unless password
  raise ArgumentError, "The new username cannot be nil"   unless username
  raise ArgumentError, "The new password cannot be empty" if password.empty?
  raise ArgumentError, "The new username cannot be empty" if username.empty?

  self.service.editCredential(username.to_s, password.to_s)

  @credentials = nil
end

#upgradableObject

:attr_reader: This flag indicates whether this storage type is upgradable or not.



48
# File 'lib/softlayer/NetworkStorage.rb', line 48

sl_attr :upgradable, 'upgradableFlag'

#usernameObject

:attr_reader: The username used to access a non-EVault Storage volume. This username is used to register the EVault server agent with the vault backup system.



55
# File 'lib/softlayer/NetworkStorage.rb', line 55

sl_attr :username

#webcc_accountObject

The account username and password for the EVault webCC interface.



99
100
101
102
103
104
105
106
107
108
109
# File 'lib/softlayer/NetworkStorage.rb', line 99

sl_dynamic_attr :webcc_account do |resource|
  resource.should_update? do
    #only retrieved once per instance
    @webcc_account == nil
  end

  resource.to_update do
     = self.service.object_mask(AccountPassword.default_object_mask).getWebccAccount
    AccountPassword.new(softlayer_client, ) unless .empty?
  end
end