Example #1
0
    def _setup_for_existing_users(self):
        if (self.config["use_share_networks"]
                and not self.config["share_networks"]):
            msg = ("Usage of share networks was enabled but for deployment "
                   "with existing users share networks also should be "
                   "specified via arg 'share_networks'")
            raise exceptions.ContextSetupFailure(ctx_name=self.get_name(),
                                                 msg=msg)

        for tenant_name_or_id, share_networks in self.config[
                "share_networks"].items():
            # Verify project existence
            for tenant in self.context["tenants"].values():
                if tenant_name_or_id in (tenant["id"], tenant["name"]):
                    tenant_id = tenant["id"]
                    existing_user = None
                    for user in self.context["users"]:
                        if user["tenant_id"] == tenant_id:
                            existing_user = user
                            break
                    break
            else:
                msg = ("Provided tenant Name or ID '%s' was not found in "
                       "existing tenants.") % tenant_name_or_id
                raise exceptions.ContextSetupFailure(ctx_name=self.get_name(),
                                                     msg=msg)
            self.context["tenants"][tenant_id][CONTEXT_NAME] = {}
            self.context["tenants"][tenant_id][CONTEXT_NAME][
                "share_networks"] = []

            manila_scenario = manila_utils.ManilaScenario(
                {"user": existing_user})
            existing_sns = manila_scenario._list_share_networks(
                detailed=False, search_opts={"project_id": tenant_id})

            for sn_name_or_id in share_networks:
                # Verify share network existence
                for sn in existing_sns:
                    if sn_name_or_id in (sn.id, sn.name):
                        break
                else:
                    msg = ("Specified share network '%(sn)s' does not "
                           "exist for tenant '%(tenant_id)s'" % {
                               "sn": sn_name_or_id,
                               "tenant_id": tenant_id
                           })
                    raise exceptions.ContextSetupFailure(
                        ctx_name=self.get_name(), msg=msg)

                # Set share network for project
                self.context["tenants"][tenant_id][CONTEXT_NAME][
                    "share_networks"].append(sn.to_dict())
Example #2
0
 def setup(self):
     for user, tenant_id in self._iterate_per_tenants():
         manila_scenario = manila_utils.ManilaScenario({
             "task":
             self.task,
             "owner_id":
             self.context["owner_id"],
             "user":
             user
         })
         self._create_shares(
             manila_scenario,
             tenant_id,
             self.config["share_proto"],
             self.config["size"],
             self.config["share_type"],
         )
Example #3
0
    def _setup_for_autocreated_users(self):
        # Create share network for each network of tenant
        for user, tenant_id in (self._iterate_per_tenants(
                self.context.get("users", []))):
            networks = self.context["tenants"][tenant_id].get("networks")
            manila_scenario = manila_utils.ManilaScenario({
                "task":
                self.task,
                "owner_id":
                self.get_owner_id(),
                "user":
                user
            })
            manila_scenario.RESOURCE_NAME_FORMAT = self.RESOURCE_NAME_FORMAT
            self.context["tenants"][tenant_id][CONTEXT_NAME] = {
                "share_networks": []
            }
            data = {}

            def _setup_share_network(tenant_id, data):
                share_network = manila_scenario._create_share_network(
                    **data).to_dict()
                self.context["tenants"][tenant_id][CONTEXT_NAME][
                    "share_networks"].append(share_network)
                for ss in self.context["tenants"][tenant_id].get(
                        consts.SECURITY_SERVICES_CONTEXT_NAME,
                    {}).get("security_services", []):
                    manila_scenario._add_security_service_to_share_network(
                        share_network["id"], ss["id"])

            if networks:
                for network in networks:
                    if network.get("cidr"):
                        data["nova_net_id"] = network["id"]
                    elif network.get("subnets"):
                        data["neutron_net_id"] = network["id"]
                        data["neutron_subnet_id"] = network["subnets"][0]
                    else:
                        LOG.warning("Can't determine network service provider."
                                    " Share network will have no data.")
                    _setup_share_network(tenant_id, data)
            else:
                _setup_share_network(tenant_id, data)
Example #4
0
 def setup(self):
     for user, tenant_id in (self._iterate_per_tenants(
             self.context.get("users", []))):
         self.context["tenants"][tenant_id][CONTEXT_NAME] = {
             "security_services": [],
         }
         if self.config["security_services"]:
             manila_scenario = manila_utils.ManilaScenario({
                 "task":
                 self.task,
                 "owner_id":
                 self.context["owner_id"],
                 "user":
                 user
             })
             for ss in self.config["security_services"]:
                 inst = manila_scenario._create_security_service(
                     **ss).to_dict()
                 self.context["tenants"][tenant_id][CONTEXT_NAME][
                     "security_services"].append(inst)
 def setUp(self):
     super(ManilaScenarioTestCase, self).setUp()
     self.scenario = utils.ManilaScenario(self.context)