Dear Yas,
i get the following error when i was refreshing the page of instances for an openstack cloud .

Duplicate entry 'default-itsyn_openstack234' for key 'PRIMARY' query: INSERT INTO cloud_aws_security_groups ( `owner_id` , `cloud_type`, `group_name` , `group_id` , `group_description` , `permissions` ) values ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'Apache', '', 'Allow HTTP(S) access' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'ETrack', '', 'Allow Attendance devices traffic' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'OpenERP', '', 'Allow access to OpenERP Service' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'RDP', '', 'Allow RDP connections for Windows machines' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'VoIP', '', 'Allow VoIP traffic' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'default', '', 'default' , '') , ( '3584fb8c2c7c467abec414a6a9918919', 'itsyn_openstack234', 'new_group', '', 'this is a new one' , '') , ( '58fb8b48db5449548250c956fdb2184c', 'itsyn_openstack234', 'default', '', 'default' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'Apache', '', 'Allowing HTTP(S) access' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'ETrack', '', 'Allows Attendance devices traffic' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'OpenERP', '', 'Allow access to OpenERP' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'RDP', '', 'Enable RDP Connections for Windows Machines' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'VoIP', '', 'Allow VoIP Traffic' , '') , ( 'ab1b5021ea3b455fb69f2da0f3d0079b', 'itsyn_openstack234', 'default', '', 'default' , '') , ( 'cfba35763ac94bac9eea49558b660083', 'itsyn_openstack234', 'default', '', 'default' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'Apache', '', 'Allow HTTP(S) Access' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'Etrack', '', 'Allow IT Syn E-Track Traffic' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'MySQL', '', 'Allowing access to MySQL DBM' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'OpenERP', '', 'OpenERP' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'RDP', '', 'Enable RDP Connections for Windows Machines' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'VoIP', '', 'Allow VoIP Traffic' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'default', '', 'default' , '') , ( 'e85fa2a891564712b73b9af26a322fea', 'itsyn_openstack234', 'test', '', 'test' , '') in /var/www/cloud/sites/all/modules/aws/modules/aws_ec2/aws_ec2_lib_security_groups_db.inc on line 237

please let me know your fix ..

Comments

saad_asd49’s picture

Dear Yas,
i have got the same error on my cloud. Please, let us know your solutions.

Best Regards,

saad_asd49’s picture

Assigned: Unassigned » saad_asd49

This Problems happens when you have 2 different cloud or running one cloud with different users and projects and this results in not getting all the instances, images, snapshots, ssh keys, security groups.
I have found a soultion for many duplicates errors that appears in the module, you have to change the database design as follow:

1- Table: cloud_aws_cloud_details
Solution: Change the size of the column `aws_access_key` from 20 to 64 to fit to the access key obtained from your cloud
Query:
ALTER TABLE `cloud_aws_cloud_details` CHANGE `aws_access_key` `aws_access_key` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL

2- Table: cloud_aws_security_groups
Solution:
1. Drop the Current primary key on (cloud_type, group_name)
- `ALTER TABLE cloud_aws_security_groups DROP PRIMARY KEY`;
2. Add new primary key on (owner_id, cloud_type, group_name)
- ALTER TABLE `cloud_aws_security_groups` ADD PRIMARY KEY ( `owner_id` , `cloud_type` , `group_name` ) ;

I hope this can help.
Best Regards,
Saad Zaher !

yas’s picture

Status: Active » Needs review

@Saad

Many thanks to your investigation and the solution. I reflected "2- Table: cloud_aws_security_groups" into the code: aws_ec2_lib.inc

--- yas

davisben’s picture

Status: Needs review » Closed (outdated)