def check_for_setup_error(self): """Returns an error if prerequisites aren't met.""" host_address_obj = types.HostAddress() for export_ip in self.config.cephfs_ganesha_export_ips: try: host_address_obj(export_ip) except ValueError: msg = (_("Invalid list member of 'cephfs_ganesha_export_ips' " "option supplied %s -- not a valid IP address or " "hostname.") % export_ip) raise exception.InvalidParameterValue(err=msg)
class HostAddressTypeTests(TypeTestHelper, unittest.TestCase): type = types.HostAddress() def test_invalid_host_addresses(self): self.assertInvalid('-1') self.assertInvalid('_foo') self.assertInvalid('3.14') self.assertInvalid('10.0') self.assertInvalid('host..name') self.assertInvalid('org.10') self.assertInvalid('0.0.00') def test_valid_host_addresses(self): self.assertConvertedValue('foo.bar', 'foo.bar') self.assertConvertedValue('192.168.0.1', '192.168.0.1') self.assertConvertedValue('abcd:ef::1', 'abcd:ef::1') self.assertConvertedValue('home-site-here.org.com', 'home-site-here.org.com') self.assertConvertedValue('3com.com', '3com.com') self.assertConvertedValue('10.org', '10.org') self.assertConvertedValue('cell1.nova.site1', 'cell1.nova.site1') self.assertConvertedValue('ab-c.com', 'ab-c.com') self.assertConvertedValue('abc.com-org', 'abc.com-org') self.assertConvertedValue('abc.0-0', 'abc.0-0')
# # 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. from oslo_config import cfg from oslo_config import types cassandra_opts = [ cfg.ListOpt('cluster_ip_addresses', default=['127.0.0.1'], item_type=types.HostAddress(), help=''' Comma separated list of Cassandra node IP addresses '''), cfg.StrOpt('keyspace', default='monasca', help=''' keyspace where metric are stored ''') ] cassandra_group = cfg.OptGroup(name='cassandra') def register_opts(conf): conf.register_group(cassandra_group)
address = self(value) return "%s(%s)" % (address, value) def __repr__(self): return "InterfaceAddress" def __eq__(self, other): return self.__class__ == other.__class__ bgp_opts = [ cfg.Opt('local_address', required=True, type=InterfaceAddress(), help="IP address used for BGP peerings"), cfg.ListOpt('peers', default=[], item_type=types.HostAddress(version=4), help="IP addresses of BGP peers"), cfg.IntOpt('my_as', min=1, max=2**16-1, required=True, help="Our BGP Autonomous System"), cfg.BoolOpt('enable_rtc', default=True, help="Enable RT Constraint (RFC4684)"), cfg.PortOpt('bgp_port', default=179, help="TCP port of connections to BGP peers") ] def register(): cfg.CONF.register_opts(bgp_opts, "BGP") def set_default_root_helper():