// newRole creates a gwacl.Role object (an Azure Virtual Machine) which uses // the given Virtual Hard Drive. // // roleSize is the name of one of Azure's machine types, e.g. ExtraSmall, // Large, A6 etc. func (env *azureEnviron) newRole(roleSize string, vhd *gwacl.OSVirtualHardDisk, stateServer bool, userdata, ser string, snapshot *azureEnviron) (*gwacl.Role, error) { // Do some common initialization roleName := gwacl.MakeRandomRoleName("juju") hostname := roleName password := gwacl.MakeRandomPassword() os, err := series.GetOSFromSeries(ser) if err != nil { return nil, errors.Trace(err) } // Generate a Network Configuration with the initially required ports open. networkConfigurationSet := gwacl.NewNetworkConfigurationSet(env.getInitialEndpoints(stateServer), nil) var role *gwacl.Role switch os { case jujuos.Windows: role, err = makeWindowsRole(password, roleSize, roleName, userdata, vhd, networkConfigurationSet, snapshot) default: role, err = makeLinuxRole(hostname, password, roleSize, roleName, userdata, vhd, networkConfigurationSet) } if err != nil { return nil, errors.Trace(err) } role.AvailabilitySetName = "juju" return role, nil }
// newRole creates a gwacl.Role object (an Azure Virtual Machine) which uses // the given Virtual Hard Drive. // // The VM will have: // - an 'ubuntu' user defined with an unguessable (randomly generated) password // - its ssh port (TCP 22) open // (if a state server) // - its state port (TCP mongoDB) port open // - its API port (TCP) open // // roleSize is the name of one of Azure's machine types, e.g. ExtraSmall, // Large, A6 etc. func (env *azureEnviron) newRole(roleSize string, vhd *gwacl.OSVirtualHardDisk, userData string, stateServer bool) *gwacl.Role { roleName := gwacl.MakeRandomRoleName("juju") // Create a Linux Configuration with the username and the password // empty and disable SSH with password authentication. hostname := roleName username := "******" password := gwacl.MakeRandomPassword() linuxConfigurationSet := gwacl.NewLinuxProvisioningConfigurationSet(hostname, username, password, userData, "true") // Generate a Network Configuration with the initially required ports open. networkConfigurationSet := gwacl.NewNetworkConfigurationSet(env.getInitialEndpoints(stateServer), nil) role := gwacl.NewRole( roleSize, roleName, vhd, []gwacl.ConfigurationSet{*linuxConfigurationSet, *networkConfigurationSet}, ) role.AvailabilitySetName = "juju" return role }
// newRole creates a gwacl.Role object (an Azure Virtual Machine) which uses // the given Virtual Hard Drive. // // The VM will have: // - an 'ubuntu' user defined with an unguessable (randomly generated) password // - its ssh port (TCP 22) open // - its state port (TCP mongoDB) port open // - its API port (TCP) open // // roleSize is the name of one of Azure's machine types, e.g. ExtraSmall, // Large, A6 etc. func (env *azureEnviron) newRole(roleSize string, vhd *gwacl.OSVirtualHardDisk, userData string, roleHostname string) *gwacl.Role { // Create a Linux Configuration with the username and the password // empty and disable SSH with password authentication. hostname := roleHostname username := "******" password := gwacl.MakeRandomPassword() linuxConfigurationSet := gwacl.NewLinuxProvisioningConfigurationSet(hostname, username, password, userData, "true") // Generate a Network Configuration with the initially required ports // open. networkConfigurationSet := gwacl.NewNetworkConfigurationSet(env.getInitialEndpoints(), nil) roleName := gwacl.MakeRandomRoleName("juju") // The ordering of these configuration sets is significant for the tests. return gwacl.NewRole( roleSize, roleName, []gwacl.ConfigurationSet{*linuxConfigurationSet, *networkConfigurationSet}, []gwacl.OSVirtualHardDisk{*vhd}) }
// newRole creates a gwacl.Role object (an Azure Virtual Machine) which uses // the given Virtual Hard Drive. // The VM will have: // - an 'ubuntu' user defined with an unguessable (randomly generated) password // - its ssh port (TCP 22) open // - its state port (TCP mongoDB) port open // - its API port (TCP) open func (env *azureEnviron) newRole(vhd *gwacl.OSVirtualHardDisk, userData string, roleHostname string) *gwacl.Role { // TODO: Derive the role size from the constraints. // ExtraSmall|Small|Medium|Large|ExtraLarge roleSize := "Small" // Create a Linux Configuration with the username and the password // empty and disable SSH with password authentication. hostname := roleHostname username := "******" password := gwacl.MakeRandomPassword() linuxConfigurationSet := gwacl.NewLinuxProvisioningConfigurationSet(hostname, username, password, userData, "true") config := env.Config() // Generate a Network Configuration with the initially required ports // open. networkConfigurationSet := gwacl.NewNetworkConfigurationSet([]gwacl.InputEndpoint{ { LocalPort: 22, Name: "sshport", Port: 22, Protocol: "TCP", }, // TODO: Ought to have this only for state servers. { LocalPort: config.StatePort(), Name: "stateport", Port: config.StatePort(), Protocol: "TCP", }, // TODO: Ought to have this only for API servers. { LocalPort: config.APIPort(), Name: "apiport", Port: config.APIPort(), Protocol: "TCP", }, }, nil) roleName := gwacl.MakeRandomRoleName("juju") // The ordering of these configuration sets is significant for the tests. return gwacl.NewRole( roleSize, roleName, []gwacl.ConfigurationSet{*linuxConfigurationSet, *networkConfigurationSet}, []gwacl.OSVirtualHardDisk{*vhd}) }