Exemplo n.º 1
0
 def handle_create(self):
     props = self.prepare_properties(self.properties,
                                     self.physical_resource_name())
     neutron_utils.resolve_subnet(self.neutron(), props, self.SUBNET,
                                  'subnet_id')
     vpnservice = self.neutron().create_vpnservice({'vpnservice':
                                                    props})['vpnservice']
     self.resource_id_set(vpnservice['id'])
Exemplo n.º 2
0
 def handle_create(self):
     props = self.prepare_properties(
         self.properties,
         self.physical_resource_name())
     neutron_utils.resolve_subnet(
         self.neutron(), props,
         self.SUBNET, 'subnet_id')
     vpnservice = self.neutron().create_vpnservice({'vpnservice': props})[
         'vpnservice']
     self.resource_id_set(vpnservice['id'])
Exemplo n.º 3
0
Arquivo: port.py Projeto: rmery/heat
    def _prepare_list_properties(self, props):
        for fixed_ip in props.get(self.FIXED_IPS, []):
            for key, value in fixed_ip.items():
                if value is None:
                    fixed_ip.pop(key)
            if fixed_ip.get(self.FIXED_IP_SUBNET):
                neutron_utils.resolve_subnet(self.neutron(), fixed_ip, self.FIXED_IP_SUBNET, "subnet_id")
        # delete empty MAC addresses so that Neutron validation code
        # wouldn't fail as it not accepts Nones
        for pair in props.get(self.ALLOWED_ADDRESS_PAIRS, []):
            if self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS in pair and pair[self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS] is None:
                del pair[self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS]

        if props.get(self.SECURITY_GROUPS):
            props[self.SECURITY_GROUPS] = self.get_secgroup_uuids(props.get(self.SECURITY_GROUPS), self.neutron())
        else:
            props.pop(self.SECURITY_GROUPS, None)

        if not props[self.FIXED_IPS]:
            del (props[self.FIXED_IPS])
Exemplo n.º 4
0
    def _prepare_list_properties(self, props):
        for fixed_ip in props.get(self.FIXED_IPS, []):
            for key, value in fixed_ip.items():
                if value is None:
                    fixed_ip.pop(key)
            if fixed_ip.get(self.FIXED_IP_SUBNET):
                neutron_utils.resolve_subnet(self.neutron(), fixed_ip,
                                             self.FIXED_IP_SUBNET, 'subnet_id')
        # delete empty MAC addresses so that Neutron validation code
        # wouldn't fail as it not accepts Nones
        for pair in props.get(self.ALLOWED_ADDRESS_PAIRS, []):
            if (self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS in pair
                    and pair[self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS] is None):
                del pair[self.ALLOWED_ADDRESS_PAIR_MAC_ADDRESS]

        if props.get(self.SECURITY_GROUPS):
            props[self.SECURITY_GROUPS] = self.get_secgroup_uuids(
                props.get(self.SECURITY_GROUPS), self.neutron())
        else:
            props.pop(self.SECURITY_GROUPS, None)
Exemplo n.º 5
0
 def handle_create(self):
     router_id = self.properties.get(self.ROUTER_ID)
     key = 'subnet_id'
     value = neutron_utils.resolve_subnet(self.neutron(),
                                          dict(self.properties),
                                          self.SUBNET, key)
     if not value:
         key = self.PORT_ID
         value = self.properties.get(key)
     self.neutron().add_interface_router(router_id, {key: value})
     self.resource_id_set('%s:%s=%s' % (router_id, key, value))
Exemplo n.º 6
0
 def handle_create(self):
     router_id = self.properties.get(self.ROUTER_ID)
     key = 'subnet_id'
     value = neutron_utils.resolve_subnet(
         self.neutron(), dict(self.properties), self.SUBNET, key)
     if not value:
         key = self.PORT_ID
         value = self.properties.get(key)
     self.neutron().add_interface_router(
         router_id,
         {key: value})
     self.resource_id_set('%s:%s=%s' % (router_id, key, value))
Exemplo n.º 7
0
    def handle_create(self):
        properties = self.prepare_properties(
            self.properties,
            self.physical_resource_name())
        neutron_utils.resolve_subnet(
            self.neutron(), properties, self.SUBNET, 'subnet_id')
        vip_properties = properties.pop(self.VIP)
        monitors = properties.pop(self.MONITORS)
        client = self.neutron()
        pool = client.create_pool({'pool': properties})['pool']
        self.resource_id_set(pool['id'])

        for monitor in monitors:
            client.associate_health_monitor(
                pool['id'], {'health_monitor': {'id': monitor}})

        vip_arguments = self.prepare_properties(
            vip_properties,
            '%s.vip' % (self.name,))

        session_p = vip_arguments.get(self.VIP_SESSION_PERSISTENCE)
        if session_p is not None:
            prepared_props = self.prepare_properties(session_p, None)
            vip_arguments['session_persistence'] = prepared_props

        vip_arguments['protocol'] = self.properties[self.PROTOCOL]

        if vip_arguments.get(self.VIP_SUBNET) is None:
            vip_arguments['subnet_id'] = properties[self.SUBNET_ID]
        else:
            vip_arguments['subnet_id'] = neutron_utils.resolve_subnet(
                self.neutron(),
                vip_arguments, self.VIP_SUBNET, 'subnet_id')

        vip_arguments['pool_id'] = pool['id']
        vip = client.create_vip({'vip': vip_arguments})['vip']

        self.metadata_set({'vip': vip['id']})
Exemplo n.º 8
0
    def handle_create(self):
        properties = self.prepare_properties(self.properties,
                                             self.physical_resource_name())
        neutron_utils.resolve_subnet(self.neutron(), properties, self.SUBNET,
                                     'subnet_id')
        vip_properties = properties.pop(self.VIP)
        monitors = properties.pop(self.MONITORS)
        client = self.neutron()
        pool = client.create_pool({'pool': properties})['pool']
        self.resource_id_set(pool['id'])

        for monitor in monitors:
            client.associate_health_monitor(
                pool['id'], {'health_monitor': {
                    'id': monitor
                }})

        vip_arguments = self.prepare_properties(vip_properties,
                                                '%s.vip' % (self.name, ))

        session_p = vip_arguments.get(self.VIP_SESSION_PERSISTENCE)
        if session_p is not None:
            prepared_props = self.prepare_properties(session_p, None)
            vip_arguments['session_persistence'] = prepared_props

        vip_arguments['protocol'] = self.properties[self.PROTOCOL]

        if vip_arguments.get(self.VIP_SUBNET) is None:
            vip_arguments['subnet_id'] = properties[self.SUBNET_ID]
        else:
            vip_arguments['subnet_id'] = neutron_utils.resolve_subnet(
                self.neutron(), vip_arguments, self.VIP_SUBNET, 'subnet_id')

        vip_arguments['pool_id'] = pool['id']
        vip = client.create_vip({'vip': vip_arguments})['vip']

        self.metadata_set({'vip': vip['id']})