# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
#     def on_timeout(proc):
#     def on_execute(proc):
#     def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):


import errno
import os
import os_brick.privileged
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick.privileged import rootwrap
#         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.





LOG = logging.getLogger(__name__)


@os_brick.privileged.default.entrypoint
def create_hostnqn():
    """Create the hostnqn file to speed up finding out the nqn.

    By having the /etc/nvme/hostnqn not only do we make sure that that value is
    always used on this system, but we are also able to just open the file to
    get the nqn on each get_connector_properties call instead of having to make
    a call to nvme show-hostnqn command.
    """
    host_nqn = ''
    try:
        os.makedirs('/etc/nvme', mode=0o755, exist_ok=True)

        # Try to get existing nqn generated from dmi or systemd
        try:

# Path: os_brick/privileged/rootwrap.py
# LOG = logging.getLogger(__name__)
# def custom_execute(*cmd, **kwargs):
#     def on_timeout(proc):
#     def on_execute(proc):
#     def on_completion(proc):
# def execute(*cmd, **kwargs):
# def execute_root(*cmd, **kwargs):
# def unlink_root(*links, **kwargs):


# Path: os_brick/privileged/nvmeof.py
import errno
import os
import os_brick.privileged
from oslo_concurrency import processutils as putils
from oslo_log import log as logging
from os_brick.privileged import rootwrap

#         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.





LOG = logging.getLogger(__name__)


@os_brick.privileged.default.entrypoint
def create_hostnqn():
    """Create the hostnqn file to speed up finding out the nqn.

    By having the /etc/nvme/hostnqn not only do we make sure that that value is
    always used on this system, but we are also able to just open the file to
    get the nqn on each get_connector_properties call instead of having to make
    a call to nvme show-hostnqn command.
    """
    host_nqn = ''
    try:
        os.makedirs('/etc/nvme', mode=0o755, exist_ok=True)

        # Try to get existing nqn generated from dmi or systemd
        try:

            host_nqn, err = rootwrap.custom_execute('nvme', 'show-hostnqn')