From 10f76b2bc63bdfa41b59028a2f06217ae54f97bd Mon Sep 17 00:00:00 2001 From: spisarski Date: Fri, 1 Dec 2017 09:48:50 -0700 Subject: Added ability to add a floating IP to an existing instance Patch includes: 1. Ability to easily retrive an initialized OpenStackVmInstance object 2. Added method to OpenStackVmInstance named "add_floating_ip" 3. Tests to ensure floating IPs added after initialization actually work JIRA: SNAPS-241, SNAPS-242 Change-Id: I1f413645a752c17fd624ecff26e851068bb77e3f Signed-off-by: spisarski --- snaps/openstack/utils/neutron_utils.py | 12 ++++++------ snaps/openstack/utils/settings_utils.py | 16 +++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'snaps/openstack/utils') diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index eaceb37..9b6379a 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -636,7 +636,7 @@ def get_security_group_by_id(neutron, sec_grp_id): def create_security_group_rule(neutron, sec_grp_rule_settings): """ - Creates a security group object in OpenStack + Creates a security group rule in OpenStack :param neutron: the client :param sec_grp_rule_settings: the security group rule settings :return: a SNAPS-OO SecurityGroupRule domain object @@ -650,7 +650,7 @@ def create_security_group_rule(neutron, sec_grp_rule_settings): def delete_security_group_rule(neutron, sec_grp_rule): """ - Deletes a security group object from OpenStack + Deletes a security group rule object from OpenStack :param neutron: the client :param sec_grp_rule: the SNAPS SecurityGroupRule object to delete """ @@ -670,7 +670,7 @@ def get_rules_by_security_group(neutron, sec_grp): def get_rules_by_security_group_id(neutron, sec_grp_id): """ - Retrieves all of the rules for a given security group + Retrieves all of the rules for a given security group by it's ID :param neutron: the client :param sec_grp_id: the ID of the associated security group """ @@ -687,7 +687,7 @@ def get_rules_by_security_group_id(neutron, sec_grp_id): def get_rule_by_id(neutron, sec_grp, rule_id): """ - Deletes a security group object from OpenStack + Returns a SecurityGroupRule object from OpenStack :param neutron: the client :param sec_grp: the SNAPS SecurityGroup domain object :param rule_id: the rule's ID @@ -727,7 +727,7 @@ def get_floating_ips(neutron, ports=None): :param ports: a list of tuple 2 where index 0 is the port name and index 1 is the SNAPS-OO Port object :return: a list of tuple 2 (port_id, SNAPS FloatingIp) objects when ports - is not None else a list of Port objects + is not None else a list of FloatingIp objects """ out = list() fips = neutron.list_floatingips() @@ -811,7 +811,7 @@ def delete_floating_ip(neutron, floating_ip): def get_network_quotas(neutron, project_id): """ - Returns a list of all available keypairs + Returns a list of NetworkQuotas objects :param neutron: the neutron client :param project_id: the project's ID of the quotas to lookup :return: an object of type NetworkQuotas or None if not found diff --git a/snaps/openstack/utils/settings_utils.py b/snaps/openstack/utils/settings_utils.py index d1a9cc6..4ad30fd 100644 --- a/snaps/openstack/utils/settings_utils.py +++ b/snaps/openstack/utils/settings_utils.py @@ -43,7 +43,7 @@ def create_network_config(neutron, network): def create_security_group_config(neutron, security_group): """ - Returns a NetworkConfig object + Returns a SecurityGroupConfig object :param neutron: the neutron client :param security_group: a SNAPS-OO SecurityGroup domain object :return: @@ -148,7 +148,7 @@ def create_router_config(neutron, router): def create_volume_config(volume): """ - Returns a VolumeSettings object + Returns a VolumeConfig object :param volume: a SNAPS-OO Volume object """ @@ -161,7 +161,7 @@ def create_volume_config(volume): def create_volume_type_config(volume_type): """ - Returns a VolumeTypeSettings object + Returns a VolumeTypeConfig object :param volume_type: a SNAPS-OO VolumeType object """ @@ -194,8 +194,8 @@ def create_volume_type_config(volume_type): def create_flavor_config(flavor): """ - Returns a VolumeSettings object - :param flavor: a SNAPS-OO Volume object + Returns a FlavorConfig object + :param flavor: a FlavorConfig object """ return FlavorConfig( name=flavor.name, flavor_id=flavor.id, ram=flavor.ram, @@ -232,7 +232,9 @@ def create_keypair_config(heat_cli, stack, keypair, pk_output_key): def create_vm_inst_config(nova, neutron, server): """ - Returns a NetworkConfig object + Returns a VmInstanceConfig object + note: if the server instance is not active, the PortSettings objects will + not be generated resulting in an invalid configuration :param nova: the nova client :param neutron: the neutron client :param server: a SNAPS-OO VmInst domain object @@ -262,7 +264,7 @@ def create_vm_inst_config(nova, neutron, server): def __create_port_config(neutron, networks): """ - Returns a list of port settings based on the networks parameter + Returns a list of PortConfig objects based on the networks parameter :param neutron: the neutron client :param networks: a list of tuples where #1 is the SNAPS Network domain object and #2 is a list of IP addresses -- cgit 1.2.3-korg