Ejemplo n.º 1
0
    def determine_openstack_user(self):

        # The user can specify an openstack_user using the flags, or they can leave it blank
        # and we'll attempt to discover the user. If failing to discover we'll default to 
        # the same user as the nova-gridcentric process.
        user = FLAGS.openstack_user
        if user == '':
            # Attempt to determine the openstack user.
            try:
                # use ps to determine the user running the nova-compute process
                cmd = "ps aux | grep nova-compute | grep python | grep -v grep | awk '{print $1}'"
                _, cmd_user, _ = utilities.check_command(cmd)
                user = cmd_user.strip()
            except:
                user = ''

            if user == '':
                # We were unable to determine the user. We'll just default to our current user.
                user = os.getuid()

        return user
Ejemplo n.º 2
0
def touch_as(path, uid):
    utilities.check_command(['sudo', '-u', '#%d' % uid, 'touch', path])
Ejemplo n.º 3
0
def mkdir_as(path, uid):
    utilities.check_command(['sudo', '-u', '#%d' % uid, 'mkdir', '-p', path])
Ejemplo n.º 4
0
def touch_as(path, uid):
    utilities.check_command(['sudo', '-u', '#%d' % uid, 'touch', path])
Ejemplo n.º 5
0
def mkdir_as(path, uid):
    utilities.check_command(['sudo', '-u', '#%d' % uid, 'mkdir', '-p', path])
Ejemplo n.º 6
0
def run_as(cmd, uid):
    sudo_cmd = ['sudo', '-u', '#%d' % uid]
    sudo_cmd += cmd
    utilities.check_command(sudo_cmd)
Ejemplo n.º 7
0
def run_as(cmd, uid):
    sudo_cmd = ['sudo', '-u', '#%d' % uid]
    sudo_cmd += cmd
    utilities.check_command(sudo_cmd)