From 11dabdb38a7ec3d44444b019e1d867fe1c76252b Mon Sep 17 00:00:00 2001 From: Robert Pothier Date: Tue, 29 Sep 2015 16:41:11 -0400 Subject: [PATCH] Update Baymodel in Magnum resources This updates OS::Magnum::BayModel in the Magnum resources with the new properties network_driver, http_proxy, https_proxy, no_proxy, labels, and insecure. Change-Id: I2c9ce5a7b3203feee0ba444440f8a3e3a1c9cd0d Implements: partial blueprint magnum-resources --- .../resources/openstack/magnum/baymodel.py | 53 +++++++++++++++++-- heat/tests/magnum/test_magnum_baymodel.py | 48 +++++++++++------ 2 files changed, 82 insertions(+), 19 deletions(-) diff --git a/heat/engine/resources/openstack/magnum/baymodel.py b/heat/engine/resources/openstack/magnum/baymodel.py index 97cab6933e..b1703f423e 100644 --- a/heat/engine/resources/openstack/magnum/baymodel.py +++ b/heat/engine/resources/openstack/magnum/baymodel.py @@ -26,11 +26,13 @@ class BayModel(resource.Resource): PROPERTIES = ( NAME, IMAGE, FLAVOR, MASTER_FLAVOR, KEYPAIR, EXTERNAL_NETWORK, FIXED_NETWORK, DNS_NAMESERVER, - DOCKER_VOLUME_SIZE, SSH_AUTHORIZED_KEY, COE + DOCKER_VOLUME_SIZE, SSH_AUTHORIZED_KEY, COE, NETWORK_DRIVER, + HTTP_PROXY, HTTPS_PROXY, NO_PROXY, LABELS, INSECURE ) = ( 'name', 'image', 'flavor', 'master_flavor', 'keypair', 'external_network', 'fixed_network', 'dns_nameserver', - 'docker_volume_size', 'ssh_authorized_key', 'coe' + 'docker_volume_size', 'ssh_authorized_key', 'coe', 'network_driver', + 'http_proxy', 'https_proxy', 'no_proxy', 'labels', 'insecure' ) properties_schema = { @@ -110,7 +112,43 @@ class BayModel(resource.Resource): constraints.AllowedValues(['kubernetes', 'swarm']) ], required=True - ) + ), + NETWORK_DRIVER: properties.Schema( + properties.Schema.STRING, + _('The name of the driver used for instantiating ' + 'container networks.'), + required=True, + support_status=support.SupportStatus(version='6.0.0') + ), + HTTP_PROXY: properties.Schema( + properties.Schema.STRING, + _('The http_proxy address to use for nodes in bay.'), + support_status=support.SupportStatus(version='6.0.0') + ), + HTTPS_PROXY: properties.Schema( + properties.Schema.STRING, + _('The https_proxy address to use for nodes in bay.'), + support_status=support.SupportStatus(version='6.0.0') + ), + NO_PROXY: properties.Schema( + properties.Schema.STRING, + _('A comma separated list of addresses for which proxies should ' + 'not be used in the bay.'), + support_status=support.SupportStatus(version='6.0.0') + ), + LABELS: properties.Schema( + properties.Schema.MAP, + _('Arbitrary labels in the form of key=value pairs to ' + 'associate with a baymodel.'), + support_status=support.SupportStatus(version='6.0.0') + ), + INSECURE: properties.Schema( + properties.Schema.BOOLEAN, + _('Disable TLS in the Bay.'), + default=False, + support_status=support.SupportStatus(version='6.0.0') + ), + } default_client_name = 'magnum' @@ -129,8 +167,15 @@ class BayModel(resource.Resource): 'dns_nameserver': self.properties[self.DNS_NAMESERVER], 'docker_volume_size': self.properties[self.DOCKER_VOLUME_SIZE], 'ssh_authorized_key': self.properties[self.SSH_AUTHORIZED_KEY], - 'coe': self.properties[self.COE] + 'coe': self.properties[self.COE], + 'network_driver': self.properties[self.NETWORK_DRIVER], + 'http_proxy': self.properties[self. HTTP_PROXY], + 'https_proxy': self.properties[self.HTTPS_PROXY], + 'no_proxy': self.properties[self.NO_PROXY], + 'labels': self.properties[self.LABELS], + 'insecure': self.properties[self.INSECURE] } + bm = self.client().baymodels.create(**args) self.resource_id_set(bm.uuid) diff --git a/heat/tests/magnum/test_magnum_baymodel.py b/heat/tests/magnum/test_magnum_baymodel.py index 92dbc8eea7..fa0e85899c 100644 --- a/heat/tests/magnum/test_magnum_baymodel.py +++ b/heat/tests/magnum/test_magnum_baymodel.py @@ -21,7 +21,11 @@ from heat.tests import common from heat.tests import utils -magnum_template = ''' +RESOURCE_TYPE = 'OS::Magnum::BayModel' + + +class TestMagnumBayModel(common.HeatTestCase): + magnum_template = ''' heat_template_version: 2015-04-30 resources: test_baymodel: @@ -38,22 +42,14 @@ magnum_template = ''' docker_volume_size: 5 ssh_authorized_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB coe: 'swarm' + network_driver: 'flannel' ''' -RESOURCE_TYPE = 'OS::Magnum::BayModel' - - -class FakeBayModel(object): - def __init__(self): - self.to_dict = lambda: {'attr': 'val'} - - -class TestMagnumBayModel(common.HeatTestCase): def setUp(self): super(TestMagnumBayModel, self).setUp() self.ctx = utils.dummy_context() resource._register_class(RESOURCE_TYPE, baymodel.BayModel) - t = template_format.parse(magnum_template) + t = template_format.parse(self.magnum_template) self.stack = utils.parse_stack(t) resource_defns = self.stack.t.resource_definitions(self.stack) @@ -85,7 +81,29 @@ class TestMagnumBayModel(common.HeatTestCase): self.assertEqual(1, len(mapping)) self.assertEqual(baymodel.BayModel, mapping[RESOURCE_TYPE]) - def test_show_resource(self): - bm = self._create_resource('bm', self.rsrc_defn, self.stack) - self.client.baymodels.get.return_value = FakeBayModel() - self.assertEqual({'attr': 'val'}, bm.FnGetAtt('show')) + +class TestMagnumBayModelWithAddedProperties(TestMagnumBayModel): + magnum_template = ''' + heat_template_version: 2015-04-30 + resources: + test_baymodel: + type: OS::Magnum::BayModel + properties: + name: test_bay_model + image: fedora-21-atomic-2 + flavor: m1.small + master_flavor: m1.medium + keypair: heat_key + external_network: 0244b54d-ae1f-44f0-a24a-442760f1d681 + fixed_network: 0f59a3dd-fac1-4d03-b41a-d4115fbffa89 + dns_nameserver: 8.8.8.8 + docker_volume_size: 5 + ssh_authorized_key: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB + coe: 'swarm' + network_driver: 'flannel' + http_proxy: 'http://proxy.com:123' + https_proxy: 'https://proxy.com:123' + no_proxy: '192.168.0.1' + labels: {'flannel_cidr': ['10.101.0.0/16', '10.102.0.0/16']} + insecure: True + '''