4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 from cmframework.apis import cmuserconfig
17 from cmframework.apis import cmerror
18 from cmdatahandlers.api import configerror
20 This plugin is used to add IP addresses for all the host(s) that are defined in
21 the user configuration. The IP addresses will be allocated in the hosts
22 according to which networks are actually used in the host.
23 It also takes care of allocating the ipmit console port and vbmc ports.
25 class iphandler(cmuserconfig.CMUserConfigPlugin):
27 super(iphandler,self).__init__()
29 def handle(self, confman):
31 hostsconf = confman.get_hosts_config_handler()
32 netconf = confman.get_networking_config_handler()
33 hosts = hostsconf.get_hosts()
34 installation_host = hostsconf.get_installation_host()
35 # Installation host has to be the first one in the list
36 # this so that the IP address of the installation host
37 # does not change during the deployment.
38 hosts.remove(installation_host)
39 hosts.insert(0, installation_host)
41 netconf.add_host_networks(host)
42 hostsconf.add_vbmc_port(host)
43 hostsconf.add_ipmi_terminal_port(host)
45 netconf.add_external_vip()
46 netconf.add_internal_vip()
47 except configerror.ConfigError as exp:
48 raise cmerror.CMError(str(exp))