Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/os_profile.rb
# build the OS Profile object needed to create a VM for Azure.
build the OS Profile object needed to create a VM for Azure.
build the OS Profile object needed to create a VM for Azure .
def build_profile(initial_user, pub_key, server_name)
      linux_config = Azure::ARM::Compute::Models::LinuxConfiguration.new
      linux_config.disable_password_authentication = true
      linux_config.ssh = Azure::ARM::Compute::Models::SshConfiguration.new
      linux_config.ssh.public_keys = []
      linux_config.ssh.public_keys[0] =
        Azure::ARM::Compute::Models::SshPublicKey.new
      linux_config.ssh.public_keys[0].path =
        "/home/#{initial_user}/.ssh/authorized_keys"
      linux_config.ssh.public_keys[0].key_data = pub_key
      OOLog.info("Public Key is: #{pub_key}")
      os_profile = Azure::ARM::Compute::Models::OSProfile.new
      os_profile.computer_name = server_name
      OOLog.info("Computer Name is: #{os_profile.computer_name}")
      os_profile.admin_username = initial_user
      OOLog.info("Initial User is: #{os_profile.admin_username}")
      os_profile.linux_configuration = linux_config
      return os_profile
    end
def build_profile ( initial_user , pub_key , server_name ) linux_config = Azure :: ARM :: Compute :: Models :: LinuxConfiguration . new linux_config . disable_password_authentication = true linux_config . ssh = Azure :: ARM :: Compute :: Models :: SshConfiguration . new linux_config . ssh . public_keys = [ ] linux_config . ssh . public_keys [ 0 ] = Azure :: ARM :: Compute :: Models :: SshPublicKey . new linux_config . ssh . public_keys [ 0 ] . path = "/home/#{initial_user}/.ssh/authorized_keys" linux_config . ssh . public_keys [ 0 ] . key_data = pub_key OOLog . info ( "Public Key is: #{pub_key}" ) os_profile = Azure :: ARM :: Compute :: Models :: OSProfile . new os_profile . computer_name = server_name OOLog . info ( "Computer Name is: #{os_profile.computer_name}" ) os_profile . admin_username = initial_user OOLog . info ( "Initial User is: #{os_profile.admin_username}" ) os_profile . linux_configuration = linux_config return os_profile end
build the OS Profile object needed to create a VM for Azure.
build the OS Profile object needed to create a VM for Azure .
initial_user
<not_specific>
pub_key
<not_specific>
server_name
<not_specific>