//deploy,only set deployment
func (this *CloudFoundryController) Deploy() {
	// reload data
	this.LoadData()

	cf.Release = entity.NewRelease(cloudFoundryName, cloudFoundryVersion)
	cf.Stemcells = entity.NewStemcell(stemcellName, stemcellVersion)

	//	templateText := ""
	if iaasVersion == defaultVersion {
		//		templateText = entity.CloudFoundryTemplateV3
		networks := cf.NetWorks
		publicNetWork := networks[utils.Net_Public]
		ipArr := utils.SpliteIPs(publicNetWork.StaticIp)
		cf.CloudFoundryProperties.FloatingIp = ipArr[0]
		//设置ip段的第一个ip为haproxy的浮动ip
	}
	//	else {
	//		templateText = entity.CloudFoundryTemplateV2
	//	}

	cloudFoundryTemplate := entity.NewCloudFoundryTemplate(cf)

	//	ok, err := cloudFoundryTemplate.CreateCloudFoundryYaml(templateText, cloudFoundryPath)

	ok, err := cloudFoundryTemplate.CreateDefaultCloudFoundryYamlFileWithAppPath(iaasVersion, cloudFoundryPath, beego.AppPath)
	if !ok {
		this.Data["Message"] = fmt.Sprintf("Error: %s", err)
	} else {
		this.Data["Message"] = fmt.Sprintf("Successful make deployment file: %s", cloudFoundryPath)
	}
}
func (this *CloudFoundryController) Post() {
	model := this.GetString("model")
	erros := make([]error, 0)
	switch model {
	case utils.CloudFoundryProperties:
		cloudFoundryProperties = entity.NewCloudFoundryProperties(
			this.GetString("name"),
			this.GetString("uuid"),
			this.GetString("floatingIp"),
			this.GetString("systemDomain"),
			this.GetString("systemDomainOrg"))

		id, err := this.GetInt64("id", 0)
		if err == nil {
			cloudFoundryProperties.Id = id
		}
		this.CommitData(cloudFoundryProperties)
	case utils.NetWorks:
		iaas := this.GetString("iaasVsersion")
		// use default MicroBOSH vip
		privateNetWorks = entity.NewNetWorks(this.GetString("private-name"),
			this.GetString("private-netWorkName"),
			this.GetString("private-netType"),
			this.GetString("private-netId"),
			this.GetString("private-cidr"),
			this.GetString("private-dns"),
			mi.NetWork.Vip,
			this.GetString("private-reservedIp"),
			this.GetString("private-staticIp"))
		//rebuild
		netWorksMap = make(map[string]entity.NetWorks)
		netWorksMap[utils.Net_Private] = privateNetWorks

		if iaas == defaultVersion {
			publicNetWorks = entity.NewNetWorks(this.GetString("public-name"),
				this.GetString("public-netWorkName"),
				this.GetString("public-netType"),
				this.GetString("public-netId"),
				this.GetString("public-cidr"),
				"",
				"",
				"",
				this.GetString("public-staticIp"))
		} else {
			publicNetWorks = entity.NewFloatingNetWork(cf.CloudFoundryProperties.FloatingIp)
		}
		netWorksMap[utils.Net_Public] = publicNetWorks

		compilation = cf.Compilation
		compilation.DefaultNetWork = privateNetWorks.Name
		this.CommitData(compilation)

		for key, _ := range resourcesPoolsMap {
			resourcesPoolsMap[key].DefaultNetWork = privateNetWorks.Name
		}

		this.CommitData(resourcesPoolsMap)
		this.CommitData(netWorksMap)
	case utils.Compilation:
		workers, _ := this.GetInt("workers", 6)
		if workers <= 0 {
			workers = 6
		}
		compilation = entity.NewCompilation(this.GetString("instanceType"),
			this.GetString("availabilityZone"),
			workers,
			this.GetString("defaultNetWork"))

		id, err := this.GetInt64("id", 0)
		if err == nil {
			compilation.Id = id
		}
		this.CommitData(compilation)
	case utils.ResourcesPools:
		arrName := this.GetStrings("name")
		arrInstanceType := this.GetStrings("instanceType")
		arrAvailabilityZone := this.GetStrings("availabilityZone")
		arrDefaultNetWork := this.GetStrings("defaultNetWork")
		arrSize := this.GetStrings("size")

		resourcesPoolsMap = make([]entity.ResourcesPools, 0)

		for index, value := range arrName {
			size, _ := strconv.Atoi(arrSize[index])

			if size <= 0 {
				size = 1
			}

			addResourcesPool := entity.NewResourcesPools(value,
				arrInstanceType[index],
				arrAvailabilityZone[index],
				arrDefaultNetWork[index],
				size,
			)

			if index == 0 {
				resourcesPool = addResourcesPool
			}
			resourcesPoolsMap = append(resourcesPoolsMap, addResourcesPool)
		}
		this.CommitData(resourcesPoolsMap)
	case utils.CloudFoundryJobs:
		iPFactory := utils.NewIPFactory()
		ipArr := utils.SpliteIPs(privateNetWorks.StaticIp)

		success, iperr := iPFactory.InitFactory(ipArr[0], ipArr[1])

		if iperr != nil {
			erros = append(erros, iperr)
		}
		for key, value := range cloudFoundryJobsMap {
			value.Name = this.GetString(key + "_name")
			instance, _ := this.GetInt(key+"_instances", 1)
			if instance <= 0 {
				instance = 1
			}
			value.ResourcesPool = this.GetString(key + "_resourcesPool_select")
			if success {
				assignaIP, assignaerr := iPFactory.AssignaIP2Job(key, instance)
				if assignaerr == nil {
					value.StaticIp = assignaIP
					value.Instances = instance
				} else {
					erros = append(erros, fmt.Errorf("Assign IP for Job : %s , Errors: %s", key, assignaerr))
				}
			}
			cloudFoundryJobsMap[key] = value
		}
		this.CommitData(cloudFoundryJobsMap)

		for index, value := range resourcesPoolsMap {
			poolsize := 0
			for _, v := range cloudFoundryJobsMap {
				if value.Name == v.ResourcesPool {
					poolsize = poolsize + 1*v.Instances //fixed instance sum
				}
			}
			value.Size = poolsize
			resourcesPoolsMap[index] = value
		}
		this.CommitData(resourcesPoolsMap)

	case utils.Properties:
		property := properties.JobProperties
		for key, val := range property {
			val.Name = key
			val.Value = this.GetString(key)
			property[key] = val
		}
		properties.JobProperties = property
		this.CommitData(properties)

	default:
		erros = append(erros, fmt.Errorf("Unknow model %s", model))
	}

	if len(erros) != 0 {
		this.Data["MessageErr"] = fmt.Sprintf("Errors: %s", erros)
	}
	this.Get()
}
		iPFactory.InitFactory("192.168.1.1", "192.168.1.20")

		fmt.Println("iiiiiiiiiiiiiiiiii")
		fmt.Printf("%s", iPFactory.GetAssignaIP4Job(utils.Job_Cloud_Controller_Clock))
		fmt.Println()
		abs, e := iPFactory.AssignaIP2Job(utils.Job_Cloud_Controller_Clock, 2)
		fmt.Printf("AssignaIP %s , %s", abs, e)
		fmt.Println()
		fmt.Printf("%s", iPFactory.GetAssignaIP4Job(utils.Job_Cloud_Controller_Clock))
		fmt.Println()

		iPFactory.AssignaIP2Job(utils.Job_Cloud_Controller_Clock, 3)

		fmt.Printf("%s", iPFactory.GetAssignaIP4Job(utils.Job_Cloud_Controller_Clock))
		fmt.Println()

		iPFactory.AssignaIP2Job(utils.Job_Cloud_Controller_Clock, 1)

		fmt.Printf("%s", iPFactory.GetAssignaIP4Job(utils.Job_Cloud_Controller_Clock))
		fmt.Println()
	})
	It("splite", func() {

		str := utils.SpliteIPs("192.168.129.100 - 192.168.129.126")
		fmt.Println(str)
		for _, i := range str {
			fmt.Println(i)
		}
	})
})