Example #1
0
    def create_ag_az_for_cascaded_node(self):
        reference_service = RefServices()
        name_aggregate = config.CONF.cascaded_node_plugins.aggregate_name
        az = config.CONF.node_cfg.availability_zone
        host = config.CONF.sysconfig.hostname
        logger.info('@@@@ Start to create aggregate for aggregate <%s> availability_zone <%s> @@@@' %
                    (name_aggregate, az))

        if reference_service.nova_aggregate_exist(name_aggregate, az):
            logger.info('aggregate<%s> availability_zone<%s> is exist, no need to create.')
        else:
            aggregate_obj = reference_service.nova_aggregate_create(name_aggregate, az)
            reference_service.nova_aggregate_add_host(aggregate_obj.id, host)

        logger.info('@@@@ End to create aggregate for aggregate <%s> availability_zone <%s> @@@@' %
                    (name_aggregate, az))
Example #2
0
    def __init__(self, absolute_path_of_patch, filter):
        """

        :param absolute_path_of_patch:  path of patches config file.
            for example: /root/tricircle-master/novaproxy/
                        /root/tricircle-master/juno-patches/nova_scheduling_patch/
        :param filter:  ['.conf', '.ini']
        :return:
        """
        self.absolute_path_of_patch = absolute_path_of_patch
        self.filter = filter
        self.system_replacement = {
            ConfigReplacement.AVAILABILITY_ZONE:
            config.CONF.node_cfg.availability_zone,
            ConfigReplacement.CASCADED_NODE_IP:
            config.CONF.node_cfg.cascaded_node_ip,
            ConfigReplacement.CASCADING_NODE_IP:
            config.CONF.node_cfg.cascading_node_ip,
            ConfigReplacement.CINDER_TENANT_ID:
            RefServices().get_tenant_id_for_admin(),
            ConfigReplacement.REGION_NAME:
            config.CONF.node_cfg.region_name,
            ConfigReplacement.CASCADING_OS_REGION_NAME:
            config.CONF.node_cfg.cascading_os_region_name,
            ConfigReplacement.ML2_LOCAL_IP:
            config.CONF.sysconfig.ml2_local_ip
        }
        self.exclude_replacement = ['project_id']
        self.bak_openstack_path = config.CONF.sysconfig.openstack_bak_path
Example #3
0
    def create_aggregate_in_cascaded_node(self):
        """
        nova aggregate-create az31.singapore--aws az31.singapore--aws
        nova host-list
        nova aggregate-add-host az31.singapore--aws 42114FD9-D446-9248-3A05-23CF474E3C68

        :return:
        """
        ref_service = RefServices()
        host_id = socket.gethostname()
        region = RefCPSService.get_local_domain()
        os_region_name = '.'.join([RefFsSystemUtils.get_az_by_domain(region), RefFsSystemUtils.get_dc_by_domain(region)])
        if not ref_service.nova_aggregate_exist(os_region_name, os_region_name):
            create_result = ref_service.nova_aggregate_create(os_region_name, os_region_name)
            if create_result is not None:
                ref_service.nova_aggregate_add_host(create_result, host_id)
        print('Success to create region<%s> for host<%s>' % (os_region_name, host_id))
Example #4
0
 def _config_tenant_id_in_neutron_conf(self, path_neutron_conf):
     option_nova_admin_tenant_id = 'nova_admin_tenant_id'
     # get tenant id
     value_nova_admin_tenant_id = RefServices().get_tenant_id_for_service()
     logger.info('tenant id of service is <%s>' %
                 (value_nova_admin_tenant_id))
     config_common = ConfigCommon(path_neutron_conf)
     config_common.set_default(option_nova_admin_tenant_id,
                               value_nova_admin_tenant_id)
     config_common.write_commit()
Example #5
0
    def _config_cinder_proxy(self, proxy_name):
        try:
            service = 'cinder'
            template = '-'.join([service, proxy_name])
            proxy_matched_region = self.proxy_match_region.get(proxy_name)
            proxy_matched_host_region_name = self._get_proxy_region_and_host_region_name(
                proxy_matched_region)
            cinder_tenant_id = RefServices().get_tenant_id_for_admin()
            log.info('cinder_tenant_id: %s' % cinder_tenant_id)

            updated_params = {
                'cascaded_cinder_url':
                ''.join([
                    'https://volume.%s:443' % proxy_matched_region,
                    '/v2/%(project_id)s'
                ]),
                'cascaded_neutron_url':
                'https://network.%s:443' % proxy_matched_region,
                'cascaded_region_name':
                proxy_matched_host_region_name,
                'cinder_tenant_id':
                cinder_tenant_id,
                'host':
                proxy_matched_host_region_name,
                'keystone_auth_url':
                'https://identity.%s:443/identity/v2.0' %
                self.cascading_region,
                'storage_availability_zone':
                proxy_matched_host_region_name
            }
            self._update_template_params_for_proxy(service, template,
                                                   updated_params)
            self._commit_config()
            #self._check_service_proxy_status(service, template, 'active')
            template_cinder_api = 'cinder-api'
            template_cinder_scheduler = 'cinder-scheduler'
            template_cinder_cinder_volume = 'cinder-scheduler'
            #self._check_service_proxy_status(service, template_cinder_api, 'active')
            #self._check_service_proxy_status(service, template_cinder_scheduler, 'active')
            #self._check_service_proxy_status(service, template_cinder_cinder_volume, 'active')
        except:
            print 'Exception when cinder proxy config. e: %s' % traceback.format_exc(
            )
            log.error('e: %s' % traceback.format_exc())
Example #6
0
    def create_ag_az_for_cascaded_node(self):
        reference_service = RefServices()
        name_aggregate = config.CONF.cascaded_node_plugins.aggregate_name
        az = config.CONF.node_cfg.availability_zone
        host = config.CONF.sysconfig.hostname
        logger.info(
            '@@@@ Start to create aggregate for aggregate <%s> availability_zone <%s> @@@@'
            % (name_aggregate, az))

        if reference_service.nova_aggregate_exist(name_aggregate, az):
            logger.info(
                'aggregate<%s> availability_zone<%s> is exist, no need to create.'
            )
        else:
            aggregate_obj = reference_service.nova_aggregate_create(
                name_aggregate, az)
            reference_service.nova_aggregate_add_host(aggregate_obj.id, host)

        logger.info(
            '@@@@ End to create aggregate for aggregate <%s> availability_zone <%s> @@@@'
            % (name_aggregate, az))
Example #7
0
    def create_aggregate_in_cascaded_node(self):
        """
        nova aggregate-create az31.singapore--aws az31.singapore--aws
        nova host-list
        nova aggregate-add-host az31.singapore--aws 42114FD9-D446-9248-3A05-23CF474E3C68

        :return:
        """
        ref_service = RefServices()
        host_id = socket.gethostname()
        region = RefCPSService.get_local_domain()
        os_region_name = '.'.join([
            RefFsSystemUtils.get_az_by_domain(region),
            RefFsSystemUtils.get_dc_by_domain(region)
        ])
        if not ref_service.nova_aggregate_exist(os_region_name,
                                                os_region_name):
            create_result = ref_service.nova_aggregate_create(
                os_region_name, os_region_name)
            if create_result is not None:
                ref_service.nova_aggregate_add_host(create_result, host_id)
        print('Success to create region<%s> for host<%s>' %
              (os_region_name, host_id))
Example #8
0
 def _create_endpoints(self, region, ip):
     logger.info('@@@@ Start to create endpoints for region <%s> ip <%s> @@@@' % (region, ip))
     reference_service = RefServices()
     reference_service.create_endpoint_for_nova(region, ip)
     reference_service.create_endpoint_for_cinder(region, ip)
     reference_service.create_endpoint_for_glance(region, ip)
     reference_service.create_endpoint_for_network(region, ip)
     reference_service.create_endpoint_for_heat(region, ip)
     reference_service.create_endpoint_for_ceilometer(region, ip)
     reference_service.create_endpoint_for_ec2(region, ip)
     logger.info('@@@@ End to create endpoints for region <%s> ip <%s> @@@@' % (region, ip))
Example #9
0
    def setUpClass(cls):
        """
        The setUpClass() and tearDownClass() methods allow you to define instructions that will be executed
        before and after each test class.
        :return:
        """
        cls.ref_services = RefServices()
        cls.image_id_emall_backend = 'cfde0324-0ca6-4883-b160-bf06383ad466'
        cls.image_id_emall_web = '78576f89-95cc-4228-9301-9d59cc2705c1'
        cls.region_az01 = 'az01.shenzhen--fusionsphere'
        cls.region_az11 = 'az11.shenzhen--vcloud'
        cls.region_az31 = 'az31.singapore--aws'
        cls.ext_router = 'ext-router'
        cls.name_ci_ext_net = 'ci-ext-net'
        cls.name_floating_ip_pool = 'ci-ext-net'

        # neutron net-create ci-ext-net --router:external True --provider:physical_network physnet1
        # --provider:network_type vlan --provider:segmentation_id 1000
        # cls.ci_ext_net = \
        #     cls.ref_services.neutron_create_net('ci-ext-net',
        #                                               router_external=True,
        #                                               network_type='vlan',
        #                                               physical_network='physnet1',
        #                                               segment_id='1000')
        # cls.ci_ext_net_id = cls.ci_ext_net['network']['id']
        cls.ci_ext_net_id = "3eb33036-2f10-4ce0-b288-ff9dd18cbfb9"

        # neutron subnet-create  ci-ext-net --name ci-ext-subnet
        # --allocation-pool start=162.3.130.100,end=162.3.130.130 --disable-dhcp --gateway 162.3.110.1 162.3.0.0/16
        # cls.ci_ext_subnet = \
        #     cls.ref_services.neutron_create_subnet(cls.ci_ext_net_id,
        #                                      'ci-ext-subnet01',
        #                                      allocation_pools=[{"start": "162.3.130.100", "end": "162.3.130.130"}],
        #                                      enable_dhcp=False,
        #                                      gateway_ip='162.3.110.1',
        #                                      cidr='162.3.0.0/16')
        # cls.ci_ext_subnet_id = cls.ci_ext_subnet['subnet']['id']
        cls.ci_ext_subnet_id = "0269ac74-e46a-4a82-b359-fbaecb25050e"

        # neutron net-create ci-net01 --router:external False --provider:network_type vxlan
        # cls.ci_net01 = \
        #     cls.ref_services.neutron_create_net('ci-net01',
        #                                               router_external=False,
        #                                               network_type='vxlan')
        # cls.ci_net01_id = cls.ci_net01['network']['id']
        cls.ci_net01_id = "c4174afd-7513-4c7a-8efb-3e63dabe152f"

        # neutron subnet-create ci-net01 --name ci-subnet01  --allocation-pool start=192.168.145.2,end=192.168.145.50
        # --disable-dhcp --gateway 192.168.145.1 192.168.145.0/24
        # cls.ci_subnet01 = \
        #     cls.ref_services.neutron_create_subnet(cls.ci_net01_id,
        #                                      'ci-subnet01',
        #                                      allocation_pools=[{"start": "192.168.145.2", "end": "192.168.145.50"}],
        #                                      enable_dhcp=True,
        #                                      gateway_ip='192.168.145.1',
        #                                      cidr='192.168.145.0/24')
        # cls.ci_subnet01_id = cls.ci_subnet01['subnet']['id']
        cls.ci_subnet01_id = "2836697c-ac30-45fe-82dd-b8cbf13cb4d0"

        # cls.ext_router_data = cls.ref_services.neutron_create_router(cls.ext_router)
        # cls.ext_router_id = cls.ext_router_data['router']['id']
        cls.ext_router_id = "19b4b453-d0e0-4b15-b103-3dd38d291cd3"
Example #10
0
 def _create_endpoints(self, region, ip):
     logger.info(
         '@@@@ Start to create endpoints for region <%s> ip <%s> @@@@' %
         (region, ip))
     reference_service = RefServices()
     reference_service.create_endpoint_for_nova(region, ip)
     reference_service.create_endpoint_for_cinder(region, ip)
     reference_service.create_endpoint_for_glance(region, ip)
     reference_service.create_endpoint_for_network(region, ip)
     reference_service.create_endpoint_for_heat(region, ip)
     reference_service.create_endpoint_for_ceilometer(region, ip)
     reference_service.create_endpoint_for_ec2(region, ip)
     logger.info(
         '@@@@ End to create endpoints for region <%s> ip <%s> @@@@' %
         (region, ip))