Last active
August 29, 2015 13:56
-
-
Save AdamSaleh/9076239 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from .architecture import Architecture # noqa | |
from .domain import Domain # noqa | |
from .environment import Environment # noqa | |
from .host import Host # noqa | |
from .operatingsystem import OperatingSystem # noqa | |
from .partitiontable import PartitionTable # noqa | |
from .smartproxy import SmartProxy # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--------------------------------------------------------------------------- | |
ImportError Traceback (most recent call last) | |
<ipython-input-1-f3d7317134fb> in <module>() | |
----> 1 import robottelo.records.host | |
/home/asaleh/Robotello/robottelo/robottelo/records/host.py in <module>() | |
1 from robottelo.common import records | |
2 from robottelo.api.apicrud import ApiCrud | |
----> 3 from robottelo.records import Environment | |
4 from robottelo.records import Architecture | |
5 from robottelo.records import Domain | |
ImportError: cannot import name Environment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from robottelo.common import records | |
from robottelo.api.apicrud import ApiCrud | |
from robottelo.records import Environment | |
from robottelo.records import Architecture | |
from robottelo.records import Domain | |
from robottelo.records import SmartProxy | |
from robottelo.records import PartitionTable | |
from robottelo.records import OperatingSystem | |
class HostApi(ApiCrud): | |
api_path = "/api/hosts/" | |
api_json_key = u"host" | |
create_fields = ["name", | |
"environment_id", | |
"architecture_id", | |
"root_pass", | |
"mac", | |
"domain_id", | |
"puppet_proxy_id", | |
"ptable_id", | |
"operatingsystem_id"] | |
class Host(records.Record): | |
name = records.StringField(format=r"host\d\d\d\d\d") | |
root_pass = records.StringField(default = "changeme") | |
mac = records.MACField() | |
environment = records.RelatedField(Environment) | |
architecture = records.RelatedField(Architecture) | |
domain = records.RelatedField(Domain) | |
puppet_proxy = records.RelatedField(SmartProxy) | |
operatingsystem = records.RelatedField(OperatingSystem) | |
ptable = records.RelatedField(PartitionTable) | |
def _post_init(self): | |
self.name = self.name + "." + self.domain.name | |
self.architecture.operatingsystem = [self.operatingsystem] | |
self.ptable.operatingsystem = [self.operatingsystem] | |
class Meta: | |
api_class = HostApi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment