X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=snaps%2Fopenstack%2Futils%2Fsettings_utils.py;h=e85bd08e1d2a805139df096d72b1565c8b1e7681;hb=3482f6e28e26025043f61efb90892d886f5909cc;hp=ea1d0187eb4d49b5adc88de456fbd9ab0f2adb9a;hpb=5ccbf950eadbe54acad6e03cc43c19e05ee4e912;p=snaps.git diff --git a/snaps/openstack/utils/settings_utils.py b/snaps/openstack/utils/settings_utils.py index ea1d018..e85bd08 100644 --- a/snaps/openstack/utils/settings_utils.py +++ b/snaps/openstack/utils/settings_utils.py @@ -15,15 +15,15 @@ import uuid from snaps import file_utils -from snaps.openstack.create_flavor import FlavorSettings +from snaps.config.flavor import FlavorConfig +from snaps.config.keypair import KeypairConfig +from snaps.config.router import RouterConfig from snaps.openstack.create_instance import ( VmInstanceSettings, FloatingIpSettings) -from snaps.openstack.create_keypairs import KeypairSettings from snaps.openstack.create_network import ( PortSettings, SubnetSettings, NetworkSettings) from snaps.openstack.create_security_group import ( SecurityGroupSettings, SecurityGroupRuleSettings) -from snaps.openstack.create_router import RouterSettings from snaps.openstack.create_volume import VolumeSettings from snaps.openstack.create_volume_type import ( VolumeTypeSettings, VolumeTypeEncryptionSettings, ControlLocation) @@ -96,7 +96,7 @@ def create_subnet_settings(neutron, network): def create_router_settings(neutron, router): """ - Returns a RouterSettings object + Returns a RouterConfig object :param neutron: the neutron client :param router: a SNAPS-OO Router domain object :return: @@ -142,7 +142,7 @@ def create_router_settings(neutron, router): if port_setting.network_name != ext_net_name: filtered_settings.append(port_setting) - return RouterSettings( + return RouterConfig( name=router.name, external_gateway=ext_net_name, admin_state_up=router.admin_state_up, port_settings=filtered_settings) @@ -191,12 +191,12 @@ def create_volume_type_settings(volume_type): qos_spec_name=qos_spec_name, public=volume_type.public) -def create_flavor_settings(flavor): +def create_flavor_config(flavor): """ Returns a VolumeSettings object :param flavor: a SNAPS-OO Volume object """ - return FlavorSettings( + return FlavorConfig( name=flavor.name, flavor_id=flavor.id, ram=flavor.ram, disk=flavor.disk, vcpus=flavor.vcpus, ephemeral=flavor.ephemeral, swap=flavor.swap, rxtx_factor=flavor.rxtx_factor, @@ -205,13 +205,13 @@ def create_flavor_settings(flavor): def create_keypair_settings(heat_cli, stack, keypair, pk_output_key): """ - Instantiates a KeypairSettings object from a Keypair domain objects + Instantiates a KeypairConfig object from a Keypair domain objects :param heat_cli: the heat client :param stack: the Stack domain object :param keypair: the Keypair SNAPS domain object :param pk_output_key: the key to the heat template's outputs for retrieval of the private key file - :return: a KeypairSettings object + :return: a KeypairConfig object """ if pk_output_key: outputs = heat_utils.get_outputs(heat_cli, stack) @@ -222,11 +222,11 @@ def create_keypair_settings(heat_cli, stack, keypair, pk_output_key): key_file = file_utils.save_string_to_file( output.value, str(guid), 0o400) - # Use outputs, file and resources for the KeypairSettings - return KeypairSettings( + # Use outputs, file and resources for the KeypairConfig + return KeypairConfig( name=keypair.name, private_filepath=key_file.name) - return KeypairSettings(name=keypair.name) + return KeypairConfig(name=keypair.name) def create_vm_inst_settings(nova, neutron, server): @@ -348,14 +348,14 @@ def __create_floatingip_settings(neutron, port_settings): return out -def determine_image_settings(glance, server, image_settings): +def determine_image_config(glance, server, image_settings): """ - Returns a ImageSettings object from the list that matches the name in one + Returns a ImageConfig object from the list that matches the name in one of the image_settings parameter :param glance: the glance client :param server: a SNAPS-OO VmInst domain object - :param image_settings: list of ImageSettings objects - :return: ImageSettings or None + :param image_settings: list of ImageConfig objects + :return: ImageConfig or None """ if image_settings: for image_setting in image_settings: @@ -364,20 +364,20 @@ def determine_image_settings(glance, server, image_settings): return image_setting -def determine_keypair_settings(heat_cli, stack, server, keypair_settings=None, - priv_key_key=None): +def determine_keypair_config(heat_cli, stack, server, keypair_settings=None, + priv_key_key=None): """ - Returns a KeypairSettings object from the list that matches the + Returns a KeypairConfig object from the list that matches the server.keypair_name value in the keypair_settings parameter if not None, else if the output_key is not None, the output's value when contains the string 'BEGIN RSA PRIVATE KEY', this value will be stored into a file and - encoded into the KeypairSettings object returned + encoded into the KeypairConfig object returned :param heat_cli: the OpenStack heat client :param stack: a SNAPS-OO Stack domain object :param server: a SNAPS-OO VmInst domain object - :param keypair_settings: list of KeypairSettings objects + :param keypair_settings: list of KeypairConfig objects :param priv_key_key: the stack options that holds the private key value - :return: KeypairSettings or None + :return: KeypairConfig or None """ # Existing keypair being used by Heat Template if keypair_settings: @@ -395,6 +395,6 @@ def determine_keypair_settings(heat_cli, stack, server, keypair_settings=None, key_file = file_utils.save_string_to_file( output.value, str(guid), 0o400) - # Use outputs, file and resources for the KeypairSettings - return KeypairSettings( + # Use outputs, file and resources for the KeypairConfig + return KeypairConfig( name=server.keypair_name, private_filepath=key_file.name)