def test_all_ok(self):
    # If the user wants to relocate their app to port X, and nothing else
    # runs on that port, this should succeed.

    # Assume that the AppController is running, so is our app, and that other
    # apps are not running on port 80.
    fake_appcontroller = flexmock(name='fake_appcontroller')
    fake_appcontroller.should_receive('get_app_info_map').with_args(
      'the secret').and_return(json.dumps({
      self.appid : {
        'nginx' : 8080
      },
      'a-different-app' : {
        'nginx' : 81
      }
    }))
    fake_appcontroller.should_receive('relocate_app').with_args(self.appid, 80,
      443, 'the secret').and_return("OK")
    flexmock(SOAPpy)
    SOAPpy.should_receive('SOAPProxy').with_args('https://public1:17443') \
      .and_return(fake_appcontroller)

    argv = [
      '--keyname', self.keyname,
      '--appname', self.appid,
      '--http_port', '80',
      '--https_port', '443'
    ]
    options = ParseArgs(argv, self.function).args
    AppScaleTools.relocate_app(options)
    def test_all_ok(self):
        # If the user wants to relocate their app to port X, and nothing else
        # runs on that port, this should succeed.

        # Assume that the AppController is running, so is our app, and that other
        # apps are not running on port 80.
        fake_appcontroller = flexmock(name='fake_appcontroller')
        fake_appcontroller.should_receive('get_app_info_map').with_args(
            'the secret').and_return(
                json.dumps({
                    self.appid: {
                        'nginx': 8080
                    },
                    'a-different-app': {
                        'nginx': 81
                    }
                }))
        fake_appcontroller.should_receive('relocate_app').with_args(
            self.appid, 80, 443, 'the secret').and_return("OK")
        flexmock(SOAPpy)
        SOAPpy.should_receive('SOAPProxy').with_args('https://public1:17443') \
          .and_return(fake_appcontroller)

        argv = [
            '--keyname', self.keyname, '--appname', self.appid, '--http_port',
            '80', '--https_port', '443'
        ]
        options = ParseArgs(argv, self.function).args
        AppScaleTools.relocate_app(options)
Exemplo n.º 3
0
    def relocate(self, appid, http_port, https_port):
        """ 'relocate' provides a nicer experience for users than the
    appscale-terminate-instances command, by using the configuration options
    present in the AppScalefile found in the current working directory.

    Args:
      appid: A str indicating the name of the application to relocate.
      http_port: An int that indicates what port should serve HTTP traffic for
        this application.
      https_port: An int that indicates what port should serve HTTPS traffic for
        this application.
    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
      directory.
    """
        contents = self.read_appscalefile()
        contents_as_yaml = yaml.safe_load(contents)

        # Construct the appscale-relocate-app command from argv and the contents of
        # the AppScalefile.
        command = []
        if 'keyname' in contents_as_yaml:
            command.append("--keyname")
            command.append(contents_as_yaml["keyname"])

        command.append("--appname")
        command.append(appid)

        command.append("--http_port")
        command.append(str(http_port))

        command.append("--https_port")
        command.append(str(https_port))

        # and exec it
        options = ParseArgs(command, "appscale-relocate-app").args
        AppScaleTools.relocate_app(options)
Exemplo n.º 4
0
  def relocate(self, appid, http_port, https_port):
    """ 'relocate' provides a nicer experience for users than the
    appscale-terminate-instances command, by using the configuration options
    present in the AppScalefile found in the current working directory.

    Args:
      appid: A str indicating the name of the application to relocate.
      http_port: An int that indicates what port should serve HTTP traffic for
        this application.
      https_port: An int that indicates what port should serve HTTPS traffic for
        this application.
    Raises:
      AppScalefileException: If there is no AppScalefile in the current working
      directory.
    """
    contents = self.read_appscalefile()
    contents_as_yaml = yaml.safe_load(contents)

    # Construct the appscale-relocate-app command from argv and the contents of
    # the AppScalefile.
    command = []
    if 'keyname' in contents_as_yaml:
      command.append("--keyname")
      command.append(contents_as_yaml["keyname"])

    command.append("--appname")
    command.append(appid)

    command.append("--http_port")
    command.append(str(http_port))

    command.append("--https_port")
    command.append(str(https_port))

    # and exec it
    options = ParseArgs(command, "appscale-relocate-app").args
    AppScaleTools.relocate_app(options)