示例#1
0
    def _set_proto_access_type_map(self):
        conf_proto_at_map = CONF.manila.proto_access_type_map
        conf_proto_at_map = dict(
            (k.upper(), v.lower()) for k, v in conf_proto_at_map.items())
        unable_proto = [
            k for k in conf_proto_at_map.keys()
            if k not in PROTO_ACCESS_TYPE_MAP.keys()
        ]
        if unable_proto:
            raise exceptions.InvalidProtocol(
                "Find temporary unable share protocol {0}".format(
                    unable_proto))

        self.proto_access_type_map = dict()
        for key, value in PROTO_ACCESS_TYPE_MAP.items():
            if key in conf_proto_at_map:
                if conf_proto_at_map[key] in value:
                    self.proto_access_type_map[key] = conf_proto_at_map[key]
                else:
                    raise exceptions.InvalidAccessType(
                        "Access type {0} is not enabled for share "
                        "protocol {1}, please chose from {2}".format(
                            conf_proto_at_map[key], key,
                            PROTO_ACCESS_TYPE_MAP[key]))
            else:
                self.proto_access_type_map[key] = value[0]
示例#2
0
 def _get_access_to(self, access_type):
     if access_type == IP:
         access_to = CONF.my_ip
         if not access_to:
             raise exceptions.InvalidAccessTo("The my_ip could not be None")
         return access_to
     elif access_type == CERT:
         access_to = CONF.manila.access_to_for_cert
         if not access_to:
             raise exceptions.InvalidAccessTo(
                 "The access_to_for_cert could not be None")
         return CONF.manila.access_to_for_cert
     raise exceptions.InvalidAccessType(
         "The access type %s is not enabled" % access_type)