//New -- method to generate an initialized elastic runtime
func (s *ElasticRuntimeBuilder) New(tileSpec tileregistry.TileSpec) (elasticRuntime tileregistry.Tile, err error) {
	var (
		installationSettings io.Reader
		installationTmpFile  *os.File
		sshKey               = ""
	)

	if installationSettings, err = GetInstallationSettings(tileSpec); err == nil {
		installationTmpFile, err = ioutil.TempFile("", opsmanager.OpsMgrInstallationSettingsFilename)
		defer installationTmpFile.Close()
		io.Copy(installationTmpFile, installationSettings)
		config := cfbackup.NewConfigurationParser(installationTmpFile.Name())

		if iaas, hasKey := config.GetIaaS(); hasKey {
			sshKey = iaas.SSHPrivateKey
		}
		elasticRuntime = NewElasticRuntime(installationTmpFile.Name(), tileSpec.ArchiveDirectory, sshKey)
	}
	return
}
func testInstallationSettings(installationSettingsPath string) {
	var mysqlplugin *MysqlPlugin
	Describe(fmt.Sprintf("given a installationSettingsFile %s", installationSettingsPath), func() {
		Describe("given a Backup() method", func() {
			Context("when called on a properly setup mysqlplugin object", func() {
				var err error
				fakePersistenceBackup := new(FakePersistenceBackup)
				var controlTmpDir string
				BeforeEach(func() {
					controlTmpDir, _ = ioutil.TempDir("", "unit-test")
					mysqlplugin = &MysqlPlugin{
						Meta: cfopsplugin.Meta{
							Name: "mysql-tile",
						},
						GetPersistanceBackup: func(user, pass string, config command.SshConfig) (pb cfbackup.PersistanceBackup, err error) {
							return fakePersistenceBackup, nil
						},
						GetPrivilegeFlusher: func(config command.SshConfig, pwd string) (err error) {
							return
						},
					}
					configParser := cfbackup.NewConfigurationParser(installationSettingsPath)
					pivotalCF := cfopsplugin.NewPivotalCF(configParser.InstallationSettings, tileregistry.TileSpec{
						ArchiveDirectory: controlTmpDir,
					})
					mysqlplugin.Setup(pivotalCF)
					err = mysqlplugin.Backup()
				})

				AfterEach(func() {
					os.RemoveAll(controlTmpDir)
				})

				It("then it should dump the target mysql contents", func() {
					Ω(err).ShouldNot(HaveOccurred())
					Ω(fakePersistenceBackup.DumpCallCount).Should(Equal(1))
				})

				It("then it should create an archive file", func() {
					Ω(err).ShouldNot(HaveOccurred())
					Ω(IsEmpty(controlTmpDir)).ShouldNot(BeTrue())
				})
			})
		})

		Describe("given a Setup() method", func() {
			Context("when called with a PivotalCF containing a MySQL tile", func() {
				var pivotalCF cfopsplugin.PivotalCF
				BeforeEach(func() {
					configParser := cfbackup.NewConfigurationParser(installationSettingsPath)
					pivotalCF = cfopsplugin.NewPivotalCF(configParser.InstallationSettings, tileregistry.TileSpec{})
					mysqlplugin.Setup(pivotalCF)
				})

				It("then it should extract Mysql username required for backup/restore", func() {
					Ω(mysqlplugin.PivotalCF).ShouldNot(BeNil())
				})

			})
		})
	})
}