Friday, February 10, 2012

How to Change the User owner for a VM Instance. #cloudstack

How to Change the User owner for a VM Instance.:

this tips will be useful especially in the test and evaluation stage from a CloudStack project.


ok, here we go!


The resource_count table contains the quantity of user_vm, public_ip, volume, snapshot, template and the first acction is add the user_vm and volumes to another account, here's a example.



mysql> select * from resource_count where account_id = 22;
+-------+-------------+--------------+----------------+--------+
| id | account_id | domain_id | type |count |
+-------+-------------+--------------+----------------+--------+
| 151 | 22 | NULL | user_vm | 1 |
| 152 | 22 | NULL | public_ip | 0 |
| 153 | 22 | NULL | volume | 2 |
| 154 | 22 | NULL | snapshot | 0 |
| 155 | 22 | NULL | template | 0 |


+-------+-------------+--------------+----------------+--------+
5 rows in set (0.00 sec)


mysql> select * from resource_count where account_id = 5;
+----+-------------+----------------+----------------+-------+
| id | account_id | domain_id | type |count|
+-----+------------+----------------+----------------+-------+
| 36 | 5 | NULL | user_vm | 9 |
| 37 | 5 | NULL | public_ip | 0 |
| 38 | 5 | NULL | volume | 20 |
| 39 | 5 | NULL | snapshot | 1 |
| 40 | 5 | NULL | template | 0 |
+-----+------------+-----------------+------------------+-------+
5 rows in set (0.00 sec)



Now, add the user_vm to account_id = 22 to account_id = 5



mysql> update resource_count set user_vm = 10 where id = 36;



Then, subtract the user_vm to the account_id = 22



mysql> update resource_count set user_vm = 0 where id = 151;



and do the same with volume and snapshot ... but in this case don't have.



mysql> update resource_count set volume= 22 where id = 38;



and subtract...



mysql> update resource_count set volume= 0 where id = 153;




now we must move the security group;



for this we must have the name in the vm




mysql> select * from user_vm;




in this table we have to localize the name of the vm instance in the display_name and with this, get the id.



and with the id we do the update



for example:



mysql> update security_group_vm_map set security_group_id = 2 where instance_id = 32;





I hope this is useful.



No comments:

Post a Comment