def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('VolumeStartup'): name = json.get('VolumeStartup').get('volumeName') owner = json.get('VolumeStartup').get('owner') # Wait few seconds so that the new node is up. time.sleep(20) if name != "" and owner != "": res = self.createvolume(sid, name, owner) if 'error' in res: return res['error'] if json.get('StartupInstances'): params = {'osd': 1} if json.get('StartupInstances').get('osd'): params['osd'] = int(json.get('StartupInstances').get('osd')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'
def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('Password'): res = self.set_password(sid, json.get('Password')) if 'error' in res: return res['error'] if json.get('Dump'): res = self.load_dump(sid, json.get('Dump')) if 'error' in res: return res['error'] if json.get('StartupInstances'): params = { 'slaves': 1 } if json.get('StartupInstances').get('slaves'): params['slaves'] = int(json.get('StartupInstances').get('slaves')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'
def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('Password'): res = self.set_password(sid, json.get('Password')) if 'error' in res: return res['error'] if json.get('Dump'): res = self.load_dump(sid, json.get('Dump')) if 'error' in res: return res['error'] if json.get('StartupInstances'): params = {'slaves': 1} if json.get('StartupInstances').get('slaves'): params['slaves'] = int( json.get('StartupInstances').get('slaves')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'
def start(self, json, appid, need_env=False): """Start the given service. Return service id upon successful termination.""" servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error env = '' if need_env: env = self.update_environment(appid) url = '' if json.get('StartupScript'): url = json.get('StartupScript') if url or env: # Only upload startup script if necessary res = self.upload_startup_script(sid, url, env) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return sid # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') return sid
def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('VolumeStartup'): name = json.get('VolumeStartup').get('volumeName') owner = json.get('VolumeStartup').get('owner') # Wait few seconds so that the new node is up. time.sleep(20) if name != "" and owner != "": res = self.createvolume(sid, name, owner) if 'error' in res: return res['error'] if json.get('StartupInstances'): params = { 'osd': 1 } if json.get('StartupInstances').get('osd'): params['osd'] = int(json.get('StartupInstances').get('osd')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'
def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('Archive'): res = self.upload_code(sid, json.get('Archive')) if 'error' in res: return res['error'] res = self.enable_code(sid, res['codeVersionId']); if 'error' in res: return res['error'] if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('StartupInstances'): params = { 'proxy': 1, 'web': 1, 'backend': 1 } if json.get('StartupInstances').get('proxy'): params['proxy'] = int(json.get('StartupInstances').get('proxy')) if json.get('StartupInstances').get('web'): params['web'] = int(json.get('StartupInstances').get('web')) if json.get('StartupInstances').get('backend'): params['backend'] = int(json.get('StartupInstances').get('backend')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'
def start(self, json, appid): servicetype = json.get('Type') cloud = 'default' if json.get('Cloud'): cloud = json.get('Cloud') res = service_start(servicetype, cloud, appid) error = self.check_error(res) if error: return error sid = simplejson.loads(res.data).get('sid') self.wait_for_state(sid, 'INIT') if json.get('ServiceName'): res = service_rename(sid, json.get('ServiceName')) error = self.check_error(res) if error: return error if json.get('Archive'): res = self.upload_code(sid, json.get('Archive')) if 'error' in res: return res['error'] res = self.enable_code(sid, res['codeVersionId']) if 'error' in res: return res['error'] if json.get('StartupScript'): res = self.upload_startup_script(sid, json.get('StartupScript')) if 'error' in res: return res['error'] if not json.get('Start') or json.get('Start') == 0: return 'ok' # Start == 1 res = self.startup(sid) if 'error' in res: return res['error'] self.wait_for_state(sid, 'RUNNING') if json.get('StartupInstances'): params = {'proxy': 1, 'web': 1, 'backend': 1} if json.get('StartupInstances').get('proxy'): params['proxy'] = int( json.get('StartupInstances').get('proxy')) if json.get('StartupInstances').get('web'): params['web'] = int(json.get('StartupInstances').get('web')) if json.get('StartupInstances').get('backend'): params['backend'] = int( json.get('StartupInstances').get('backend')) res = self.add_nodes(sid, params) if 'error' in res: return res['error'] return 'ok'