Index: /branches/rel_apv_10_7_3/usr/click/bin/heartbeat/heartbeat.c
===================================================================
--- /branches/rel_apv_10_7_3/usr/click/bin/heartbeat/heartbeat.c	(revision 40281)
+++ /branches/rel_apv_10_7_3/usr/click/bin/heartbeat/heartbeat.c	(working copy)
@@ -576,6 +576,11 @@
 do_heartbeat()
 {
     int bandwidth_limit = 0;
+    int ram_limit = 0;
+    int cpu_limit = 0;
+    int found_bandwidth = 0;
+    int found_ram = 0;
+    int found_cpu = 0;
     time_t t;
     char versionBuffer[BUFFER_LEN] = {'\0'};
     char bandwidthBuffer[BUFFER_LEN] = {'\0'};
@@ -769,7 +774,33 @@
                         goto end;
                     }
                     resource_id = json_object_get_int(resource_id_obj);
-                    if (resource_id == 3) {
+                    if (resource_id == 1) {
+                        json_object *quantity_obj = json_object_object_get(resource_obj, "quantity");
+                        if (!quantity_obj) {
+                            logging("[heartbeat]Invalid response, no field 'quantity' for memory", 3);
+                            json_object_put(result);
+                            goto end;
+                        }
+                        ram_limit = json_object_get_int(quantity_obj);
+                        char ram_s[256];
+                        sprintf(ram_s, "[heartbeat]Get RAM limit successfully. The limitation is %d GB.", ram_limit);
+                        logging(ram_s, 1);
+                        found_ram = 1;
+                    } 
+                    else if (resource_id == 2) {
+                        json_object *quantity_obj = json_object_object_get(resource_obj, "quantity");
+                        if (!quantity_obj) {
+                            logging("[heartbeat]Invalid response, no field 'quantity' for CPU", 3);
+                            json_object_put(result);
+                            goto end;
+                        }
+                        cpu_limit = json_object_get_int(quantity_obj);
+                        char cpu_s[256];
+                        sprintf(cpu_s, "[heartbeat]Get CPU limit successfully. The limitation is %d Cores.", cpu_limit);
+                        logging(cpu_s, 1);
+                        found_cpu = 1;
+                    } 
+                    else if (resource_id == 3) {
                         json_object *quantity_obj = json_object_object_get(resource_obj, "quantity");
                         if (!quantity_obj) {
                             logging("[heartbeat]Invalid response, no field 'quantity'", 3);
@@ -780,11 +811,18 @@
                         char bw_s[256];
                         sprintf(bw_s, "[heartbeat]Get bandwidth limit successfully. The limitation is %d MB.", bandwidth_limit);
                         logging(bw_s, 1);
-                        break;
-                    } else {
-                        logging("[heartbeat]Failed to qeury the bandwidth limit because resource id is not 3.", 3);
+                        found_bandwidth = 1;
                     }
                 }
+                if (!found_bandwidth) {
+                    logging("[heartbeat]Failed to query the bandwidth limit because resource id 3 was not found.", 3);
+                }
+                if (!found_ram) {
+                    logging("[heartbeat]Failed to query the RAM limit because resource id 1 was not found.", 3);
+                }
+                if (!found_cpu) {
+                    logging("[heartbeat]Failed to query the CPU limit because resource id 2 was not found.", 3);
+                }
                 
                 // compare the lic from heartbeat with record heartbeat lic.
                 // They are different, update the heartbeat lic. Otherwise pass it.
@@ -793,8 +831,13 @@
                         logging("[heartbeat]Current device is enabled successfully and update license.", 1);
                         bandwidth_volume_update(bandwidth_limit);
                         feactl_p->max_vapv_bandwidth = bandwidth_limit * 1000000ULL;
-			char buf[32];
-			int len = snprintf(buf, sizeof(buf), "%llu\n", feactl_p->max_vapv_bandwidth);
+                        feactl_p->max_vapv_ram = ram_limit;
+                        feactl_p->max_vapv_cpus = cpu_limit;
+			char buf[128];
+			int len = snprintf(buf, sizeof(buf), "%llu\n%d\n%d\n", 
+				feactl_p->max_vapv_bandwidth, 
+				feactl_p->max_vapv_ram, 
+				feactl_p->max_vapv_cpus);
 			int fd = open("/ca/etc/bw_cm", O_WRONLY | O_CREAT | O_TRUNC, 0644);
 			if (fd != -1) {
 				write(fd, buf, len);
@@ -805,17 +848,26 @@
                         strncpy(heartbeat_info.license_key, license_key, LICENSE_KEY);
                         strncpy(heartbeat_info.cm_serial_number, cm_serial_number, CM_SN);
                         heartbeat_info.bandwidth_limit = bandwidth_limit;
+                        heartbeat_info.ram_limit = ram_limit;
+                        heartbeat_info.cpu_limit = cpu_limit;
                         heartbeat_info.device_manage_status = ENABLED;
                         heartbeat_info.heartbeat_time = t;
                         write_heartbeat_info(CM_INFO, &heartbeat_info);
                     } else {
                         logging("[heartbeat]Apply_license failed.", 3);
                     }
-                } else if (heartbeat_info.bandwidth_limit != bandwidth_limit) {
+                } else if (heartbeat_info.bandwidth_limit != bandwidth_limit  ||
+                        heartbeat_info.ram_limit != ram_limit || 
+                        heartbeat_info.cpu_limit != cpu_limit) {
                     bandwidth_volume_update(bandwidth_limit);
                     feactl_p->max_vapv_bandwidth = bandwidth_limit * 1000000ULL;
-		    char buf[32];
-		    int len = snprintf(buf, sizeof(buf), "%llu\n", feactl_p->max_vapv_bandwidth);
+                    feactl_p->max_vapv_ram = ram_limit;
+                    feactl_p->max_vapv_cpus = cpu_limit;
+		    char buf[128];
+		    int len = snprintf(buf, sizeof(buf), "%llu\n%d\n%d\n", 
+			    feactl_p->max_vapv_bandwidth, 
+			    feactl_p->max_vapv_ram, 
+			    feactl_p->max_vapv_cpus);
 		    int fd = open("/ca/etc/bw_cm", O_WRONLY | O_CREAT | O_TRUNC, 0644);
 		    if (fd != -1) {
 			    write(fd, buf, len);
@@ -823,6 +875,8 @@
 		    }
                     logging("[heartbeat]Just update bandwidth successfully.", 1);
                     heartbeat_info.bandwidth_limit = bandwidth_limit;
+                    heartbeat_info.ram_limit = ram_limit;
+                    heartbeat_info.cpu_limit = cpu_limit;
                     heartbeat_info.heartbeat_time = t;
                     write_heartbeat_info(CM_INFO, &heartbeat_info);
                 }
@@ -830,10 +884,17 @@
                 if (heartbeat_info.device_manage_status == ENABLED) {
                     disable_license(0);
                     heartbeat_info.bandwidth_limit = 1;
+                    heartbeat_info.ram_limit = 0;
+                    heartbeat_info.cpu_limit = 0;
                     bandwidth_volume_update(1);
                     feactl_p->max_vapv_bandwidth = 1 * 1000000;
+                    feactl_p->max_vapv_ram = 1; 
+                    feactl_p->max_vapv_cpus = 1;
 		    char buf[16];
-		    int len = snprintf(buf, sizeof(buf), "%d\n", feactl_p->max_vapv_bandwidth);
+                    int len = snprintf(buf, sizeof(buf), "%llu\n%d\n%d\n", 
+                                    feactl_p->max_vapv_bandwidth, 
+                                    feactl_p->max_vapv_ram, 
+                                    feactl_p->max_vapv_cpus);
 		    int fd = open("/ca/etc/bw_cm", O_WRONLY | O_CREAT | O_TRUNC, 0644);
 		    if (fd != -1) {
 			    write(fd, buf, len);
Index: /branches/rel_apv_10_7_3/usr/click/bin/vtch/vtch-guest.c
===================================================================
--- /branches/rel_apv_10_7_3/usr/click/bin/vtch/vtch-guest.c	(revision 40281)
+++ /branches/rel_apv_10_7_3/usr/click/bin/vtch/vtch-guest.c	(working copy)
@@ -357,9 +357,21 @@
 			    syslog(LOG_EMERG, "CMD_DEL_LICENSE : read bandwidth from file\n");
 			    FILE *f = fopen("/ca/etc/bw_cm", "r");
 			    if (f) {
-				fscanf(f, "%llu", &(feactl_p->max_vapv_bandwidth));
-				syslog(LOG_EMERG, "CMD_DEL_LICENSE : setting bandwidth to : %llu\n", feactl_p->max_vapv_bandwidth);
-				fclose(f);
+				unsigned long long parsed_bw = 0;
+				int parsed_ram = 0;
+				int parsed_cpu = 0;
+
+				// fscanf reads variables separated by spaces or newlines
+				int matches = fscanf(f, "%llu %d %d", &parsed_bw, &parsed_ram, &parsed_cpu);
+				// Check if we successfully read all 3 limits
+				if (matches == 3) {
+				    feactl_p->max_vapv_bandwidth = parsed_bw;
+				    feactl_p->max_vapv_ram = parsed_ram;
+				    feactl_p->max_vapv_cpus = parsed_cpu;
+				    syslog(LOG_EMERG, "CMD_DEL_LICENSE : setting bandwidth to : %llu, RAM to: %d GB, CPU to: %d Cores\n", 
+					    feactl_p->max_vapv_bandwidth, feactl_p->max_vapv_ram, feactl_p->max_vapv_cpus);
+				    fclose(f);
+				}
 			    }
 			}
 			syslog(LOG_USER | LOG_INFO, "Activation server enabled. Stop setting license as invalid.\n");
Index: /branches/rel_apv_10_7_3/usr/click/lib/libfeactl/feactl.c
===================================================================
--- /branches/rel_apv_10_7_3/usr/click/lib/libfeactl/feactl.c	(revision 40281)
+++ /branches/rel_apv_10_7_3/usr/click/lib/libfeactl/feactl.c	(working copy)
@@ -3184,18 +3184,29 @@
 			syslog(LOG_EMERG, "licensepermit is enabled.\n");
 			int fd = open("/ca/etc/bw_cm", O_RDONLY);
 			if (fd != -1) {
-				char buf[32];
+				char buf[128];
 				ssize_t bytes = read(fd, buf, sizeof(buf) - 1);
 				syslog(LOG_EMERG, "set_license_limits : read bandwidth from file\n");
 				if (bytes > 0) {
 					buf[bytes] = '\0';
-					feactl_p->max_vapv_bandwidth = atoll(buf);
-					syslog(LOG_EMERG, "set_license_limits : setting bandwidth to : %llu\n", feactl_p->max_vapv_bandwidth);
+					unsigned long long parsed_bw = 0;
+					int parsed_ram = 0;
+					int parsed_cpu = 0;
+					int matches = sscanf(buf, "%llu %d %d", &parsed_bw, &parsed_ram, &parsed_cpu);
+					// Check if we successfully read all 3 limits from the file
+					if (matches == 3) {
+						feactl_p->max_vapv_bandwidth = parsed_bw;
+						feactl_p->max_vapv_ram = parsed_ram;
+						feactl_p->max_vapv_cpus = parsed_cpu;
+						feactl_p->max_vapv_bandwidth = atoll(buf);
+						syslog(LOG_EMERG, "set_license_limits : setting bandwidth to : %llu, RAM to: %d GB, CPU to: %d Cores\n", 
+								feactl_p->max_vapv_bandwidth, feactl_p->max_vapv_ram, feactl_p->max_vapv_cpus);
+					}
 				}
 				close(fd);
 			}
 		} else {
-			syslog(LOG_EMERG, "set_license_limits : licensepermit not enabled. setting bandwidth to : %llu\n", feactl_p->max_vapv_bandwidth);
+			syslog(LOG_EMERG, "set_license_limits : licensepermit not enabled. setting bandwidth to : %llu, RAM to: %d GB, CPU to: %d Cores\n",  feactl_p->max_vapv_bandwidth, feactl_p->max_vapv_ram, feactl_p->max_vapv_cpus);
 		}
 	} else {
 		syslog(LOG_USER | LOG_INFO, "activation server not enabled");
