def create_in_etcd(self, name, write_data): spec, labels, annotations = write_data return datamodel_v3.put(self.resource_kind, self.namespace, name, spec, labels=labels, annotations=annotations, mod_revision=0)
def update_in_etcd(self, name, write_data, mod_revision=etcdv3.MUST_UPDATE): spec, labels, annotations = write_data return datamodel_v3.put(self.resource_kind, self.namespace, name, spec, labels=labels, annotations=annotations, mod_revision=mod_revision)
def write_endpoint(self, port, context): # Reread the current port. This protects against concurrent writes # breaking our state. port = self.db.get_port(context, port['id']) # Fill out other information we need on the port. port = self.add_extra_port_information(context, port) # Write the security policies for this port. self.policy_syncer.write_sgs_to_etcd(port['security_groups'], context) # Implementation note: we could arguably avoid holding the transaction # for this length and instead release it here, then use atomic CAS. The # problem there is that we potentially have to repeatedly respin and # regain the transaction. Let's not do that for now, and performance # test to see if it's a problem later. datamodel_v3.put("WorkloadEndpoint", self.namespace, endpoint_name(port), endpoint_spec(port), labels=endpoint_labels(port, self.namespace), annotations=endpoint_annotations(port))
def update_in_etcd(self, name, spec, mod_revision=None): return datamodel_v3.put(self.resource_kind, self.namespace, name, spec, mod_revision=mod_revision)