brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From neykov <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #739: A default network is now created when dep...
Date Thu, 22 Jun 2017 14:37:57 GMT
Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/739#discussion_r123528419
  
    --- Diff: locations/jclouds/src/main/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreator.java
---
    @@ -0,0 +1,147 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +package org.apache.brooklyn.location.jclouds.networking.creator;
    +
    +import static org.apache.brooklyn.core.location.cloud.CloudLocationConfig.CLOUD_REGION_ID;
    +import static org.apache.brooklyn.location.jclouds.api.JcloudsLocationConfigPublic.NETWORK_NAME;
    +import static org.apache.brooklyn.location.jclouds.api.JcloudsLocationConfigPublic.TEMPLATE_OPTIONS;
    +
    +import java.util.Arrays;
    +import java.util.HashMap;
    +import java.util.Map;
    +
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +import com.google.common.collect.ImmutableMap;
    +
    +import org.jclouds.azurecompute.arm.AzureComputeApi;
    +import org.jclouds.azurecompute.arm.domain.ResourceGroup;
    +import org.jclouds.azurecompute.arm.domain.Subnet;
    +import org.jclouds.azurecompute.arm.domain.VirtualNetwork;
    +import org.jclouds.compute.ComputeService;
    +
    +import org.apache.brooklyn.config.ConfigKey;
    +import org.apache.brooklyn.core.config.ConfigKeys;
    +import org.apache.brooklyn.util.collections.MutableMap;
    +import org.apache.brooklyn.util.core.config.ConfigBag;
    +
    +public class DefaultAzureArmNetworkCreator {
    +
    +    public static final Logger LOG = LoggerFactory.getLogger(DefaultAzureArmNetworkCreator.class);
    +
    +    private static final String DEFAULT_RESOURCE_GROUP = "brooklyn-default-resource-group";
    +    private static final String DEFAULT_NETWORK_NAME = "brooklyn-default-network";
    +    private static final String DEFAULT_SUBNET_NAME = "brooklyn-default-subnet";
    +
    +    private static final String DEFAULT_VNET_ADDRESS_PREFIX = "10.1.0.0/16";
    +    private static final String DEFAULT_SUBNET_ADDRESS_PREFIX = "10.1.0.0/24";
    +
    +    public static ConfigKey<Boolean> AZURE_ARM_DEFAULT_NETWORK_ENABLED = ConfigKeys.newBooleanConfigKey(
    +            "azure.arm.default.network.enabled",
    +            "When set to true, AMP will create a default network and subnet per Azure
region and " +
    +                    "deploy applications there (if no network configuration has been
set for the application).",
    +            true);
    +
    +    public static void createDefaultNetworkAndAddToTemplateOptionsIfRequired(ComputeService
computeService, ConfigBag config) {
    +        if (!config.get(AZURE_ARM_DEFAULT_NETWORK_ENABLED)) {
    +            LOG.info("azure.arm.default.network.enabled is disabled, not creating default
network");
    +            return;
    +        }
    +
    +
    +        Map<String, Object> templateOptions = config.get(TEMPLATE_OPTIONS);
    +
    +        //Only create a default network if we haven't specified a network name (in template
options or config) or ip options
    +        if (config.containsKey(NETWORK_NAME)) {
    +            LOG.info("Network config specified when provisioning Azure machine. Not creating
default network");
    +            return;
    +        }
    +        if (templateOptions != null && (templateOptions.containsKey(NETWORK_NAME.getName())
|| templateOptions.containsKey("ipOptions"))) {
    --- End diff --
    
    The `TemplateOptions` property is named `networks`, whereas `NETWORK_NAME.getName()` is
`networkName`, so it will miss user-supplied options.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message