-
Notifications
You must be signed in to change notification settings - Fork 194
WIP: Add support for specifying a subnet on a private VLAN #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,6 +132,9 @@ def _parse_create_args(client, args): | |
| if args.get('vlan_private'): | ||
| data['private_vlan'] = args['vlan_private'] | ||
|
|
||
| if args.get('vlan_private_subnet'): | ||
| data['private_vlan_subnet'] = args['vlan_private_subnet'] | ||
|
|
||
| if args.get('public_security_group'): | ||
| pub_groups = args.get('public_security_group') | ||
| data['public_security_groups'] = [group for group in pub_groups] | ||
|
|
@@ -227,6 +230,10 @@ def _parse_create_args(client, args): | |
| help="The ID of the private VLAN on which you want the virtual " | ||
| "server placed", | ||
| type=click.INT) | ||
| @click.option('--vlan-private-subnet', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here just, --private-subnet. |
||
| help="The ID of the private VLAN subnet on which you want the virtual " | ||
| "server placed", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Max line length is 120, so put this all on one line please. |
||
| type=click.INT) | ||
| @helpers.multi_option('--public-security-group', | ||
| '-S', | ||
| help=('Security group ID to associate with ' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -309,7 +309,7 @@ def _generate_create_dict( | |
| dedicated=False, public_vlan=None, private_vlan=None, | ||
| userdata=None, nic_speed=None, disks=None, post_uri=None, | ||
| private=False, ssh_keys=None, public_security_groups=None, | ||
| private_security_groups=None, **kwargs): | ||
| private_security_groups=None, private_vlan_subnet=None, **kwargs): | ||
| """Returns a dict appropriate to pass into Virtual_Guest::createObject | ||
|
|
||
| See :func:`create_instance` for a list of available options. | ||
|
|
@@ -368,10 +368,25 @@ def _generate_create_dict( | |
| data.update({ | ||
| 'primaryNetworkComponent': { | ||
| "networkVlan": {"id": int(public_vlan)}}}) | ||
|
|
||
| if private_vlan: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My thoughts here are to break out the private/public vlan stuff into a helper function. if private_vlan or public_vlan:
network_component = self._create_network_components(private_vlan, public_vlan, private_vlan_subnet, public_vlan_subnet)
date.update(network_component)Or something similar would work.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestions, I had just started doing that very thing - however, just to pre-warn you it seems there is a tox check for max number of lines in a module, and we have just crossed the 1000 limit
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for that one, you can just add it to the ignored list at the top of this module. I don't want to split this file out at the moment, although I will likely do so in the future. |
||
| data.update({ | ||
| "primaryBackendNetworkComponent": { | ||
| "networkVlan": {"id": int(private_vlan)}}}) | ||
| # As per https://stackoverflow.com/questions/37592080/create-a-softlayer-virtual-guest-on-a-specific-subnet | ||
| # we can specify a subnet under the VLAN | ||
| if private_vlan_subnet: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be inside the private_vlan if statement since I don't think the API requires a vlan id when supplying a subnet id. |
||
| data.update({ | ||
| "primaryBackendNetworkComponent": { | ||
| "networkVlanId": int(private_vlan), | ||
| "networkVlan": { | ||
| "primarySubnet": { | ||
| "id": int(private_vlan_subnet) | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| else: | ||
| data.update({ | ||
| "primaryBackendNetworkComponent": { | ||
| "networkVlan": {"id": int(private_vlan)}}}) | ||
|
|
||
| if public_security_groups: | ||
| secgroups = [{'securityGroup': {'id': int(sg)}} | ||
|
|
@@ -565,6 +580,7 @@ def create_instance(self, **kwargs): | |
| :param list public_security_groups: The list of security group IDs to apply to the public interface | ||
| :param list private_security_groups: The list of security group IDs to apply to the private interface | ||
| :param int private_vlan: The ID of the private VLAN on which you want this VS placed. | ||
| :param int private_vlan_subnet: The ID of the private VLAN subnet on which you want this VS placed. | ||
| :param list disks: A list of disk capacities for this server. | ||
| :param string post_uri: The URI of the post-install script to run after reload | ||
| :param bool private: If true, the VS will be provisioned only with access to the private network. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend naming this private_subnet instead of private_vlan_subnet.