1# Licensed to the Apache Software Foundation (ASF) under one or more 2# contributor license agreements. See the NOTICE file distributed with 3# this work for additional information regarding copyright ownership. 4# The ASF licenses this file to You under the Apache License, Version 2.0 5# (the "License"); you may not use this file except in compliance with 6# the License. You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16__all__ = [ 17 'Provider', 18 'ContainerState' 19] 20 21 22class Type(object): 23 @classmethod 24 def tostring(cls, value): 25 """Return the string representation of the state object attribute 26 :param str value: the state object to turn into string 27 :return: the uppercase string that represents the state object 28 :rtype: str 29 """ 30 return value.upper() 31 32 @classmethod 33 def fromstring(cls, value): 34 """Return the state object attribute that matches the string 35 :param str value: the string to look up 36 :return: the state object attribute that matches the string 37 :rtype: str 38 """ 39 return getattr(cls, value.upper(), None) 40 41 42class Provider(object): 43 """ 44 Defines for each of the supported providers 45 46 Non-Dummy drivers are sorted in alphabetical order. Please preserve this 47 ordering when adding new drivers. 48 """ 49 DUMMY = 'dummy' 50 DOCKER = 'docker' 51 ECS = 'ecs' 52 GKE = 'GKE' 53 JOYENT = 'joyent' 54 KUBERNETES = 'kubernetes' 55 LXD = 'lxd' 56 RANCHER = 'rancher' 57 58 59class ContainerState(Type): 60 """ 61 Standard states for a container 62 63 :cvar RUNNING: Container is running. 64 :cvar REBOOTING: Container is rebooting. 65 :cvar TERMINATED: Container is terminated. 66 This container can't be started later on. 67 :cvar STOPPED: Container is stopped. 68 This container can be started later on. 69 :cvar PENDING: Container is pending. 70 :cvar SUSPENDED: Container is suspended. 71 :cvar ERROR: Container is an error state. 72 Usually no operations can be performed 73 on the container once it ends up in the error state. 74 :cvar PAUSED: Container is paused. 75 :cvar UNKNOWN: Container state is unknown. 76 """ 77 RUNNING = 'running' 78 REBOOTING = 'rebooting' 79 TERMINATED = 'terminated' 80 PENDING = 'pending' 81 UNKNOWN = 'unknown' 82 STOPPED = 'stopped' 83 SUSPENDED = 'suspended' 84 ERROR = 'error' 85 PAUSED = 'paused' 86