def test_modify_zone_partial_credentials(self):
     multisite.modify_zone(
         'brundall-east',
         endpoints=['http://localhost:80', 'https://localhost:443'],
         access_key='mykey',
     )
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin', '--id=rgw.testhost',
         'zone', 'modify',
         '--rgw-zone=brundall-east',
         '--endpoints=http://localhost:80,https://localhost:443',
         '--read-only=0',
     ])
 def test_modify_zone_promote_master(self):
     multisite.modify_zone(
         'brundall-east',
         default=True,
         master=True,
     )
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin', '--id=rgw.testhost',
         'zone', 'modify',
         '--rgw-zone=brundall-east',
         '--master',
         '--default',
         '--read-only=0',
     ])
示例#3
0
def readwrite(args):
    """Mark zone associated with local RGW units as read write"""
    zone = config('zone')
    if not zone:
        action_fail('No zone configuration set, not marking read write')
        return
    try:
        multisite.modify_zone(zone, readonly=False)
        multisite.update_period()
        action_set(
            values={'message': 'zone:{} marked as read write'.format(zone)})
    except subprocess.CalledProcessError as cpe:
        action_fail('Unable mark zone:{} '
                    'as read write: {}'.format(zone, cpe.output))
示例#4
0
 def test_modify_zone_partial_credentials(self):
     multisite.modify_zone(
         'brundall-east',
         endpoints=['http://localhost:80', 'https://localhost:443'],
         access_key='mykey',
     )
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin',
         '--id=rgw.testhost',
         'zone',
         'modify',
         '--rgw-zone=brundall-east',
         '--endpoints=http://localhost:80,https://localhost:443',
         '--read-only=0',
     ])
示例#5
0
 def test_modify_zone_promote_master(self):
     multisite.modify_zone(
         'brundall-east',
         default=True,
         master=True,
     )
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin',
         '--id=rgw.testhost',
         'zone',
         'modify',
         '--rgw-zone=brundall-east',
         '--master',
         '--default',
         '--read-only=0',
     ])
 def test_modify_zone(self):
     multisite.modify_zone(
         'brundall-east',
         endpoints=['http://localhost:80', 'https://localhost:443'],
         access_key='mykey',
         secret='secret',
         readonly=True
     )
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin', '--id=rgw.testhost',
         'zone', 'modify',
         '--rgw-zone=brundall-east',
         '--endpoints=http://localhost:80,https://localhost:443',
         '--access-key=mykey', '--secret=secret',
         '--read-only=1',
     ])
示例#7
0
def promote(args):
    """Promote zone associated with local RGW units to master/default"""
    zone = config('zone')
    if not zone:
        action_fail('No zone configuration set, not promoting')
        return
    try:
        multisite.modify_zone(zone, default=True, master=True)
        multisite.update_period()
        action_set(
            values={
                'message': 'zone:{} promoted to '
                'master/default'.format(zone)
            })
    except subprocess.CalledProcessError as cpe:
        action_fail('Unable to promote zone:{} '
                    'to master: {}'.format(zone, cpe.output))
示例#8
0
def readwrite(args):
    """Mark zone associated with local RGW units as read write"""
    zone = config('zone')
    if not zone:
        action_fail('No zone configuration set, not marking read write')
        return
    try:
        multisite.modify_zone(zone, readonly=False)
        multisite.update_period()
        action_set(
            values={
                'message': 'zone:{} marked as read write'.format(zone)
            }
        )
    except subprocess.CalledProcessError as cpe:
        action_fail('Unable mark zone:{} '
                    'as read write: {}'.format(zone, cpe.output))
示例#9
0
def promote(args):
    """Promote zone associated with local RGW units to master/default"""
    zone = config('zone')
    if not zone:
        action_fail('No zone configuration set, not promoting')
        return
    try:
        multisite.modify_zone(zone,
                              default=True, master=True)
        multisite.update_period()
        action_set(
            values={'message': 'zone:{} promoted to '
                    'master/default'.format(zone)}
        )
    except subprocess.CalledProcessError as cpe:
        action_fail('Unable to promote zone:{} '
                    'to master: {}'.format(zone, cpe.output))
示例#10
0
 def test_modify_zone(self):
     multisite.modify_zone(
         'brundall-east',
         endpoints=['http://localhost:80', 'https://localhost:443'],
         access_key='mykey',
         secret='secret',
         readonly=True)
     self.subprocess.check_output.assert_called_with([
         'radosgw-admin',
         '--id=rgw.testhost',
         'zone',
         'modify',
         '--rgw-zone=brundall-east',
         '--endpoints=http://localhost:80,https://localhost:443',
         '--access-key=mykey',
         '--secret=secret',
         '--read-only=1',
     ])
示例#11
0
def master_relation_joined(relation_id=None):
    if not ready_for_service(legacy=False):
        log('unit not ready, deferring multisite configuration')
        return

    internal_url = '{}:{}'.format(
        canonical_url(CONFIGS, INTERNAL),
        listen_port(),
    )
    endpoints = [internal_url]
    realm = config('realm')
    zonegroup = config('zonegroup')
    zone = config('zone')
    access_key = leader_get('access_key')
    secret = leader_get('secret')

    if not all((realm, zonegroup, zone)):
        return

    relation_set(relation_id=relation_id,
                 realm=realm,
                 zonegroup=zonegroup,
                 url=endpoints[0],
                 access_key=access_key,
                 secret=secret)

    if not is_leader():
        return

    if not leader_get('restart_nonce'):
        # NOTE(jamespage):
        # This is an ugly kludge to force creation of the required data
        # items in the .rgw.root pool prior to the radosgw process being
        # started; radosgw-admin does not currently have a way of doing
        # this operation but a period update will force it to be created.
        multisite.update_period(fatal=False)

    mutation = False

    if realm not in multisite.list_realms():
        multisite.create_realm(realm, default=True)
        mutation = True

    if zonegroup not in multisite.list_zonegroups():
        multisite.create_zonegroup(zonegroup,
                                   endpoints=endpoints,
                                   default=True,
                                   master=True,
                                   realm=realm)
        mutation = True

    if zone not in multisite.list_zones():
        multisite.create_zone(zone,
                              endpoints=endpoints,
                              default=True,
                              master=True,
                              zonegroup=zonegroup)
        mutation = True

    if MULTISITE_SYSTEM_USER not in multisite.list_users():
        access_key, secret = multisite.create_system_user(
            MULTISITE_SYSTEM_USER)
        multisite.modify_zone(zone, access_key=access_key, secret=secret)
        leader_set(access_key=access_key, secret=secret)
        mutation = True

    if mutation:
        multisite.update_period()
        service_restart(service_name())
        leader_set(restart_nonce=str(uuid.uuid4()))

    relation_set(relation_id=relation_id, access_key=access_key, secret=secret)
示例#12
0
def master_relation_joined(relation_id=None):
    if not ready_for_service(legacy=False):
        log('unit not ready, deferring multisite configuration')
        return

    internal_url = '{}:{}'.format(
        canonical_url(CONFIGS, INTERNAL),
        config('port')
    )
    endpoints = [internal_url]
    realm = config('realm')
    zonegroup = config('zonegroup')
    zone = config('zone')
    access_key = leader_get('access_key')
    secret = leader_get('secret')

    if not all((realm, zonegroup, zone)):
        return

    relation_set(relation_id=relation_id,
                 realm=realm,
                 zonegroup=zonegroup,
                 url=endpoints[0],
                 access_key=access_key,
                 secret=secret)

    if not is_leader():
        return

    if not leader_get('restart_nonce'):
        # NOTE(jamespage):
        # This is an ugly kludge to force creation of the required data
        # items in the .rgw.root pool prior to the radosgw process being
        # started; radosgw-admin does not currently have a way of doing
        # this operation but a period update will force it to be created.
        multisite.update_period(fatal=False)

    mutation = False

    if realm not in multisite.list_realms():
        multisite.create_realm(realm, default=True)
        mutation = True

    if zonegroup not in multisite.list_zonegroups():
        multisite.create_zonegroup(zonegroup,
                                   endpoints=endpoints,
                                   default=True, master=True,
                                   realm=realm)
        mutation = True

    if zone not in multisite.list_zones():
        multisite.create_zone(zone,
                              endpoints=endpoints,
                              default=True, master=True,
                              zonegroup=zonegroup)
        mutation = True

    if MULTISITE_SYSTEM_USER not in multisite.list_users():
        access_key, secret = multisite.create_system_user(
            MULTISITE_SYSTEM_USER
        )
        multisite.modify_zone(zone,
                              access_key=access_key,
                              secret=secret)
        leader_set(access_key=access_key,
                   secret=secret)
        mutation = True

    if mutation:
        multisite.update_period()
        service_restart(service_name())
        leader_set(restart_nonce=str(uuid.uuid4()))

    relation_set(relation_id=relation_id,
                 access_key=access_key,
                 secret=secret)