Skip to content

Conversation

FernandoOjeda
Copy link
Contributor

Create dedicated host with gpu #1022.

@coveralls
Copy link

coveralls commented Aug 23, 2018

Coverage Status

Coverage increased (+0.2%) to 89.119% when pulling ac9e28e on FernandoOjeda:fo_create_dedicated_host_with_gpu into cdaebcc on softlayer:master.

disk_capacity = capacity['capacity']

for hardwareComponent in item['bundleItems']:
if hardwareComponent['keyName'].find("GPU") != -1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of creating 4 variables, it would makes sense to do something like this:

gpuComponent =  {
                                    'hardwareComponentModel': {
                                        'hardwareGenericComponentModel': {
                                            'id': hardwareGenericComponentModelId,
                                            'hardwareComponentType': {
                                                'keyName': hardwareComponentTypeKeyName
                                            }
                                        }
                                    }
                                },
                                {
                                    'hardwareComponentModel': {
                                        'hardwareGenericComponentModel': {
                                            'id': hardwareGenericComponentModelId,
                                            'hardwareComponentType': {
                                                'keyName': hardwareComponentTypeKeyName
                                            }
                                        }
                                    }
                                }

Then just use gpuComponent further down.

Copy link
Contributor Author

@FernandoOjeda FernandoOjeda Aug 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

'datacenter': {
'id': loc_id
if item['keyName'].find("GPU") == -1:
host = {
Copy link
Member

@allmightyspiff allmightyspiff Aug 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set host outside of the if statement since it always need to be set, and is the same for GPU/NO-GPU

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

'id': loc_id
}
}
else:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if/else should instead just be a single if gpuComponent is not None: and then add the gpuComponent to the already existing host dictionary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@allmightyspiff allmightyspiff merged commit d28da2d into softlayer:master Aug 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants