当前位置: 首页>>代码示例>>Python>>正文


Python AppScaleLogger.verbose方法代码示例

本文整理汇总了Python中appscale.tools.appscale_logger.AppScaleLogger.verbose方法的典型用法代码示例。如果您正苦于以下问题:Python AppScaleLogger.verbose方法的具体用法?Python AppScaleLogger.verbose怎么用?Python AppScaleLogger.verbose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在appscale.tools.appscale_logger.AppScaleLogger的用法示例。


在下文中一共展示了AppScaleLogger.verbose方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: terminate_instances

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def terminate_instances(self, parameters):
    """ Deletes the instances specified in 'parameters' running in Google
    Compute Engine.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key mapping to a list of
        instance names that should be deleted.
    """
    instance_ids = parameters[self.PARAM_INSTANCE_IDS]
    responses = []
    for instance_id in instance_ids:
      gce_service, credentials = self.open_connection(parameters)
      http = httplib2.Http()
      auth_http = credentials.authorize(http)
      request = gce_service.instances().delete(
        project=parameters[self.PARAM_PROJECT],
        zone=parameters[self.PARAM_ZONE],
        instance=instance_id
      )
      response = request.execute(http=auth_http)
      AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
      responses.append(response)

    for response in responses:
      gce_service, credentials = self.open_connection(parameters)
      http = httplib2.Http()
      auth_http = credentials.authorize(http)
      self.ensure_operation_succeeds(gce_service, auth_http, response,
        parameters[self.PARAM_PROJECT])
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:32,代码来源:gce_agent.py

示例2: add_access_config

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def add_access_config(self, parameters, instance_id, static_ip):
    """ Instructs Google Compute Engine to use the given IP address as the
    public IP for the named instance.

    This assumes that there is no existing public IP address for the named
    instance. If this is not the case, callers should use delete_access_config
    first to remove it.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key mapping to a list of
        instance names that should be deleted.
      instance_id: A str naming the running instance that the new public IP
        address should be added to.
      static_ip: A str naming the already allocated static IP address that
        will be used for the named instance.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.instances().addAccessConfig(
      project=parameters[self.PARAM_PROJECT],
      instance=instance_id,
      networkInterface="nic0",
      zone=parameters[self.PARAM_ZONE],
      body={
        "kind": "compute#accessConfig",
        "type" : "ONE_TO_ONE_NAT",
        "name" : "External NAT",
        "natIP" : static_ip
      }
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:36,代码来源:gce_agent.py

示例3: create_network_interface

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def create_network_interface(self, network_client, interface_name, ip_name,
                               subnet, parameters):
    """ Creates the Public IP Address resource and uses that to create the
    Network Interface.
    Args:
      network_client: A NetworkManagementClient instance.
      interface_name: The name to use for the Network Interface.
      ip_name: The name to use for the Public IP Address.
      subnet: The Subnet resource from the Virtual Network created.
      parameters:  A dict, containing all the parameters necessary to
        authenticate this user with Azure.
    """
    group_name = parameters[self.PARAM_RESOURCE_GROUP]
    region = parameters[self.PARAM_ZONE]
    verbose = parameters[self.PARAM_VERBOSE]
    AppScaleLogger.verbose("Creating/Updating the Public IP Address '{}'".
                           format(ip_name), verbose)
    ip_address = PublicIPAddress(
      location=region, public_ip_allocation_method=IPAllocationMethod.dynamic,
      idle_timeout_in_minutes=4)
    result = network_client.public_ip_addresses.create_or_update(
      group_name, ip_name, ip_address)
    self.sleep_until_update_operation_done(result, ip_name, verbose)
    public_ip_address = network_client.public_ip_addresses.get(group_name, ip_name)

    AppScaleLogger.verbose("Creating/Updating the Network Interface '{}'".
                           format(interface_name), verbose)
    network_interface_ip_conf = NetworkInterfaceIPConfiguration(
      name=interface_name, private_ip_allocation_method=IPAllocationMethod.dynamic,
      subnet=subnet, public_ip_address=PublicIPAddress(id=(public_ip_address.id)))

    result = network_client.network_interfaces.create_or_update(group_name,
      interface_name, NetworkInterface(location=region,
                                       ip_configurations=[network_interface_ip_conf]))
    self.sleep_until_update_operation_done(result, interface_name, verbose)
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:37,代码来源:azure_agent.py

示例4: does_address_exist

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def does_address_exist(self, parameters):
    """ Queries Google Compute Engine to see if the specified static IP address
    exists for this user.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key indicating the name of the
        static IP address that we should check for existence.
    Returns:
      True if the named address exists, and False otherwise.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.addresses().list(
      project=parameters[self.PARAM_PROJECT],
      filter="address eq {0}".format(parameters[self.PARAM_STATIC_IP]),
      region=parameters[self.PARAM_REGION]
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])

    if 'items' in response:
      return True
    else:
      return False
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:28,代码来源:gce_agent.py

示例5: create_virtual_network

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
 def create_virtual_network(self, network_client, parameters, network_name,
                            subnet_name):
   """ Creates the network resources, such as Virtual network and Subnet.
   Args:
     network_client: A NetworkManagementClient instance.
     parameters:  A dict, containing all the parameters necessary to
       authenticate this user with Azure.
     network_name: The name to use for the Virtual Network resource.
     subnet_name: The name to use for the Subnet resource.
   Returns:
     A Subnet instance from the Virtual Network created.
   """
   group_name = parameters[self.PARAM_RESOURCE_GROUP]
   region = parameters[self.PARAM_ZONE]
   verbose = parameters[self.PARAM_VERBOSE]
   AppScaleLogger.verbose("Creating/Updating the Virtual Network '{}'".
                          format(network_name), verbose)
   address_space = AddressSpace(address_prefixes=['10.1.0.0/16'])
   subnet1 = Subnet(name=subnet_name, address_prefix='10.1.0.0/24')
   result = network_client.virtual_networks.create_or_update(group_name, network_name,
     VirtualNetwork(location=region, address_space=address_space,
                    subnets=[subnet1]))
   self.sleep_until_update_operation_done(result, network_name, verbose)
   subnet = network_client.subnets.get(group_name, network_name, subnet_name)
   return subnet
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:27,代码来源:azure_agent.py

示例6: create_firewall

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def create_firewall(self, parameters, network_url):
    """ Creates a new firewall in Google Compute Engine with the specified name,
    bound to the specified network.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key indicating the name of the
        firewall that we should create.
      network_url: A str containing the URL of the network that this new
        firewall should be applied to.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.firewalls().insert(
      project=parameters[self.PARAM_PROJECT],
      body={
        "name" : parameters[self.PARAM_GROUP],
        "description" : "Firewall used for AppScale instances",
        "network" : network_url,
        "sourceRanges" : ["0.0.0.0/0"],
        "allowed" : [
          {"IPProtocol" : "tcp", "ports": ["1-65535"]},
          {"IPProtocol" : "udp", "ports": ["1-65535"]},
          {"IPProtocol" : "icmp"}
        ]
      }
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
    self.ensure_operation_succeeds(gce_service, auth_http, response,
      parameters[self.PARAM_PROJECT])
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:34,代码来源:gce_agent.py

示例7: create_network

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def create_network(self, parameters):
    """ Creates a new network in Google Compute Engine with the specified name.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key indicating the name of the
        network that we should create in GCE.
    Returns:
      The URL corresponding to the name of the network that was created, for use
      with binding this network to one or more firewalls.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.networks().insert(
      project=parameters[self.PARAM_PROJECT],
      body={
        "name" : parameters[self.PARAM_GROUP],
        "description" : "Network used for AppScale instances",
        "IPv4Range" : "10.240.0.0/16"
      }
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
    self.ensure_operation_succeeds(gce_service, auth_http, response,
      parameters[self.PARAM_PROJECT])
    return response['targetLink']
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:29,代码来源:gce_agent.py

示例8: does_ssh_key_exist

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def does_ssh_key_exist(self, parameters):
    """ Queries Google Compute Engine to see if the specified SSH key exists.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine. We don't have an additional key for the name of
        the SSH key, since we use the one in ~/.ssh.
    Returns:
      A tuple of two items. The first item is a bool that is True if
        our public key's contents are in GCE, and False otherwise, while
        the second item is the contents of all SSH keys stored in GCE.
    """
    our_public_ssh_key = None
    public_ssh_key_location = LocalState.LOCAL_APPSCALE_PATH + \
      parameters[self.PARAM_KEYNAME] + ".pub"
    with open(public_ssh_key_location) as file_handle:
      system_user = os.getenv('LOGNAME', default=pwd.getpwuid(os.getuid())[0])
      our_public_ssh_key = system_user + ":" + file_handle.read().rstrip()

    gce_service, credentials = self.open_connection(parameters)
    try:
      http = httplib2.Http()
      auth_http = credentials.authorize(http)
      request = gce_service.projects().get(
        project=parameters[self.PARAM_PROJECT])
      response = request.execute(http=auth_http)
      AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])

      if not 'items' in response['commonInstanceMetadata']:
        return False, ""

      metadata = response['commonInstanceMetadata']['items']
      if not metadata:
        return False, ""

      all_ssh_keys = ""
      for item in metadata:
        if item['key'] != 'sshKeys':
          continue

        # Now that we know there's one or more SSH keys, just make sure that
        # ours is in this list.
        all_ssh_keys = item['value']
        if our_public_ssh_key in all_ssh_keys:
          return True, all_ssh_keys

      return False, all_ssh_keys
    except errors.HttpError:
      return False, ""
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:51,代码来源:gce_agent.py

示例9: sleep_until_update_operation_done

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
 def sleep_until_update_operation_done(self, result, resource_name, verbose):
   """ Sleeps until the create/update operation for the resource is completed
     successfully.
     Args:
       result: An instance, of the AzureOperationPoller to poll for the status
         of the operation being performed.
       resource_name: The name of the resource being updated.
   """
   time_start = time.time()
   while not result.done():
     AppScaleLogger.verbose("Waiting {0} second(s) for {1} to be created/updated.".
                            format(self.SLEEP_TIME, resource_name), verbose)
     time.sleep(self.SLEEP_TIME)
     total_sleep_time = time.time() - time_start
     if total_sleep_time > self.MAX_SLEEP_TIME:
       AppScaleLogger.log("Waited {0} second(s) for {1} to be created/updated. "
         "Operation has timed out.".format(total_sleep_time, resource_name))
       break
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:20,代码来源:azure_agent.py

示例10: create_ssh_key

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def create_ssh_key(self, parameters, all_ssh_keys):
    """ Creates a new SSH key in Google Compute Engine with the contents of
    our newly generated public key.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine.
      all_ssh_keys: A str that contains all of the SSH keys that are
        currently passed in to GCE instances.
    """
    our_public_ssh_key = None
    public_ssh_key_location = LocalState.LOCAL_APPSCALE_PATH + \
      parameters[self.PARAM_KEYNAME] + ".pub"
    with open(public_ssh_key_location) as file_handle:
      system_user = os.getenv('LOGNAME', default=pwd.getpwuid(os.getuid())[0])
      public_ssh_key = file_handle.read().rstrip()
      our_public_ssh_keys = "{system_user}:{key}\nroot:{key}".format(
                            system_user=system_user, key=public_ssh_key)

    if all_ssh_keys:
      new_all_ssh_keys = our_public_ssh_keys + "\n" + all_ssh_keys
    else:
      new_all_ssh_keys = our_public_ssh_key

    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.projects().setCommonInstanceMetadata(
      project=parameters[self.PARAM_PROJECT],
      body={
        "kind": "compute#metadata",
        "items": [{
          "key": "sshKeys",
          "value": new_all_ssh_keys
        }]
      }
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
    self.ensure_operation_succeeds(gce_service, auth_http, response,
      parameters[self.PARAM_PROJECT])
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:43,代码来源:gce_agent.py

示例11: sleep_until_delete_operation_done

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
 def sleep_until_delete_operation_done(self, result, resource_name,
                                       max_sleep, verbose):
   """ Sleeps until the delete operation for the resource is completed
   successfully.
   Args:
     result: An instance, of the AzureOperationPoller to poll for the status
       of the operation being performed.
     resource_name: The name of the resource being deleted.
     max_sleep: The maximum number of seconds to sleep for the resources to
       be deleted.
     verbose: A boolean indicating whether or not in verbose mode.
   """
   time_start = time.time()
   while not result.done():
     AppScaleLogger.verbose("Waiting {0} second(s) for {1} to be deleted.".
                            format(self.SLEEP_TIME, resource_name), verbose)
     time.sleep(self.SLEEP_TIME)
     total_sleep_time = time.time() - time_start
     if total_sleep_time > max_sleep:
       AppScaleLogger.log("Waited {0} second(s) for {1} to be deleted. "
         "Operation has timed out.".format(total_sleep_time, resource_name))
       break
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:24,代码来源:azure_agent.py

示例12: does_image_exist

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def does_image_exist(self, parameters):
    """ Queries Google Compute Engine to see if the specified image exists for
    this user.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key indicating the name of the
        image that we should check for existence.
    Returns:
      True if the named image exists, and False otherwise.
    """
    gce_service, credentials = self.open_connection(parameters)
    try:
      http = httplib2.Http()
      auth_http = credentials.authorize(http)
      request = gce_service.images().get(project=parameters[self.PARAM_PROJECT],
        image=parameters[self.PARAM_IMAGE_ID])
      response = request.execute(http=auth_http)
      AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
      return True
    except errors.HttpError:
      return False
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:24,代码来源:gce_agent.py

示例13: describe_instances

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def describe_instances(self, parameters, pending=False):
    """ Queries Google Compute Engine to see which instances are currently
    running, and retrieve information about their public and private IPs.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine.
      pending: Boolean if we should show pending instances.
    Returns:
      A tuple of the form (public_ips, private_ips, instance_ids), where each
        member is a list. Items correspond to each other across these lists,
        so a caller is guaranteed that item X in each list belongs to the same
        virtual machine.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.instances().list(
      project=parameters[self.PARAM_PROJECT],
      filter="name eq {group}-.*".format(group=parameters[self.PARAM_GROUP]),
      zone=parameters[self.PARAM_ZONE]
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])

    instance_ids = []
    public_ips = []
    private_ips = []

    if response and 'items' in response:
      instances = response['items']
      for instance in instances:
        if instance['status'] == "RUNNING":
          instance_ids.append(instance['name'])
          network_interface = instance['networkInterfaces'][0]
          public_ips.append(network_interface['accessConfigs'][0]['natIP'])
          private_ips.append(network_interface['networkIP'])

    return public_ips, private_ips, instance_ids
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:41,代码来源:gce_agent.py

示例14: delete_firewall

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def delete_firewall(self, parameters):
    """ Deletes a firewall in Google Compute Engine with the specified name.

    Callers should not invoke this method until they are certain that no
    instances are using the specified firewall, or this method will fail.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine, and an additional key indicating the name of the
        firewall that we should create.
    """
    gce_service, credentials = self.open_connection(parameters)
    http = httplib2.Http()
    auth_http = credentials.authorize(http)
    request = gce_service.firewalls().delete(
      project=parameters[self.PARAM_PROJECT],
      firewall=parameters[self.PARAM_GROUP]
    )
    response = request.execute(http=auth_http)
    AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
    self.ensure_operation_succeeds(gce_service, auth_http, response,
      parameters[self.PARAM_PROJECT])
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:24,代码来源:gce_agent.py

示例15: does_disk_exist

# 需要导入模块: from appscale.tools.appscale_logger import AppScaleLogger [as 别名]
# 或者: from appscale.tools.appscale_logger.AppScaleLogger import verbose [as 别名]
  def does_disk_exist(self, parameters, disk):
    """ Queries Google Compute Engine to see if the specified persistent disk
    exists for this user.

    Args:
      parameters: A dict with keys for each parameter needed to connect to
        Google Compute Engine.
      disk: A str containing the name of the disk that we should check for
        existence.
    Returns:
      True if the named persistent disk exists, and False otherwise.
    """
    gce_service, credentials = self.open_connection(parameters)
    try:
      http = httplib2.Http()
      auth_http = credentials.authorize(http)
      request = gce_service.disks().get(project=parameters[self.PARAM_PROJECT],
        disk=disk, zone=parameters[self.PARAM_ZONE])
      response = request.execute(http=auth_http)
      AppScaleLogger.verbose(str(response), parameters[self.PARAM_VERBOSE])
      return True
    except errors.HttpError:
      return False
开发者ID:menivaitsi,项目名称:appscale-tools,代码行数:25,代码来源:gce_agent.py


注:本文中的appscale.tools.appscale_logger.AppScaleLogger.verbose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。