You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- update resourceCloudStackLimitsRead to handle different ID formats
- rewrite resourceCloudStackLimitsImport to handle different ID formats
- Support -1 (Unlimited) and 0 (zero) limits
log.Printf("[DEBUG] Importing resource with ID: %s", d.Id())
106
+
107
+
// First, extract the resource type which is always the first part
108
+
idParts:=strings.SplitN(d.Id(), "-", 2)
109
+
iflen(idParts) <2 {
110
+
returnnil, fmt.Errorf("unexpected import ID format (%q), expected type-account-accountname-domainid, type-domain-domainid, or type-project-projectid", d.Id())
111
+
}
112
+
113
+
// Parse the resource type
114
+
typeInt, err:=strconv.Atoi(idParts[0])
115
+
iferr!=nil {
116
+
returnnil, fmt.Errorf("invalid type value in import ID: %s", idParts[0])
117
+
}
118
+
119
+
// Find the string representation for this numeric type
120
+
vartypeStrstring
121
+
fork, v:=rangeresourceTypeMap {
122
+
ifv==typeInt {
123
+
typeStr=k
124
+
break
125
+
}
126
+
}
127
+
iftypeStr=="" {
128
+
returnnil, fmt.Errorf("unknown type value in import ID: %d", typeInt)
129
+
}
130
+
iferr:=d.Set("type", typeStr); err!=nil {
131
+
returnnil, err
132
+
}
133
+
134
+
// Get the original resource ID from the state
135
+
originalID:=d.Id()
136
+
log.Printf("[DEBUG] Original import ID: %s", originalID)
137
+
138
+
// Instead of trying to parse the complex ID, let's create a new resource
139
+
// and read it from the API to get the correct values
140
+
cs:=meta.(*cloudstack.CloudStackClient)
141
+
142
+
// Create a new parameter struct for listing resource limits
143
+
p:=cs.Limit.NewListResourceLimitsParams()
144
+
p.SetResourcetype(typeInt)
145
+
146
+
// Try to determine the resource scope from the ID format
0 commit comments