|
@@ -6,12 +6,14 @@ import (
|
|
"unicode"
|
|
"unicode"
|
|
|
|
|
|
"devel.mephi.ru/dyokunev/go-sdapi/sdApi1"
|
|
"devel.mephi.ru/dyokunev/go-sdapi/sdApi1"
|
|
|
|
+ "devel.mephi.ru/dyokunev/go-sdapi/sdApi11"
|
|
"github.com/alyu/configparser"
|
|
"github.com/alyu/configparser"
|
|
"github.com/gophercloud/gophercloud"
|
|
"github.com/gophercloud/gophercloud"
|
|
"github.com/gophercloud/gophercloud/openstack"
|
|
"github.com/gophercloud/gophercloud/openstack"
|
|
"github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
|
|
"github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
|
|
|
|
|
|
- models "devel.mephi.ru/dyokunev/go-asu-models"
|
|
|
|
|
|
+ asuModels "devel.mephi.ru/dyokunev/go-asu-models"
|
|
|
|
+ api11Models "devel.mephi.ru/dyokunev/go-sd-models/api11"
|
|
)
|
|
)
|
|
|
|
|
|
// H E L P E R S
|
|
// H E L P E R S
|
|
@@ -103,7 +105,7 @@ func (osclient OpenstackIdentityClient) getProjectsMap() map[int]projects.Projec
|
|
return projectsToMap(allProjects)
|
|
return projectsToMap(allProjects)
|
|
}
|
|
}
|
|
|
|
|
|
-func makeUpdateOpts(unit models.Unit, domainID string) projects.UpdateOpts {
|
|
|
|
|
|
+func makeUpdateOpts(unit asuModels.Unit, domainID string) projects.UpdateOpts {
|
|
updateOpts := projects.UpdateOpts{
|
|
updateOpts := projects.UpdateOpts{
|
|
DomainID: domainID,
|
|
DomainID: domainID,
|
|
Enabled: pointerFromBool(true),
|
|
Enabled: pointerFromBool(true),
|
|
@@ -117,7 +119,7 @@ func makeUpdateOpts(unit models.Unit, domainID string) projects.UpdateOpts {
|
|
return updateOpts
|
|
return updateOpts
|
|
}
|
|
}
|
|
|
|
|
|
-func makeCreateOpts(unit models.Unit, domainID string) projects.CreateOpts {
|
|
|
|
|
|
+func makeCreateOpts(unit asuModels.Unit, domainID string) projects.CreateOpts {
|
|
createOpts := projects.CreateOpts{
|
|
createOpts := projects.CreateOpts{
|
|
DomainID: domainID,
|
|
DomainID: domainID,
|
|
Enabled: pointerFromBool(true),
|
|
Enabled: pointerFromBool(true),
|
|
@@ -134,11 +136,11 @@ func makeCreateOpts(unit models.Unit, domainID string) projects.CreateOpts {
|
|
|
|
|
|
// U N I T S
|
|
// U N I T S
|
|
|
|
|
|
-func getAllUnits(config *configparser.Configuration) models.Units {
|
|
|
|
|
|
+func getAllUnits(config *configparser.Configuration) asuModels.Units {
|
|
section, err := config.Section("sd.mephi.ru")
|
|
section, err := config.Section("sd.mephi.ru")
|
|
checkErr(err)
|
|
checkErr(err)
|
|
|
|
|
|
- sdApi1.SetApiKey(section.ValueOf("api_key"))
|
|
|
|
|
|
+ sdApi1.SetApiKey(section.ValueOf("api1_key"))
|
|
|
|
|
|
allUnits, err := sdApi1.GetUnits()
|
|
allUnits, err := sdApi1.GetUnits()
|
|
checkErr(err)
|
|
checkErr(err)
|
|
@@ -146,10 +148,11 @@ func getAllUnits(config *configparser.Configuration) models.Units {
|
|
return allUnits
|
|
return allUnits
|
|
}
|
|
}
|
|
|
|
|
|
-func getCleanUnitsMap(config *configparser.Configuration) map[int]models.Unit {
|
|
|
|
|
|
+// Map of persNumber to Unit
|
|
|
|
+func getCleanUnitsMap(config *configparser.Configuration) map[int]asuModels.Unit {
|
|
allUnits := getAllUnits(config)
|
|
allUnits := getAllUnits(config)
|
|
idToPersNum := map[int]int{}
|
|
idToPersNum := map[int]int{}
|
|
- cleanUnits := map[int]models.Unit{}
|
|
|
|
|
|
+ cleanUnits := map[int]asuModels.Unit{}
|
|
|
|
|
|
// Get all not nil units without duplicates
|
|
// Get all not nil units without duplicates
|
|
for _, unit := range allUnits {
|
|
for _, unit := range allUnits {
|
|
@@ -183,7 +186,7 @@ func getCleanUnitsMap(config *configparser.Configuration) map[int]models.Unit {
|
|
return cleanUnits
|
|
return cleanUnits
|
|
}
|
|
}
|
|
|
|
|
|
-func newestUnit(unit1 models.Unit, unit2 models.Unit) models.Unit {
|
|
|
|
|
|
+func newestUnit(unit1 asuModels.Unit, unit2 asuModels.Unit) asuModels.Unit {
|
|
if unit1.CreateOrderDate != nil && unit2.CreateOrderDate != nil {
|
|
if unit1.CreateOrderDate != nil && unit2.CreateOrderDate != nil {
|
|
if unit1.CreateOrderDate.Unix() > unit2.CreateOrderDate.Unix() {
|
|
if unit1.CreateOrderDate.Unix() > unit2.CreateOrderDate.Unix() {
|
|
return unit1
|
|
return unit1
|
|
@@ -193,3 +196,17 @@ func newestUnit(unit1 models.Unit, unit2 models.Unit) models.Unit {
|
|
return unit1
|
|
return unit1
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// P E O P L E
|
|
|
|
+
|
|
|
|
+func getPeople(config *configparser.Configuration) api11Models.People {
|
|
|
|
+ section, err := config.Section("sd.mephi.ru")
|
|
|
|
+ checkErr(err)
|
|
|
|
+
|
|
|
|
+ sdApi11.SetApiKey(section.ValueOf("api11_key"))
|
|
|
|
+
|
|
|
|
+ people, err := sdApi11.GetPeople()
|
|
|
|
+ checkErr(err)
|
|
|
|
+
|
|
|
|
+ return people
|
|
|
|
+}
|