Change-Id: If4b2675e14a33901862b54a55c0950a7275aa62d
// Creates database
func (adapter *DbAdapter) CreateDatabase() {
// Creates database
func (adapter *DbAdapter) CreateDatabase() {
- adapter.logger.Info("creating Database...")
+ adapter.logger.Infof("creating Database...")
usrpswd := os.Getenv("MYSQL_USER") + ":" + os.Getenv("MYSQL_PASSWORD")
host := "@tcp(" + "dbhost" + ":3306)/"
usrpswd := os.Getenv("MYSQL_USER") + ":" + os.Getenv("MYSQL_PASSWORD")
host := "@tcp(" + "dbhost" + ":3306)/"
db.Exec("USE applcmDB")
gorm.DefaultCallback.Create().Remove("mysql:set_identity_insert")
db.Exec("USE applcmDB")
gorm.DefaultCallback.Create().Remove("mysql:set_identity_insert")
- adapter.logger.Info("Migrating models...")
+ adapter.logger.Infof("Migrating models...")
db.AutoMigrate(&model.AppPackageInfo{})
db.AutoMigrate(&model.AppInstanceInfo{})
adapter.db = db
db.AutoMigrate(&model.AppPackageInfo{})
db.AutoMigrate(&model.AppInstanceInfo{})
adapter.db = db
}
// Instantiate application
}
// Instantiate application
-func (c *PluginAdapter) Instantiate(pluginInfo string, host string, deployArtifact string) (workloadId string, error error) {
- c.logger.Info("Instantation started")
- clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate}
+func (c *PluginAdapter) Instantiate(pluginInfo string, host string, deployArtifact string) (workloadId string, error error, status string) {
+ c.logger.Infof("Instantation started")
+ clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate, Logger: c.logger}
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
c.logger.Errorf("failed to create client: %v", err)
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
c.logger.Errorf("failed to create client: %v", err)
+ return "", err, "Failure"
}
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
//Instantiate
}
ctx, cancel := context.WithTimeout(context.Background(), 50*time.Second)
defer cancel()
//Instantiate
- workloadId, status, err := client.Instantiate(ctx, deployArtifact, host)
+ workloadId, status, err = client.Instantiate(ctx, deployArtifact, host)
if err != nil {
c.logger.Errorf("server failed to respond %s", err.Error())
if err != nil {
c.logger.Errorf("server failed to respond %s", err.Error())
+ return "", err, "Failure"
- c.logger.Info("Instantiation success with workloadId %s, status: %s ", workloadId, status)
- return workloadId, nil
+ c.logger.Infof("Instantiation completed with workloadId %s, status: %s ", workloadId, status)
+ return workloadId, nil, status
}
// Query application
func (c *PluginAdapter) Query(pluginInfo string, host string, workloadId string) (status string, error error) {
}
// Query application
func (c *PluginAdapter) Query(pluginInfo string, host string, workloadId string) (status string, error error) {
- c.logger.Info("Query started")
+ c.logger.Infof("Query started")
clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate}
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate}
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
c.logger.Errorf("failed to query: %v", err)
return "", err
}
c.logger.Errorf("failed to query: %v", err)
return "", err
}
- c.logger.Info("query status: ", status)
+ c.logger.Infof("query status: ", status)
return status, nil
}
// Terminate application
func (c *PluginAdapter) Terminate(pluginInfo string, host string, workloadId string) (status string, error error) {
return status, nil
}
// Terminate application
func (c *PluginAdapter) Terminate(pluginInfo string, host string, workloadId string) (status string, error error) {
- c.logger.Info("Terminate started")
+ c.logger.Infof("Terminate started")
clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate}
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
clientConfig := plugin.ClientGRPCConfig{Address: pluginInfo, ChunkSize: chunkSize, RootCertificate: rootCertificate}
var client, err = plugin.NewClientGRPC(clientConfig)
if err != nil {
- c.logger.Info("termination success with status: ", status)
+ c.logger.Infof("termination success with status: ", status)
// Run on it's router
func (hdlr *Handlers) Run(host string) {
// Run on it's router
func (hdlr *Handlers) Run(host string) {
- hdlr.logger.Info("Server is running on port %s", host)
+ hdlr.logger.Infof("Server is running on port %s", host)
err := http.ListenAndServe(host, hdlr.router)
if err != nil {
hdlr.logger.Fatalf("Server couldn't run on port %s", host)
err := http.ListenAndServe(host, hdlr.router)
if err != nil {
hdlr.logger.Fatalf("Server couldn't run on port %s", host)
return
}
pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
return
}
pluginInfo = "helm.plugin" + ":" + os.Getenv("HELM_PLUGIN_PORT")
+ impl.logger.Infof("Plugin Info ", pluginInfo)
case "kubernetes":
pkgPath := PackageFolderPath + packageName + PackageArtifactPath + "Kubernetes"
artifact = impl.getDeploymentArtifact(pkgPath, "*.yaml")
case "kubernetes":
pkgPath := PackageFolderPath + packageName + PackageArtifactPath + "Kubernetes"
artifact = impl.getDeploymentArtifact(pkgPath, "*.yaml")
impl.logger.Infof("Artifact to deploy:", artifact)
adapter := pluginAdapter.NewPluginAdapter(pluginInfo, impl.logger)
impl.logger.Infof("Artifact to deploy:", artifact)
adapter := pluginAdapter.NewPluginAdapter(pluginInfo, impl.logger)
- workloadId, err := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact)
+ workloadId, err, resStatus := adapter.Instantiate(pluginInfo, req.SelectedMECHostInfo.HostID, artifact)
if err != nil {
st, ok := status.FromError(err)
if ok && st.Code() == codes.InvalidArgument {
if err != nil {
st, ok := status.FromError(err)
if ok && st.Code() == codes.InvalidArgument {
respondError(w, http.StatusInternalServerError, err.Error())
}
}
respondError(w, http.StatusInternalServerError, err.Error())
}
}
- impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId)
- respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode(""))
+ if resStatus == "Failure" {
+ respondError(w, http.StatusInternalServerError, err.Error())
+ }
+
+ impl.dbAdapter.UpdateAppInstanceInfoInstStatusHostAndWorkloadId(appInstanceId, "INSTANTIATED", req.SelectedMECHostInfo.HostID, workloadId)
+ respondJSON(w, http.StatusAccepted, json.NewEncoder(w).Encode(workloadId))
}
// Gets deployment artifact
}
// Gets deployment artifact
- c.logger.Info("deployArtifact: ", deployArtifact)
+ c.logger.Infof("deployArtifact: ", deployArtifact)
// Get a file handle for the file we
// want to upload
// Get a file handle for the file we
// want to upload
c.logger.Errorf("failed to receive upstream status response: ", err)
return "","Failure", err
}
c.logger.Errorf("failed to receive upstream status response: ", err)
return "","Failure", err
}
- c.logger.Info("Instantiation Completed")
- return res.WorkloadId, res.Status, err
+ c.logger.Infof("Instantiation Completed with workloadId %s and status", res.GetWorkloadId(), res.GetStatus())
+ return res.GetWorkloadId(), res.GetStatus(), err
FullTimestamp: true,
})
logger.SetLevel(loggerLevel)
FullTimestamp: true,
})
logger.SetLevel(loggerLevel)
- logger.Info("logger created")
+ logger.Infof("logger created")
return logger
}
\ No newline at end of file
return logger
}
\ No newline at end of file
}
hostIP := req.GetHostIp()
}
hostIP := req.GetHostIp()
- s.logger.Info("Recieved instantiate request")
+ s.logger.Infof("Recieved instantiate request")
// Host validation
if (hostIP == "") {
// Host validation
if (hostIP == "") {
// Receive chunk and write to helm package
chunk := req.GetPackage()
// Receive chunk and write to helm package
chunk := req.GetPackage()
- s.logger.Info("Recieved chunk")
+ s.logger.Infof("Recieved chunk")
_, err = helmPkg.Write(chunk)
if err != nil {
_, err = helmPkg.Write(chunk)
if err != nil {
if (err != nil) {
res.Status = "Failure"
if (err != nil) {
res.Status = "Failure"
+ s.logger.Infof("Instantiation Failed")
} else {
res.Status = "Success"
} else {
res.Status = "Success"
+ s.logger.Infof("Successful Instantiation")
}
err = stream.SendAndClose(&res)
if err != nil {
return s.logError(status.Errorf(codes.Unknown, "cannot send response: %v", err))
}
}
err = stream.SendAndClose(&res)
if err != nil {
return s.logError(status.Errorf(codes.Unknown, "cannot send response: %v", err))
}
- s.logger.Info("Successful Instantiation")
hc.logger.Errorf("Unable to install chart with release name: %s. Err: %s", relName, err)
return "", err
}
hc.logger.Errorf("Unable to install chart with release name: %s. Err: %s", relName, err)
return "", err
}
- hc.logger.Info("Successfully create chart with release name: %s", relName)
+ hc.logger.Infof("Successfully create chart with release name: %s", relName)
hc.logger.Errorf("Unable to uninstall chart with release name: %s. Err: %s", relName, err)
return err
}
hc.logger.Errorf("Unable to uninstall chart with release name: %s. Err: %s", relName, err)
return err
}
- hc.logger.Info("Successfully uninstalled chart with release name: %s. Response Info: %s", res.Release.Name, res.Info)
+ hc.logger.Infof("Successfully uninstalled chart with release name: %s. Response Info: %s", res.Release.Name, res.Info)
FullTimestamp: true,
})
logger.SetLevel(loggerLevel)
FullTimestamp: true,
})
logger.SetLevel(loggerLevel)
- logger.Info("logger created")
+ logger.Infof("logger created")
return logger
}
\ No newline at end of file
return logger
}
\ No newline at end of file
cd ../broker
. docker-build.sh
cd ../broker
. docker-build.sh
#helmplugin compile and build docker image
cd ../k8shelm
. docker-build.sh
#helmplugin compile and build docker image
cd ../k8shelm
. docker-build.sh