Return-Path: X-Original-To: apmail-cloudstack-issues-archive@www.apache.org Delivered-To: apmail-cloudstack-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 052481973B for ; Fri, 15 Apr 2016 11:13:26 +0000 (UTC) Received: (qmail 72088 invoked by uid 500); 15 Apr 2016 11:13:25 -0000 Delivered-To: apmail-cloudstack-issues-archive@cloudstack.apache.org Received: (qmail 72057 invoked by uid 500); 15 Apr 2016 11:13:25 -0000 Mailing-List: contact issues-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list issues@cloudstack.apache.org Received: (qmail 72048 invoked by uid 500); 15 Apr 2016 11:13:25 -0000 Delivered-To: apmail-incubator-cloudstack-issues@incubator.apache.org Received: (qmail 72044 invoked by uid 99); 15 Apr 2016 11:13:25 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Apr 2016 11:13:25 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 6FE9C2C1F5A for ; Fri, 15 Apr 2016 11:13:25 +0000 (UTC) Date: Fri, 15 Apr 2016 11:13:25 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: cloudstack-issues@incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CLOUDSTACK-9003) Make VM naming services injectable and in their own module MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CLOUDSTACK-9003?page=3Dcom.atla= ssian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId= =3D15242813#comment-15242813 ]=20 ASF GitHub Bot commented on CLOUDSTACK-9003: -------------------------------------------- Github user rafaelweingartner commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1492#discussion_r59859628 =20 --- Diff: api/src/com/cloud/naming/ResourceNamingPolicyManager.java --- @@ -0,0 +1,32 @@ +// 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 com.cloud.naming; + +import com.cloud.utils.component.Manager; + +public interface ResourceNamingPolicyManager extends Manager { + + + /** + * Finds a resource naming policy among the registered ones by its= class + * @param policyClass + * @return + */ + @SuppressWarnings("rawtypes") + public T getPolicy(Class polic= yClass); --- End diff -- =20 Let=E2=80=99s check if I understood this method. It will look up for a naming policy that is registered given a naming p= olicy class, right? =20 The registered policy is an instance of that class that is sent as a pa= rameter, right? If I already know the class I need, why look for an instanc= e of it? =20 What about creating singletons those classes using spring? And then, ju= st injecting them where needed. Sorry if overlooked something, but have you= tried to design some solution that uses IoC instead of creating our own? > Make VM naming services injectable and in their own module > ---------------------------------------------------------- > > Key: CLOUDSTACK-9003 > URL: https://issues.apache.org/jira/browse/CLOUDSTACK-900= 3 > Project: CloudStack > Issue Type: Improvement > Security Level: Public(Anyone can view this level - this is the defa= ult.)=20 > Reporter: Jeffrey Hair > Priority: Minor > > Proposal: Make the various classes/code that give VMs and other resources= hostnames, hypervisor guest names, and UUIDs into their classes as injecta= ble dependencies in their own module under the core or backend module. > This proposal originally only concerned the VirtualMachineName class and = can be broken down into several parts: > * Make the VirtualMachineName class an injectable dependency instead of b= eing full of static methods. > * Refactor the generateHostName method in UserVmManagerImpl to be backed = by an injectable service which generates host names. > * Move the UUIDManagerImpl from the core module to a new module (grouped = with the other 2 ideally). > Rationale: > * VirtualMachineName is one of the few remaining classes that has static = methods tangled like spaghetti throughout the code. This change will put it= in line with the rest of the management server codebase and opens the door= to extensibility. Which brings us to... > * Extensibility: The ultimate goal of this feature is to provide 3rd part= y developers the option of changing default instance/resource naming polici= es. Currently this is possible in a very limited fashion with the instance.= name global setting, but this proposal makes it much more extensible. > By moving the naming-related services (VirtualMachineName, UUIDManager, a= nd more as added/discovered) to their own module, the module can be exclude= d by modules.properties and different ones substituted in. Alternatively, i= t could use the adapter model that other classes use, and the user can conf= igure which adapters are active and also provide custom ones. > A good use case for this functionality is using a different style naming = to emulate other cloud providers such as AWS (i-abc123) or GCE.=20 -- This message was sent by Atlassian JIRA (v6.3.4#6332)