Gets the path to the script describing a cloud.

 === Parameters
 cloud_name(String):: a registered_type cloud name

 === Return
 cloud_script_path(String):: path to script used to describe cloud on creation

 === Raise
 UnknownCloud:: on error
169765
def registered_script_path(cloud_name)
      cloud_script_path = registered_type(cloud_name)
      raise UnknownCloud.new("Unknown cloud: #{cloud_name}") unless cloud_script_path
      return cloud_script_path
    end
943941
def auto_find_instance_path(self) -> Path:
        
        prefix, package_path = find_package(self.import_name)
        if prefix is None:
            return package_path / "instance"
        return prefix / "var" / f"{self.name}-instance"
86280
def get_project_id():
    
    if os.name == 'nt':
        command = _CLOUD_SDK_WINDOWS_COMMAND
    else:
        command = _CLOUD_SDK_POSIX_COMMAND

    try:
        output = subprocess.check_output(
            (command,) + _CLOUD_SDK_CONFIG_COMMAND,
            stderr=subprocess.STDOUT)
    except (subprocess.CalledProcessError, OSError, IOError):
        return None

    try:
        configuration = json.loads(output.decode('utf-8'))
    except ValueError:
        return None

    try:
        return configuration['configuration']['properties']['core']['project']
    except KeyError:
        return None
1111400
def _get_scripts(self, scripts_path_rel, files_deployment, script_type, project_path):
        

        scripts_dict = {}
        if scripts_path_rel:

            self._logger.debug('Getting scripts with {0} definitions'.format(script_type))
            scripts_dict = pgpm.lib.utils.misc.collect_scripts_from_sources(scripts_path_rel, files_deployment,
                                                                            project_path, False, self._logger)
            if len(scripts_dict) == 0:
                self._logger.debug('No {0} definitions were found in {1} folder'.format(script_type, scripts_path_rel))
        else:
            self._logger.debug('No {0} folder was specified'.format(script_type))

        return scripts_dict
57561
def name_url(provider, cloud, method_name):
    
    snake_parts = method_name.split('_')
    if len(snake_parts) <= 1:
        return False

    # Convention for libcloud is ex_ are extended methods
    if snake_parts[0] == 'ex':
        extra = True
        method_name = method_name.replace('ex_', '', 1)
    else:
        extra = False
    snake_parts = method_name.split('_')
    # Try to semantically match the method name to a REST action
    if snake_parts[0] in get_sem_verbs:
        method = 'GET'
        for verb in get_sem_verbs:
            method_name = method_name.replace('%s_' % verb, '', 1)
    elif snake_parts[0] in delete_sem_verbs:
        method = 'DELETE'
    elif snake_parts[0] in put_sem_verbs:
        method = 'PUT'
    else:
        method = 'POST'

    uri = '/%s/%s/%s%s' % (provider,
                           cloud,
                           'extensions/' if extra else '',
                           method_name)
    return (method, uri)
987590
def path(self):
        

        # Need to do this to ensure the function produces the
        # bundle path when called from subclasses
        names = [k for k, _, _ in Name._name_parts]

        return os.path.join(self.source,
                            self._path_join(names=names, excludes=['source', 'format'], sep=self.NAME_PART_SEP),
                            *self._local_parts()
                            )
709437
def getUser(cls, cloud):
        
        try:
            config = d = ConfigDict("cloudmesh.yaml")

            d = ConfigDict("cloudmesh.yaml")

            #
            # bug: cloud is none when adding a group
            #

            config = d["cloudmesh"]["clouds"][cloud]
            credentials = config["credentials"]
            cloud_type = config["cm_type"]

            if cloud_type == "openstack":
                return credentials["OS_USERNAME"]
            else:
                raise ValueError("getUser for this cloud type not yet "
                                 "supported: {}".format(cloud))
        except Exception as ex:
            Console.error("problem getting user")
358546
def script(server_):
    ''' 
    '''
    return salt.utils.cloud.os_script(
        config.get_cloud_config_value('script', server_, __opts__),
        server_,
        __opts__,
        salt.utils.cloud.salt_config_to_yaml(
            salt.utils.cloud.minion_config(__opts__, server_)
        )
    )
912752
def cloudshell_model_name(self):
        """"""
        if self.shell_name:
            return "{shell_name}.{resource_model}".format(shell_name=self.shell_name,
                                                          resource_model=self.RESOURCE_MODEL.replace(" ", ""))
        else:
            return self.RESOURCE_MODEL
1194847
def python_path(self, script):
        
        if not script:
            try:
                import __main__
                script = getfile(__main__)
            except Exception:  # pragma    nocover
                return
        script = os.path.realpath(script)
        if self.cfg.get('python_path', True):
            path = os.path.dirname(script)
            if path not in sys.path:
                sys.path.insert(0, path)
        return script
1096190
def provide_temporary_scripts_path(self):
        """"""
        if len(self.options.temporary_scripts_path) > 0:
            if os.path.isfile(self.options.temporary_scripts_path):
                self.logger.error("Error: configured script path seems to be a file!")
                # it's ok to leave because called before the collector runs
                sys.exit(1)

            if not os.path.isdir(self.options.temporary_scripts_path):
                os.makedirs(self.options.temporary_scripts_path)
323403
def _get_url_path(list_name):
    
    access_key = getattr(settings,
                         "RESTCLIENTS_MAILMAN_KEY",
                         "__mock_key__")
    return URL.format(key=access_key, uwnetid=list_name)
693705
def build_path_to(script_name = nil, *args)
    args.compact!
    query = args.pop if args.last.kind_of?(Hash)
    path  = map_path_to(script_name, *args)
    path << "?" << Rack::Utils::build_query(query) if query
    path
  end
580886
def _init_cloud(self, cloud_arg):
        
        # Disable too broad exception warning
        # pylint: disable=W0703
        cloud = None
        if cloud_arg:
            try:
                if hasattr(self.args, "cm"):
                    cloud_module = self.args.cm if self.args.cm else None
                    self.logger.info("Creating cloud module {}.".format(cloud_module))
                else:
                    cloud_module = None

                cloud = Cloud(host=None, module=cloud_module, logger=self.logger, args=self.args)
            except Exception as error:
                self.logger.warning("Cloud module could not be initialized: {}".format(error))
                cloud = None
        return cloud
422353
def show_instance(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The show_instance action must be called with -a or --action.'
        )

    nodes = list_nodes_full()
    # Find under which cloud service the name is listed, if any
    if name not in nodes:
        return {}
    if 'name' not in nodes[name]:
        nodes[name]['name'] = nodes[name]['id']
    try:
        __utils__['cloud.cache_node'](nodes[name], __active_provider_name__, __opts__)
    except TypeError:
        log.warning('Unable to show cache node data; this may be because the node has been deleted')
    return nodes[name]
1295518
def __get_container_path(self, host_path):
    
    libname = os.path.split(host_path)[1]
    return os.path.join(_container_lib_location, libname)
418399
def load_cloudformation_template(path=None):
    
    if not path:
        path = os.path.abspath('cloudformation.py')
    else:
        path = os.path.abspath(path)
    if isinstance(path, six.string_types):
        try:
            sp = sys.path
            # temporarily add folder to allow relative path
            sys.path.append(os.path.abspath(os.path.dirname(path)))
            cloudformation = imp.load_source('cloudformation', path)
            sys.path = sp  # restore
            # use cfn template hooks
            if not check_hook_mechanism_is_intact(cloudformation):
                # no hooks - do nothing
                log.debug(
                    'No valid hook configuration: \'%s\'. Not using hooks!',
                    path)
            else:
                if check_register_present(cloudformation):
                    # register the template hooks so they listen to gcdt_signals
                    cloudformation.register()
            return cloudformation, True
        except GracefulExit:
            raise
        except ImportError as e:
            print('could not find package for import: %s' % e)
        except Exception as e:
            print('could not import cloudformation.py, maybe something wrong ',
                  'with your code?')
            print(e)
    return None, False