Пример #1
0
  def testCreateConnection_Success(self):
    """Test CreateConnection returns operation when successful."""
    want = self.services_messages.Operation(
        name=self.OPERATION_NAME, done=False)
    self.ExpectCreateConnection(self.NETWORK, self.RANGES, self.OPERATION_NAME)

    got = peering.CreateConnection(self.PROJECT_NUMBER, self.service,
                                   self.NETWORK, self.RANGES)

    self.assertEqual(got, want)
Пример #2
0
  def testCreateConnection_PermissionDenied(self):
    """Test CreateConnection raises correctly when server returns 403 error."""
    server_error = http_error.MakeDetailedHttpError(code=403, message='Error!')
    self.ExpectCreateConnection(
        self.NETWORK, self.RANGES, None, error=server_error)

    with self.assertRaisesRegex(
        exceptions.CreateConnectionsPermissionDeniedException, r'Error!'):
      peering.CreateConnection(self.PROJECT_NUMBER, self.service, self.NETWORK,
                               self.RANGES)
Пример #3
0
    def Run(self, args):
        """Run 'services vpc-peerings connect'.

    Args:
      args: argparse.Namespace, The arguments that this command was invoked
          with.

    Returns:
      Nothing.
    """
        project = properties.VALUES.core.project.Get(required=True)
        project_number = _GetProjectNumber(project)
        reserved_ranges = args.reserved_ranges.split(',')
        op = peering.CreateConnection(project_number, args.service,
                                      args.network, reserved_ranges)
        if args. async:
            cmd = OP_WAIT_CMD.format(op.name)
            log.status.Print('Asynchronous operation is in progress... '
                             'Use the following command to wait for its '
                             'completion:\n {0}'.format(cmd))
            return
        op = peering.WaitOperation(op.name)
        services_util.PrintOperation(op)