Sha256: f0022ef1f992e380f41ff64f2558fd0febe0920e2a19a6a54e985f3dee7607bc

Contents?: true

Size: 1.63 KB

Versions: 29

Compression:

Stored size: 1.63 KB

Contents

module Fog
  module Compute
    class HPV2
      class Real
        # Retrieves the encrypted administrator password for a server running Windows.
        #
        # ==== Parameters
        # * 'server_id'<~String> - UUId of the server
        #
        # ==== Returns
        # * 'password_data'<~string>: Encrypted password for a server running Windows
        #
        def get_windows_password(server_id)
          # get console output assuming that the server is already in active state
          log_output = get_console_output(server_id, 400).body['output']
          # decrypt the log output to extract the encrypted, base64-encoded password
          encrypted_password = extract_password_from_log(log_output)
        end
      end

      class Mock
        def get_windows_password(server_id)
          # need to mock out the private key as well
          private_key = OpenSSL::PKey::RSA.generate(1024)
          public_key = private_key.public_key
          ### The original password is Passw0rd
          encoded_password = encrypt_using_public_key("Passw0rd", public_key)

          if list_servers_detail.body['servers'].find {|_| _['id'] == server_id}
            # mock output for this call get_console_output(server_id, 400).body['output']
            log_output = "start junk [cloud-init] Encrypt random password\n-----BEGIN BASE64-ENCODED ENCRYPTED PASSWORD-----\n#{encoded_password}-----END BASE64-ENCODED ENCRYPTED PASSWORD-----\nend junk [cloud-init] Done\n"
            encrypted_password = extract_password_from_log(log_output)
          else
            raise Fog::Compute::HPV2::NotFound
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 4 rubygems

Version Path
fog-1.37.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.36.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.35.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-2.0.0.pre.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.34.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.33.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.32.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.31.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.30.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.29.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.28.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.27.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.26.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.25.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
nsidc-fog-1.24.1 lib/fog/hp/requests/compute_v2/get_windows_password.rb
fog-1.24.0 lib/fog/hp/requests/compute_v2/get_windows_password.rb
ns-fog-1.22.11 lib/fog/hp/requests/compute_v2/get_windows_password.rb
ns-fog-1.22.10 lib/fog/hp/requests/compute_v2/get_windows_password.rb