Class: VagrantPlugins::Deltacloud::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Deltacloud::Config
- Defined in:
- lib/vagrant-deltacloud-provider/config.rb
Instance Attribute Summary collapse
-
#availability_zone ⇒ String
Availability Zone.
-
#deltacloud_api_url ⇒ Object
The url to access Deltacloud.
-
#hardware_profile ⇒ Object
The hardware profile of server to launch, either the ID or name.
-
#image ⇒ Object
The name or ID of the image to use.
-
#metadata ⇒ Hash
A Hash of metadata that will be sent to the instance for configuration.
-
#networks ⇒ Array
Network list the VM will be connected to.
-
#password ⇒ Object
The API key to access Deltacloud.
-
#public_key_name ⇒ String
The name of the public key to use.
-
#public_key_path ⇒ Array
Public key path to create Deltacloud keypair.
-
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider.
-
#scheduler_hints ⇒ Object
Pass hints to the Deltacloud scheduler, e.g.
-
#security_groups ⇒ Array[String]
List of strings representing the security groups to apply.
-
#server_name ⇒ Object
The name of the server.
-
#ssh_disabled ⇒ Boolean
Flag to enable/disable all SSH actions (to use for instance on private networks).
-
#ssh_timeout ⇒ Integer
The SSH timeout use after server creation.
-
#ssh_username ⇒ String
The SSH username to use with this Deltacloud instance.
-
#sync_method ⇒ String
Sync folder method.
-
#tenant_name ⇒ Object
The name of the deltacloud project on witch the vm will be created.
-
#user_data ⇒ String
User data to be sent to the newly created Deltacloud instance.
-
#username ⇒ String
The username to access Deltacloud.
-
#volumes ⇒ Array
Volumes list that will be attached to the VM.
Instance Method Summary collapse
-
#finalize! ⇒ Object
rubocop:disable Style/CyclomaticComplexity.
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #merge(other) ⇒ Object
-
#rsync_include(inc) ⇒ Object
rubocop:enable Style/CyclomaticComplexity.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 110 def initialize @password = UNSET_VALUE @deltacloud_api_url = UNSET_VALUE @hardware_profile = UNSET_VALUE @image = UNSET_VALUE @tenant_name = UNSET_VALUE @server_name = UNSET_VALUE @username = UNSET_VALUE @rsync_includes = [] @public_key_name = UNSET_VALUE @ssh_username = UNSET_VALUE @ssh_timeout = UNSET_VALUE @sync_method = UNSET_VALUE @availability_zone = UNSET_VALUE @networks = [] @volumes = [] @public_key_path = UNSET_VALUE @scheduler_hints = UNSET_VALUE @security_groups = UNSET_VALUE @user_data = UNSET_VALUE @metadata = UNSET_VALUE @ssh_disabled = UNSET_VALUE end |
Instance Attribute Details
#availability_zone ⇒ String
Availability Zone
83 84 85 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 83 def availability_zone @availability_zone end |
#deltacloud_api_url ⇒ Object
The url to access Deltacloud.
13 14 15 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 13 def deltacloud_api_url @deltacloud_api_url end |
#hardware_profile ⇒ Object
The hardware profile of server to launch, either the ID or name. This can also be a regular expression to partially match a name.
17 18 19 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 17 def hardware_profile @hardware_profile end |
#image ⇒ Object
The name or ID of the image to use. This can also be a regular expression to partially match a name.
21 22 23 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 21 def image @image end |
#metadata ⇒ Hash
A Hash of metadata that will be sent to the instance for configuration
103 104 105 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 103 def @metadata end |
#networks ⇒ Array
Network list the VM will be connected to
68 69 70 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 68 def networks @networks end |
#password ⇒ Object
The API key to access Deltacloud.
9 10 11 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 9 def password @password end |
#public_key_name ⇒ String
The name of the public key to use.
41 42 43 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 41 def public_key_name @public_key_name end |
#public_key_path ⇒ Array
Public key path to create Deltacloud keypair
78 79 80 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 78 def public_key_path @public_key_path end |
#rsync_includes ⇒ Array
Opt files/directories in to the rsync operation performed by this provider
58 59 60 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 58 def rsync_includes @rsync_includes end |
#scheduler_hints ⇒ Object
Pass hints to the Deltacloud scheduler, e.g. { “cell”: “some cell name” }
86 87 88 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 86 def scheduler_hints @scheduler_hints end |
#security_groups ⇒ Array[String]
List of strings representing the security groups to apply. e.g. [‘ssh’, ‘http’]
92 93 94 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 92 def security_groups @security_groups end |
#server_name ⇒ Object
The name of the server. This defaults to the name of the machine defined by Vagrant (via ‘config.vm.define`), but can be overriden here.
31 32 33 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 31 def server_name @server_name end |
#ssh_disabled ⇒ Boolean
Flag to enable/disable all SSH actions (to use for instance on private networks)
108 109 110 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 108 def ssh_disabled @ssh_disabled end |
#ssh_timeout ⇒ Integer
The SSH timeout use after server creation. If server startup is too long the timeout value can be increase with this variable. Default is 60 seconds
53 54 55 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 53 def ssh_timeout @ssh_timeout end |
#ssh_username ⇒ String
The SSH username to use with this Deltacloud instance. This overrides the ‘config.ssh.username` variable.
47 48 49 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 47 def ssh_username @ssh_username end |
#sync_method ⇒ String
Sync folder method. Can be either “rsync” or “none”
63 64 65 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 63 def sync_method @sync_method end |
#tenant_name ⇒ Object
The name of the deltacloud project on witch the vm will be created.
26 27 28 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 26 def tenant_name @tenant_name end |
#user_data ⇒ String
User data to be sent to the newly created Deltacloud instance. Use this e.g. to inject a script at boot time.
98 99 100 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 98 def user_data @user_data end |
#username ⇒ String
The username to access Deltacloud.
36 37 38 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 36 def username @username end |
#volumes ⇒ Array
Volumes list that will be attached to the VM
73 74 75 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 73 def volumes @volumes end |
Instance Method Details
#finalize! ⇒ Object
rubocop:disable Style/CyclomaticComplexity
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 164 def finalize! @password = nil if @password == UNSET_VALUE @deltacloud_api_url = nil if @deltacloud_api_url == UNSET_VALUE @hardware_profile = nil if @hardware_profile == UNSET_VALUE @image = nil if @image == UNSET_VALUE @tenant_name = nil if @tenant_name == UNSET_VALUE @server_name = nil if @server_name == UNSET_VALUE @username = nil if @username == UNSET_VALUE @rsync_includes = nil if @rsync_includes.empty? @sync_method = 'rsync' if @sync_method == UNSET_VALUE @public_key_name = nil if @public_key_name == UNSET_VALUE @public_key_path = nil if @public_key_path == UNSET_VALUE @availability_zone = nil if @availability_zone == UNSET_VALUE @scheduler_hints = nil if @scheduler_hints == UNSET_VALUE @security_groups = nil if @security_groups == UNSET_VALUE @user_data = nil if @user_data == UNSET_VALUE @metadata = nil if @metadata == UNSET_VALUE @ssh_disabled = false if @ssh_disabled == UNSET_VALUE # The SSH values by default are nil, and the top-level config # `config.ssh` values are used. @ssh_username = nil if @ssh_username == UNSET_VALUE @ssh_timeout = 180 if @ssh_timeout == UNSET_VALUE @networks = nil if @networks.empty? @volumes = nil if @volumes.empty? end |
#merge(other) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 134 def merge(other) result = self.class.new # Set all of our instance variables on the new class [self, other].each do |obj| obj.instance_variables.each do |key| # Ignore keys that start with a double underscore. This allows # configuration classes to still hold around internal state # that isn't propagated. next if key.to_s.start_with?('@__') # Don't set the value if it is the unset value, either. value = obj.instance_variable_get(key) if [:@networks, :@volumes, :@rsync_includes].include? key result.instance_variable_set(key, value) unless value.empty? else result.instance_variable_set(key, value) if value != UNSET_VALUE end end end # Persist through the set of invalid methods this_invalid = @__invalid_methods || Set.new other_invalid = other.instance_variable_get(:"@__invalid_methods") || Set.new result.instance_variable_set(:"@__invalid_methods", this_invalid + other_invalid) result end |
#rsync_include(inc) ⇒ Object
rubocop:enable Style/CyclomaticComplexity
192 193 194 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 192 def rsync_include(inc) @rsync_includes << inc end |
#validate(machine) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/vagrant-deltacloud-provider/config.rb', line 196 def validate(machine) errors = _detected_errors errors << I18n.t('vagrant_deltacloud.config.password_required') unless @password errors << I18n.t('vagrant_deltacloud.config.username_required') unless @username validate_ssh_username(machine, errors) validate_ssh_timeout(errors) if machine.config.ssh.private_key_path puts I18n.t('vagrant_deltacloud.config.public_key_name_required').yellow unless @public_key_name || @public_key_path else errors << I18n.t('vagrant_deltacloud.config.private_key_missing') if @public_key_name || @public_key_path end { deltacloud_api_url: @deltacloud_api_url }.each_pair do |key, value| errors << I18n.t('vagrant_deltacloud.config.invalid_uri', key: key, uri: value) unless value.nil? || valid_uri?(value) end { 'Deltacloud Provider' => errors } end |