Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Correction in the schema (#99)
Browse files Browse the repository at this point in the history
Signed-off-by: Prativa Bawri <[email protected]>
  • Loading branch information
Prativa20 authored and Vijay Raghavan committed Oct 27, 2018
1 parent 3512b26 commit bdbd53c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 9 additions & 2 deletions vrealize/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func updateResource(d *schema.ResourceData, meta interface{}) error {
log.Errorf("Error while reading resource actions for the request %v: %v ", catalogItemRequestID, err.Error())
return fmt.Errorf("Error while reading resource actions for the request %v: %v ", catalogItemRequestID, err.Error())
}
if apiError != nil {
if apiError != nil && !apiError.isEmpty() {
log.Errorf("Error while reading resource actions for the request %v: %v ", catalogItemRequestID, apiError.Errors)
return fmt.Errorf("Error while reading resource actions for the request %v: %v ", catalogItemRequestID, apiError.Errors)
}
Expand Down Expand Up @@ -225,11 +225,17 @@ func updateResource(d *schema.ResourceData, meta interface{}) error {
for _, entry := range entries {
if entry.Key == utils.COMPONENT {
entryValue := entry.Value
componentName := entryValue.Value.(string)
var componentName string
for k, v := range entryValue {
if k == "value" {
componentName = v.(string)
}
}
resourceActionTemplate := new(ResourceActionTemplate)
apiError := new(APIError)
log.Info("Retrieving reconfigure action template for the component: %v ", componentName)
getActionTemplatePath := fmt.Sprintf(utils.GET_ACTION_TEMPLATE_API, resources.Id, reconfigureActionId)
log.Info("Call GET to fetch the reconfigure action template %v ", getActionTemplatePath)
response, err := vRAClient.HTTPClient.New().Get(getActionTemplatePath).
Receive(resourceActionTemplate, apiError)
response.Close = true
Expand Down Expand Up @@ -335,6 +341,7 @@ func readResource(d *schema.ResourceData, meta interface{}) error {
for _, resource := range requestResourceView.Content {
if resource.ResourceType == utils.INFRASTRUCTURE_VIRTUAL {
resourceData := resource.ResourcesData
log.Info("The resource data map of the resource %v is: \n%v", resourceData.Component, resource.ResourcesData)
dataVals := make(map[string]interface{})
resourceDataMap[resourceData.Component] = dataVals
dataVals[utils.MACHINE_CPU] = resourceData.Cpu
Expand Down
10 changes: 3 additions & 7 deletions vrealize/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ type DeploymentResourceData struct {
// Retrieves the resources that were provisioned as a result of a given request.
// Also returns the actions allowed on the resources and their templates
type ResourceActions struct {
Links []string `json:"links,omitempty"`
Links []interface{} `json:"links,omitempty"`
Content []ResourceActionContent `json:"content,omitempty"`
}

Expand All @@ -121,20 +121,16 @@ type ResourceTypeRef struct {
type Operation struct {
Name string `json:"name,omitempty"`
OperationId string `json:"id,omitempty"`
Description string `json:"description,omitempty"`
Type string `json:"type,omitempty"`
BindingId string `json:"bindingId,omitempty"`
}

type ResourceDataMap struct {
Entries []ResourceDataEntry `json:"entries,omitempty"`
}
type ResourceDataEntry struct {
Key string `json:"key,omitempty"`
Value ResourceDataEntryValue `json:"value,omitempty"`
}
type ResourceDataEntryValue struct {
Type string `json:"type,omitempty"`
Value interface{} `json:"value,omitempty"`
Value map[string]interface{} `json:"value,omitempty"`
}

//CatalogRequest - A structure that captures a vRA catalog request.
Expand Down

0 comments on commit bdbd53c

Please sign in to comment.