Class: VagrantPlugins::WinAzure::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::WinAzure::Config
- Defined in:
- lib/vagrant-azure/config.rb
Instance Attribute Summary collapse
-
#availability_set_name ⇒ Object
Returns the value of attribute availability_set_name.
-
#cloud_service_name ⇒ Object
Returns the value of attribute cloud_service_name.
-
#deployment_name ⇒ Object
Returns the value of attribute deployment_name.
-
#mgmt_certificate ⇒ Object
Returns the value of attribute mgmt_certificate.
-
#mgmt_endpoint ⇒ Object
Returns the value of attribute mgmt_endpoint.
-
#private_key_file ⇒ Object
(also: #ssh_private_key_file)
ssh_private_key and ssh_certificate_file is overly specific and probably should be deprecated in favor of private_key_file and certificate_file as they are in Azure ruby sdk.
-
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
-
#state_read_timeout ⇒ Object
Returns the value of attribute state_read_timeout.
-
#storage_access_key ⇒ Object
Returns the value of attribute storage_access_key.
-
#storage_acct_name ⇒ Object
Returns the value of attribute storage_acct_name.
-
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
-
#tcp_endpoints ⇒ Object
Returns the value of attribute tcp_endpoints.
-
#vm_affinity_group ⇒ Object
Returns the value of attribute vm_affinity_group.
-
#vm_image ⇒ Object
Returns the value of attribute vm_image.
-
#vm_location ⇒ Object
Returns the value of attribute vm_location.
-
#vm_name ⇒ Object
Returns the value of attribute vm_name.
-
#vm_password ⇒ Object
Returns the value of attribute vm_password.
-
#vm_size ⇒ Object
Returns the value of attribute vm_size.
-
#vm_user ⇒ Object
Returns the value of attribute vm_user.
-
#vm_virtual_network_name ⇒ Object
Returns the value of attribute vm_virtual_network_name.
-
#winrm_http_port ⇒ Object
Returns the value of attribute winrm_http_port.
-
#winrm_https_port ⇒ Object
Returns the value of attribute winrm_https_port.
-
#winrm_transport ⇒ Object
Returns the value of attribute winrm_transport.
Instance Method Summary collapse
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/vagrant-azure/config.rb', line 47 def initialize @storage_acct_name = UNSET_VALUE @storage_access_key = UNSET_VALUE @mgmt_certificate = UNSET_VALUE @mgmt_endpoint = UNSET_VALUE @subscription_id = UNSET_VALUE @vm_name = UNSET_VALUE @vm_user = UNSET_VALUE @vm_password = UNSET_VALUE @vm_image = UNSET_VALUE @vm_location = UNSET_VALUE @vm_affinity_group = UNSET_VALUE @vm_virtual_network_name = UNSET_VALUE @cloud_service_name = UNSET_VALUE @deployment_name = UNSET_VALUE @tcp_endpoints = UNSET_VALUE @private_key_file = UNSET_VALUE @ssh_port = UNSET_VALUE @vm_size = UNSET_VALUE @winrm_transport = UNSET_VALUE @winrm_http_port = UNSET_VALUE @winrm_https_port = UNSET_VALUE @availability_set_name = UNSET_VALUE @state_read_timeout = UNSET_VALUE end |
Instance Attribute Details
#availability_set_name ⇒ Object
Returns the value of attribute availability_set_name.
43 44 45 |
# File 'lib/vagrant-azure/config.rb', line 43 def availability_set_name @availability_set_name end |
#cloud_service_name ⇒ Object
Returns the value of attribute cloud_service_name.
27 28 29 |
# File 'lib/vagrant-azure/config.rb', line 27 def cloud_service_name @cloud_service_name end |
#deployment_name ⇒ Object
Returns the value of attribute deployment_name.
28 29 30 |
# File 'lib/vagrant-azure/config.rb', line 28 def deployment_name @deployment_name end |
#mgmt_certificate ⇒ Object
Returns the value of attribute mgmt_certificate.
13 14 15 |
# File 'lib/vagrant-azure/config.rb', line 13 def mgmt_certificate @mgmt_certificate end |
#mgmt_endpoint ⇒ Object
Returns the value of attribute mgmt_endpoint.
14 15 16 |
# File 'lib/vagrant-azure/config.rb', line 14 def mgmt_endpoint @mgmt_endpoint end |
#private_key_file ⇒ Object Also known as: ssh_private_key_file
ssh_private_key and ssh_certificate_file is overly specific and probably should be deprecated in favor of private_key_file and certificate_file as they are in Azure ruby sdk. This is here to not break compatibility with previous versions.
34 35 36 |
# File 'lib/vagrant-azure/config.rb', line 34 def private_key_file @private_key_file end |
#ssh_port ⇒ Object
Returns the value of attribute ssh_port.
38 39 40 |
# File 'lib/vagrant-azure/config.rb', line 38 def ssh_port @ssh_port end |
#state_read_timeout ⇒ Object
Returns the value of attribute state_read_timeout.
45 46 47 |
# File 'lib/vagrant-azure/config.rb', line 45 def state_read_timeout @state_read_timeout end |
#storage_access_key ⇒ Object
Returns the value of attribute storage_access_key.
17 18 19 |
# File 'lib/vagrant-azure/config.rb', line 17 def storage_access_key @storage_access_key end |
#storage_acct_name ⇒ Object
Returns the value of attribute storage_acct_name.
16 17 18 |
# File 'lib/vagrant-azure/config.rb', line 16 def storage_acct_name @storage_acct_name end |
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
15 16 17 |
# File 'lib/vagrant-azure/config.rb', line 15 def subscription_id @subscription_id end |
#tcp_endpoints ⇒ Object
Returns the value of attribute tcp_endpoints.
29 30 31 |
# File 'lib/vagrant-azure/config.rb', line 29 def tcp_endpoints @tcp_endpoints end |
#vm_affinity_group ⇒ Object
Returns the value of attribute vm_affinity_group.
24 25 26 |
# File 'lib/vagrant-azure/config.rb', line 24 def vm_affinity_group @vm_affinity_group end |
#vm_image ⇒ Object
Returns the value of attribute vm_image.
22 23 24 |
# File 'lib/vagrant-azure/config.rb', line 22 def vm_image @vm_image end |
#vm_location ⇒ Object
Returns the value of attribute vm_location.
23 24 25 |
# File 'lib/vagrant-azure/config.rb', line 23 def vm_location @vm_location end |
#vm_name ⇒ Object
Returns the value of attribute vm_name.
19 20 21 |
# File 'lib/vagrant-azure/config.rb', line 19 def vm_name @vm_name end |
#vm_password ⇒ Object
Returns the value of attribute vm_password.
21 22 23 |
# File 'lib/vagrant-azure/config.rb', line 21 def vm_password @vm_password end |
#vm_size ⇒ Object
Returns the value of attribute vm_size.
39 40 41 |
# File 'lib/vagrant-azure/config.rb', line 39 def vm_size @vm_size end |
#vm_user ⇒ Object
Returns the value of attribute vm_user.
20 21 22 |
# File 'lib/vagrant-azure/config.rb', line 20 def vm_user @vm_user end |
#vm_virtual_network_name ⇒ Object
Returns the value of attribute vm_virtual_network_name.
25 26 27 |
# File 'lib/vagrant-azure/config.rb', line 25 def vm_virtual_network_name @vm_virtual_network_name end |
#winrm_http_port ⇒ Object
Returns the value of attribute winrm_http_port.
41 42 43 |
# File 'lib/vagrant-azure/config.rb', line 41 def winrm_http_port @winrm_http_port end |
#winrm_https_port ⇒ Object
Returns the value of attribute winrm_https_port.
42 43 44 |
# File 'lib/vagrant-azure/config.rb', line 42 def winrm_https_port @winrm_https_port end |
#winrm_transport ⇒ Object
Returns the value of attribute winrm_transport.
40 41 42 |
# File 'lib/vagrant-azure/config.rb', line 40 def winrm_transport @winrm_transport end |
Instance Method Details
#finalize! ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/vagrant-azure/config.rb', line 75 def finalize! @storage_acct_name = ENV['AZURE_STORAGE_ACCOUNT'] if @storage_acct_name == UNSET_VALUE @storage_access_key = ENV['AZURE_STORAGE_ACCESS_KEY'] if @storage_access_key == UNSET_VALUE @mgmt_certificate = ENV['AZURE_MANAGEMENT_CERTIFICATE'] if @mgmt_certificate == UNSET_VALUE @mgmt_endpoint = ENV['AZURE_MANAGEMENT_ENDPOINT'] if @mgmt_endpoint == UNSET_VALUE @subscription_id = ENV['AZURE_SUBSCRIPTION_ID'] if @subscription_id == UNSET_VALUE @vm_name = nil if @vm_name == UNSET_VALUE @vm_user = 'vagrant' if @vm_user == UNSET_VALUE @vm_password = nil if @vm_password == UNSET_VALUE @vm_image = nil if @vm_image == UNSET_VALUE @vm_location = 'West US' if @vm_location == UNSET_VALUE @vm_affinity_group = nil if @vm_affinity_group == UNSET_VALUE @vm_virtual_network_name = nil if @vm_virtual_network_name == UNSET_VALUE @cloud_service_name = nil if @cloud_service_name == UNSET_VALUE @deployment_name = nil if @deployment_name == UNSET_VALUE @tcp_endpoints = nil if @tcp_endpoints == UNSET_VALUE @private_key_file = nil if @private_key_file == UNSET_VALUE @ssh_port = nil if @ssh_port == UNSET_VALUE @vm_size = nil if @vm_size == UNSET_VALUE @winrm_transport = nil if @winrm_transport == UNSET_VALUE @winrm_http_port = nil if @winrm_http_port == UNSET_VALUE @winrm_https_port = nil if @winrm_https_port == UNSET_VALUE @availability_set_name = nil if @availability_set_name == UNSET_VALUE @state_read_timeout = nil if @state_read_timeout == UNSET_VALUE utils = Class.new.extend(Azure::Core::Utility) # This done due to a bug in Ruby SDK - it doesn't generate a storage # account name if add_role = true if @storage_acct_name.nil? || @storage_acct_name.empty? @storage_acct_name = utils.random_string("#{@vm_name}storage").gsub(/[^0-9a-z ]/i, '').downcase[0..23] end if @cloud_service_name.nil? || @cloud_service_name.empty? @cloud_service_name = utils.random_string("#{@vm_name}-service-") end end |
#validate(machine) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/vagrant-azure/config.rb', line 117 def validate(machine) errors = _detected_errors # Azure connection properties related validation. errors << 'vagrant_azure.subscription_id.required' if @subscription_id.nil? errors << 'vagrant_azure.mgmt_certificate.required' if @mgmt_certificate.nil? errors << 'vagrant_azure.mgmt_endpoint.required' if @mgmt_endpoint.nil? # Azure Virtual Machine related validation errors << 'vagrant_azure.vm_name.required' if @vm_name.nil? paths = machine.config.ssh.private_key_path unless @vm_password || machine.config.ssh.password || @private_key_file || (paths && paths.count > 0) errors << 'You must provide one of the following: ssh.private_key_path, azure.private_key_file, ssh.password or azure.vm_password.' end if (@private_key_file || (paths && paths.count > 0)) && (@vm_password || machine.config.ssh.password) machine.config.ssh.password = @vm_password = nil machine.ui.warn('You specified both private_key and password. Vagrant-Azure will only use the private_key in this case.') end if machine.config.ssh.password.nil? && @vm_password machine.config.ssh.password = @vm_password elsif machine.config.ssh.password && @vm_password.nil? @vm_password = machine.config.ssh.password end if machine.config.ssh.private_key_path.nil? && @private_key_file machine.config.ssh.private_key_path = [File.(@private_key_file)] elsif machine.config.ssh.private_key_path && @private_key_file.nil? @private_key_file = File.(paths.first) end { 'Microsoft Azure Provider' => errors } end |